From: Steven Rostedt <rostedt@goodmis.org> To: Torsten Duwe <duwe@lst.de> Cc: Mark Rutland <mark.rutland@arm.com>, Will Deacon <will.deacon@arm.com>, Catalin Marinas <catalin.marinas@arm.com>, Julien Thierry <julien.thierry@arm.com>, Josh Poimboeuf <jpoimboe@redhat.com>, Ingo Molnar <mingo@redhat.com>, Ard Biesheuvel <ard.biesheuvel@linaro.org>, Arnd Bergmann <arnd@arndb.de>, AKASHI Takahiro <takahiro.akashi@linaro.org>, Amit Daniel Kachhap <amit.kachhap@arm.com>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> Subject: Re: [PATCH v6] arm64: implement ftrace with regs Date: Sat, 5 Jan 2019 15:00:11 -0500 [thread overview] Message-ID: <20190105150011.6062d818@gandalf.local.home> (raw) In-Reply-To: <20190105110543.GA4298@lst.de> On Sat, 5 Jan 2019 12:05:43 +0100 Torsten Duwe <duwe@lst.de> wrote: > > My point is: those 2 insn will _never_ be split by any alignment > > boundary > 8; does that mean anything, have you considered this? > > Forget that. Steve mentioned the keyword *interrupt*, which creates a > completely different situation. In short, only the instruction pointer > will be saved; and i-cache and pipeline will be freshly reloaded on return, > so this threat is highly unlikely (interrupt taken exactly after 1st nop), > but not impossible. "Puking horses..." as we say in German. Correct. > > > > > I wonder if we could solve that by patching the kernel at build-time, to > > > > add the MOV X9, X30 in place of the first NOP. If we were to do that, we > > > > could also update the addresses to pooint at the second NOP, simplifying > > > > the changes to the runtime code. > > > > > > You can also patch it at boot up when there's only one CPU running, and > > > interrupts are disabled. > > > > May I remind about possible performance hits? Even the NOPs had a tiny impact > > on certain in-order implementations. I'd rather switch between the mov and > > a "b +2". > > This one however still holds. Now, if you can add one of the changes, do a synchronization to make sure that all tasks are not preempted there, and see that first change, then make the other change to complete the transaction, there may be a solution: synchronize_rcu_tasks()! convert all first nops to "MOV X9, X30" synchronize_rcu_tasks(); convert all second nops to "BL ftrace_regs_caller" That would work. What synchronize_rcu_tasks() does, is that it wont return until all tasks have either called schedule voluntarily (not preempted), goes into user space, or goes idle. Tasks that are idle (not preempted) are not counted. Then you are guaranteed that no task was preempted at the first nop and will come back and call "BL ftrace_regs_caller". The only caveat is that synchronize_rcu_tasks() can take some time to complete (seconds even) if something was preempted and is starved from the CPU for some time. This is why you would need to group the conversions together, by changing all the first nops for all the functions you want to trace before calling the synchronization routine. -- Steve
WARNING: multiple messages have this Message-ID (diff)
From: Steven Rostedt <rostedt@goodmis.org> To: Torsten Duwe <duwe@lst.de> Cc: Mark Rutland <mark.rutland@arm.com>, Arnd Bergmann <arnd@arndb.de>, Julien Thierry <julien.thierry@arm.com>, Catalin Marinas <catalin.marinas@arm.com>, Ard Biesheuvel <ard.biesheuvel@linaro.org>, Will Deacon <will.deacon@arm.com>, linux-kernel@vger.kernel.org, AKASHI Takahiro <takahiro.akashi@linaro.org>, Ingo Molnar <mingo@redhat.com>, Josh Poimboeuf <jpoimboe@redhat.com>, Amit Daniel Kachhap <amit.kachhap@arm.com>, live-patching@vger.kernel.org, "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v6] arm64: implement ftrace with regs Date: Sat, 5 Jan 2019 15:00:11 -0500 [thread overview] Message-ID: <20190105150011.6062d818@gandalf.local.home> (raw) In-Reply-To: <20190105110543.GA4298@lst.de> On Sat, 5 Jan 2019 12:05:43 +0100 Torsten Duwe <duwe@lst.de> wrote: > > My point is: those 2 insn will _never_ be split by any alignment > > boundary > 8; does that mean anything, have you considered this? > > Forget that. Steve mentioned the keyword *interrupt*, which creates a > completely different situation. In short, only the instruction pointer > will be saved; and i-cache and pipeline will be freshly reloaded on return, > so this threat is highly unlikely (interrupt taken exactly after 1st nop), > but not impossible. "Puking horses..." as we say in German. Correct. > > > > > I wonder if we could solve that by patching the kernel at build-time, to > > > > add the MOV X9, X30 in place of the first NOP. If we were to do that, we > > > > could also update the addresses to pooint at the second NOP, simplifying > > > > the changes to the runtime code. > > > > > > You can also patch it at boot up when there's only one CPU running, and > > > interrupts are disabled. > > > > May I remind about possible performance hits? Even the NOPs had a tiny impact > > on certain in-order implementations. I'd rather switch between the mov and > > a "b +2". > > This one however still holds. Now, if you can add one of the changes, do a synchronization to make sure that all tasks are not preempted there, and see that first change, then make the other change to complete the transaction, there may be a solution: synchronize_rcu_tasks()! convert all first nops to "MOV X9, X30" synchronize_rcu_tasks(); convert all second nops to "BL ftrace_regs_caller" That would work. What synchronize_rcu_tasks() does, is that it wont return until all tasks have either called schedule voluntarily (not preempted), goes into user space, or goes idle. Tasks that are idle (not preempted) are not counted. Then you are guaranteed that no task was preempted at the first nop and will come back and call "BL ftrace_regs_caller". The only caveat is that synchronize_rcu_tasks() can take some time to complete (seconds even) if something was preempted and is starved from the CPU for some time. This is why you would need to group the conversions together, by changing all the first nops for all the functions you want to trace before calling the synchronization routine. -- Steve _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-01-05 20:00 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-01-04 14:10 [PATCH v6] arm64: implement ftrace with regs Torsten Duwe 2019-01-04 14:10 ` Torsten Duwe 2019-01-04 17:50 ` Mark Rutland 2019-01-04 17:50 ` Mark Rutland 2019-01-04 18:06 ` Steven Rostedt 2019-01-04 18:06 ` Steven Rostedt 2019-01-04 22:41 ` Torsten Duwe 2019-01-04 22:41 ` Torsten Duwe 2019-01-05 11:05 ` Torsten Duwe 2019-01-05 11:05 ` Torsten Duwe 2019-01-05 20:00 ` Steven Rostedt [this message] 2019-01-05 20:00 ` Steven Rostedt 2019-01-07 11:19 ` Mark Rutland 2019-01-07 11:19 ` Mark Rutland 2019-01-14 12:13 ` Balbir Singh 2019-01-14 12:13 ` Balbir Singh 2019-01-14 12:26 ` Mark Rutland 2019-01-14 12:26 ` Mark Rutland 2019-01-16 15:56 ` Julien Thierry 2019-01-16 15:56 ` Julien Thierry 2019-01-16 18:01 ` Julien Thierry 2019-01-16 18:01 ` Julien Thierry 2019-01-07 4:57 ` Amit Daniel Kachhap 2019-01-07 4:57 ` Amit Daniel Kachhap 2019-01-16 9:57 ` Julien Thierry 2019-01-16 9:57 ` Julien Thierry 2019-01-16 10:08 ` Julien Thierry 2019-01-16 10:08 ` Julien Thierry 2019-01-17 15:48 ` Torsten Duwe 2019-01-17 15:48 ` Torsten Duwe
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190105150011.6062d818@gandalf.local.home \ --to=rostedt@goodmis.org \ --cc=amit.kachhap@arm.com \ --cc=ard.biesheuvel@linaro.org \ --cc=arnd@arndb.de \ --cc=catalin.marinas@arm.com \ --cc=duwe@lst.de \ --cc=jpoimboe@redhat.com \ --cc=julien.thierry@arm.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=live-patching@vger.kernel.org \ --cc=mark.rutland@arm.com \ --cc=mingo@redhat.com \ --cc=paulmck@linux.vnet.ibm.com \ --cc=takahiro.akashi@linaro.org \ --cc=will.deacon@arm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.