From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Ingo Molnar <mingo@redhat.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Paul Mackerras <paulus@samba.org>,
Steven Rostedt <rostedt@goodmis.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH v1 16/22] powerpc/ftrace: Minimise number of #ifdefs
Date: Wed, 4 May 2022 12:44:01 +0000 [thread overview]
Message-ID: <004a9b6b-2722-45ec-b13a-577b9dd72312@csgroup.eu> (raw)
In-Reply-To: <1650267933.ewyj9l63lo.naveen@linux.ibm.com>
Le 18/04/2022 à 09:59, Naveen N. Rao a écrit :
> 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
>> and PPC_INST_LD_TOC as well.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>> 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 | 201 ++++++++++++-----------
>> 4 files changed, 113 insertions(+), 116 deletions(-)
>>
>> diff --git a/arch/powerpc/include/asm/code-patching.h
>> b/arch/powerpc/include/asm/code-patching.h
>> index 4260e89f62b1..071fcbec31c5 100644
>> --- a/arch/powerpc/include/asm/code-patching.h
>> +++ b/arch/powerpc/include/asm/code-patching.h
>> @@ -217,7 +217,6 @@ static inline unsigned long
>> ppc_kallsyms_lookup_name(const char *name)
>> return addr;
>> }
>>
>> -#ifdef CONFIG_PPC64
>> /*
>> * Some instruction encodings commonly used in dynamic ftracing
>> * and function live patching.
>> @@ -234,6 +233,5 @@ static inline unsigned long
>> ppc_kallsyms_lookup_name(const char *name)
>>
>> /* usually preceded by a mflr r0 */
>> #define PPC_INST_STD_LR PPC_RAW_STD(_R0, _R1, PPC_LR_STKOFF)
>> -#endif /* CONFIG_PPC64 */
>>
>> #endif /* _ASM_POWERPC_CODE_PATCHING_H */
>> diff --git a/arch/powerpc/include/asm/module.h
>> b/arch/powerpc/include/asm/module.h
>> index e6f5963fd96e..700d7ecd9012 100644
>> --- a/arch/powerpc/include/asm/module.h
>> +++ b/arch/powerpc/include/asm/module.h
>> @@ -41,9 +41,7 @@ struct mod_arch_specific {
>>
>> #ifdef CONFIG_FUNCTION_TRACER
>> unsigned long tramp;
>> -#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
>> unsigned long tramp_regs;
>> -#endif
>> #endif
>>
>> /* List of BUG addresses, source line numbers and filenames */
>> diff --git a/arch/powerpc/include/asm/sections.h
>> b/arch/powerpc/include/asm/sections.h
>> index 8be2c491c733..6980eaeb16fe 100644
>> --- a/arch/powerpc/include/asm/sections.h
>> +++ b/arch/powerpc/include/asm/sections.h
>> @@ -29,18 +29,6 @@ extern char start_virt_trampolines[];
>> extern char end_virt_trampolines[];
>> #endif
>>
>> -/*
>> - * This assumes the kernel is never compiled -mcmodel=small or
>> - * the total .toc is always less than 64k.
>> - */
>> -static inline unsigned long kernel_toc_addr(void)
>> -{
>> - unsigned long toc_ptr;
>> -
>> - asm volatile("mr %0, 2" : "=r" (toc_ptr));
>> - return toc_ptr;
>> -}
>> -
>> static inline int overlaps_interrupt_vector_text(unsigned long start,
>> unsigned long end)
>> {
>> @@ -60,5 +48,17 @@ static inline int overlaps_kernel_text(unsigned
>> long start, unsigned long end)
>>
>> #endif
>>
>> +/*
>> + * This assumes the kernel is never compiled -mcmodel=small or
>> + * the total .toc is always less than 64k.
>> + */
>> +static inline unsigned long kernel_toc_addr(void)
>> +{
>> + unsigned long toc_ptr;
>> +
>> + asm volatile("mr %0, 2" : "=r" (toc_ptr));
>> + return toc_ptr;
>> +}
>> +
>> #endif /* __KERNEL__ */
>> #endif /* _ASM_POWERPC_SECTIONS_H */
>> diff --git a/arch/powerpc/kernel/trace/ftrace.c
>> b/arch/powerpc/kernel/trace/ftrace.c
>> index ffedf8c82ea8..4dd30e396026 100644
>> --- a/arch/powerpc/kernel/trace/ftrace.c
>> +++ b/arch/powerpc/kernel/trace/ftrace.c
>> @@ -150,55 +150,55 @@ __ftrace_make_nop(struct module *mod,
>> return -EINVAL;
>> }
>>
>> - /* When using -mkernel_profile or PPC32 there is no load to jump
>> over */
>> - pop = ppc_inst(PPC_RAW_NOP());
>> + if (IS_ENABLED(CONFIG_MPROFILE_KERNEL)) {
>> + /* When using -mkernel_profile or PPC32 there is no load to
>> jump over */
>> + pop = ppc_inst(PPC_RAW_NOP());
>
> Why move this inside the if() statement? You can keep this out and drop
> the else clause.
I find it less error prone that way.
Putting a bad value and then replace it later with the good one can be
misleading, and if some day someone removes that second set by error, it
will go unnoticed. When you set it only once, GCC will complain in case
that setting disappear by error.
Christophe
next prev parent reply other threads:[~2022-05-04 12:44 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-24 14:29 [PATCH v1 00/22] powerpc: ftrace optimisation and cleanup and more [v1] Christophe Leroy
2022-03-24 14:29 ` [PATCH v1 01/22] powerpc/ftrace: Refactor prepare_ftrace_return() Christophe Leroy
2022-03-24 14:29 ` [PATCH v1 02/22] powerpc/ftrace: Remove redundant create_branch() calls Christophe Leroy
2022-03-24 14:29 ` [PATCH v1 03/22] powerpc/code-patching: Inline is_offset_in_{cond}_branch_range() Christophe Leroy
2022-03-24 14:29 ` [PATCH v1 04/22] powerpc/ftrace: Use is_offset_in_branch_range() Christophe Leroy
2022-03-24 14:29 ` [PATCH v1 05/22] powerpc/code-patching: Inline create_branch() Christophe Leroy
2022-03-24 14:29 ` [PATCH v1 06/22] powerpc/ftrace: Inline ftrace_modify_code() Christophe Leroy
2022-04-18 6:07 ` Naveen N. Rao
2022-04-22 9:12 ` Michael Ellerman
2022-05-04 11:43 ` Christophe Leroy
2022-03-24 14:29 ` [PATCH v1 07/22] powerpc/ftrace: Use patch_instruction() return directly Christophe Leroy
2022-04-18 6:21 ` Naveen N. Rao
2022-04-18 19:44 ` Steven Rostedt
2022-05-04 12:01 ` Christophe Leroy
2022-03-24 14:29 ` [PATCH v1 08/22] powerpc/ftrace: Make __ftrace_make_{nop/call}() common to PPC32 and PPC64 Christophe Leroy
2022-04-18 6:40 ` Naveen N. Rao
2022-05-04 12:19 ` Christophe Leroy
2022-05-06 11:41 ` Christophe Leroy
2022-03-24 14:29 ` [PATCH v1 09/22] powerpc/ftrace: Don't include ftrace.o for CONFIG_FTRACE_SYSCALLS Christophe Leroy
2022-03-24 14:30 ` [PATCH v1 10/22] powerpc/ftrace: Use CONFIG_FUNCTION_TRACER instead of CONFIG_DYNAMIC_FTRACE Christophe Leroy
2022-04-18 7:00 ` Naveen N. Rao
2022-05-06 11:41 ` Christophe Leroy
2022-03-24 14:30 ` [PATCH v1 11/22] powerpc/ftrace: Remove ftrace_plt_tramps[] Christophe Leroy
2022-03-24 14:30 ` [PATCH v1 12/22] powerpc/ftrace: Use BRANCH_SET_LINK instead of value 1 Christophe Leroy
2022-03-24 14:30 ` [PATCH v1 13/22] powerpc/ftrace: Use PPC_RAW_xxx() macros instead of opencoding Christophe Leroy
2022-04-18 7:38 ` Naveen N. Rao
2022-05-04 12:39 ` Christophe Leroy
2022-05-05 16:47 ` Christophe Leroy
2022-03-24 14:30 ` [PATCH v1 14/22] powerpc/ftrace: Use size macro " Christophe Leroy
2022-03-24 14:30 ` [PATCH v1 15/22] powerpc/ftrace: Simplify expected_nop_sequence() Christophe Leroy
2022-03-24 14:30 ` [PATCH v1 16/22] powerpc/ftrace: Minimise number of #ifdefs Christophe Leroy
2022-04-18 7:59 ` Naveen N. Rao
2022-05-04 12:44 ` Christophe Leroy [this message]
2022-03-24 14:30 ` [PATCH v1 17/22] powerpc/inst: Add __copy_inst_from_kernel_nofault() Christophe Leroy
2022-03-24 14:30 ` [PATCH v1 18/22] powerpc/ftrace: Don't use copy_from_kernel_nofault() in module_trampoline_target() Christophe Leroy
2022-03-24 14:30 ` [PATCH v1 19/22] powerpc/inst: Remove PPC_INST_BRANCH Christophe Leroy
2022-03-24 14:30 ` [PATCH v1 20/22] powerpc/modules: Use PPC_INST_BRANCH_MASK instead of opencoding Christophe Leroy
2022-03-24 14:30 ` [PATCH v1 21/22] powerpc/inst: Remove PPC_INST_BL Christophe Leroy
2022-03-24 14:30 ` [PATCH v1 22/22] powerpc/opcodes: Remove unused PPC_INST_XXX macros Christophe Leroy
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=004a9b6b-2722-45ec-b13a-577b9dd72312@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=naveen.n.rao@linux.vnet.ibm.com \
--cc=paulus@samba.org \
--cc=rostedt@goodmis.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®