[PATCH v3 19/25] powerpc/ftrace: Minimise number of #ifdefs

Christophe Leroy christophe.leroy at csgroup.eu
Wed May 18 22:04:28 AEST 2022



Le 18/05/2022 à 13:19, Michael Ellerman a écrit :
> "Naveen N. Rao" <naveen.n.rao at linux.vnet.ibm.com> writes:
>> Christophe Leroy wrote:
>>> A lot of #ifdefs can be replaced by IS_ENABLED()
>>>
>>> Do so.
>>>
>>> This requires to have kernel_toc_addr() defined at all time
>>> as well as PPC_INST_LD_TOC and PPC_INST_STD_LR.
>>>
>>> Signed-off-by: Christophe Leroy <christophe.leroy at csgroup.eu>
>>> ---
>>> v2: Moved the setup of pop outside of the big if()/else() in __ftrace_make_nop()
>>> ---
>>>   arch/powerpc/include/asm/code-patching.h |   2 -
>>>   arch/powerpc/include/asm/module.h        |   2 -
>>>   arch/powerpc/include/asm/sections.h      |  24 +--
>>>   arch/powerpc/kernel/trace/ftrace.c       | 182 +++++++++++------------
>>>   4 files changed, 103 insertions(+), 107 deletions(-)
>>>
>>
>> <snip>
>>
>>> @@ -710,6 +707,9 @@ void arch_ftrace_update_code(int command)
>>>
>>>   #ifdef CONFIG_PPC64
>>>   #define PACATOC offsetof(struct paca_struct, kernel_toc)
>>> +#else
>>> +#define PACATOC 0
>>> +#endif
>>
>> This conflicts with my fix for the ftrace init tramp:
>> https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20220516071422.463738-1-naveen.n.rao@linux.vnet.ibm.com/
>>
>> It probably makes sense to retain #ifdef CONFIG_PPC64, so that we can
>> get rid of the PACATOC. Here is an incremental diff:
> 
> Where is the incremental diff meant to apply?
> 
> It doesn't apply on top of patch 19, or at the end of the series.

White space damage it seems.

I'll send you a proper fixup for that patch in a few minutes.


> 
> cheers
> 
>> diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
>> index da1a2f8ebb72f3..28169a1ccc7377 100644
>> --- a/arch/powerpc/kernel/trace/ftrace.c
>> +++ b/arch/powerpc/kernel/trace/ftrace.c
>> @@ -701,11 +701,6 @@ void arch_ftrace_update_code(int command)
>>   }
>>   
>>   #ifdef CONFIG_PPC64
>> -#define PACATOC offsetof(struct paca_struct, kernel_toc)
>> -#else
>> -#define PACATOC 0
>> -#endif
>> -
>>   extern unsigned int ftrace_tramp_text[], ftrace_tramp_init[];
>>   
>>   void ftrace_free_init_tramp(void)
>> @@ -724,7 +719,7 @@ int __init ftrace_dyn_arch_init(void)
>>   	int i;
>>   	unsigned int *tramp[] = { ftrace_tramp_text, ftrace_tramp_init };
>>   	u32 stub_insns[] = {
>> -		PPC_RAW_LD(_R12, _R13, PACATOC),
>> +		PPC_RAW_LD(_R12, _R13, offsetof(struct paca_struct, kernel_toc)),
>>   		PPC_RAW_ADDIS(_R12, _R12, 0),
>>   		PPC_RAW_ADDI(_R12, _R12, 0),
>>   		PPC_RAW_MTCTR(_R12),
>> @@ -733,9 +728,6 @@ int __init ftrace_dyn_arch_init(void)
>>   	unsigned long addr;
>>   	long reladdr;
>>   
>> -	if (IS_ENABLED(CONFIG_PPC32))
>> -		return 0;
>> -
>>   	addr = ppc_global_function_entry((void *)FTRACE_REGS_ADDR);
>>   	reladdr = addr - kernel_toc_addr();
>>   
>> @@ -754,6 +746,7 @@ int __init ftrace_dyn_arch_init(void)
>>   
>>   	return 0;
>>   }
>> +#endif
>>   
>>   #ifdef CONFIG_FUNCTION_GRAPH_TRACER
>>   
>>
>> - Naveen


More information about the Linuxppc-dev mailing list