[RFC PATCH v2 3/5] powerpc/ftrace: Unify 32-bit and 64-bit ftrace entry code

Steven Rostedt rostedt at goodmis.org
Wed Jun 12 01:14:44 AEST 2024


On Tue, 11 Jun 2024 20:17:19 +0530
Naveen N Rao <naveen at kernel.org> wrote:

> > I know it's very unlikely, but in theory, I think the race exists.  
> 
> I *think* you are assuming that we will be patching back the 'stw' 

Yes, that was what I was assuming :-p

> instruction here? So, there could be an issue if a cpu has executed the 
> nop instead of 'stw' and then sees the call to _mcount().
> 
> But, we don't patch back the 'stw' instruction. That is instead done as 
> part of ftrace_caller(), along with setting up an additional stack frame 
> to ensure reliable stack unwinding. Commit 41a506ef71eb 
> ("powerpc/ftrace: Create a dummy stackframe to fix stack unwind") has 
> more details.
> 
> The primary motivation for this patch is to address differences in the 
> function profile sequence with various toolchains. Since commit 
> 0f71dcfb4aef ("powerpc/ftrace: Add support for 
> -fpatchable-function-entry"), we use the same two-instruction profile 
> sequence across 32-bit and 64-bit powerpc:
> 	mflr	r0
> 	bl	ftrace_caller
> 
> This has also been true on 64-bit powerpc with -mprofile-kernel, except 
> the very early versions of gcc that supported that option (gcc v5).
> 
> On 32-bit powerpc, we used to use the three instruction sequence before 
> support for -fpatchable-function-entry was introduced.
> 
> In this patch, we move all toolchain variants to use the two-instruction 
> sequence for consistency.

OK, if you are not patching that back, then all should be good.

-- Steve


More information about the Linuxppc-dev mailing list