diff mbox series

[v1,06/22] powerpc/ftrace: Inline ftrace_modify_code()

Message ID 3b651381f4c53988ede62f4a1505e7e8ccab56b4.1648131740.git.christophe.leroy@csgroup.eu (mailing list archive)
State Superseded
Headers show
Series powerpc: ftrace optimisation and cleanup and more [v1] | expand

Commit Message

Christophe Leroy March 24, 2022, 2:29 p.m. UTC
Inlining ftrace_modify_code(), it increases a bit the
size of ftrace code but brings 5% improvment on ftrace
activation.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/kernel/trace/ftrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Naveen N. Rao April 18, 2022, 6:07 a.m. UTC | #1
Christophe Leroy wrote:
> Inlining ftrace_modify_code(), it increases a bit the
> size of ftrace code but brings 5% improvment on ftrace
> activation.
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
>  arch/powerpc/kernel/trace/ftrace.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
> index 41c45b9c7f39..98e82fa4980f 100644
> --- a/arch/powerpc/kernel/trace/ftrace.c
> +++ b/arch/powerpc/kernel/trace/ftrace.c
> @@ -53,7 +53,7 @@ ftrace_call_replace(unsigned long ip, unsigned long addr, int link)
>  	return op;
>  }
> 
> -static int
> +static inline int
>  ftrace_modify_code(unsigned long ip, ppc_inst_t old, ppc_inst_t new)
>  {
>  	ppc_inst_t replaced;

I thought gcc was free to inline functions without the need for 
'inline'. Don't you see this being inlined otherwise?

On the flip side, don't we need __always_inline if we want to force 
inlining?


- Naveen
Michael Ellerman April 22, 2022, 9:12 a.m. UTC | #2
"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> writes:
> Christophe Leroy wrote:
>> Inlining ftrace_modify_code(), it increases a bit the
>> size of ftrace code but brings 5% improvment on ftrace
>> activation.
>> 
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>>  arch/powerpc/kernel/trace/ftrace.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
>> index 41c45b9c7f39..98e82fa4980f 100644
>> --- a/arch/powerpc/kernel/trace/ftrace.c
>> +++ b/arch/powerpc/kernel/trace/ftrace.c
>> @@ -53,7 +53,7 @@ ftrace_call_replace(unsigned long ip, unsigned long addr, int link)
>>  	return op;
>>  }
>> 
>> -static int
>> +static inline int
>>  ftrace_modify_code(unsigned long ip, ppc_inst_t old, ppc_inst_t new)
>>  {
>>  	ppc_inst_t replaced;
>
> I thought gcc was free to inline functions without the need for 
> 'inline'.

Yes it is.

> On the flip side, don't we need __always_inline if we want to force 
> inlining?

Yes. Since ac7c3e4ff401 ("compiler: enable CONFIG_OPTIMIZE_INLINING forcibly").

cheers
Christophe Leroy May 4, 2022, 11:43 a.m. UTC | #3
Le 18/04/2022 à 08:07, Naveen N. Rao a écrit :
> Christophe Leroy wrote:
>> Inlining ftrace_modify_code(), it increases a bit the
>> size of ftrace code but brings 5% improvment on ftrace
>> activation.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>>  arch/powerpc/kernel/trace/ftrace.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/kernel/trace/ftrace.c 
>> b/arch/powerpc/kernel/trace/ftrace.c
>> index 41c45b9c7f39..98e82fa4980f 100644
>> --- a/arch/powerpc/kernel/trace/ftrace.c
>> +++ b/arch/powerpc/kernel/trace/ftrace.c
>> @@ -53,7 +53,7 @@ ftrace_call_replace(unsigned long ip, unsigned long 
>> addr, int link)
>>      return op;
>>  }
>>
>> -static int
>> +static inline int
>>  ftrace_modify_code(unsigned long ip, ppc_inst_t old, ppc_inst_t new)
>>  {
>>      ppc_inst_t replaced;
> 
> I thought gcc was free to inline functions without the need for 
> 'inline'. Don't you see this being inlined otherwise?

Yep, gcc is free to inline, but in that case it doesn't inline unless 
you suggest it to do so.

> 
> On the flip side, don't we need __always_inline if we want to force 
> inlining?

The question is, do we want to force inlining, even with 
CONFIG_CC_OPTIMIZE_FOR_SIZE ?

With 'inline', gcc seems to now inline it with 
CONFIG_CC_OPTIMIZE_FOR_SPEED and still keep it out of line with 
CONFIG_CC_OPTIMIZE_FOR_SIZE.

Christophe
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
index 41c45b9c7f39..98e82fa4980f 100644
--- a/arch/powerpc/kernel/trace/ftrace.c
+++ b/arch/powerpc/kernel/trace/ftrace.c
@@ -53,7 +53,7 @@  ftrace_call_replace(unsigned long ip, unsigned long addr, int link)
 	return op;
 }
 
-static int
+static inline int
 ftrace_modify_code(unsigned long ip, ppc_inst_t old, ppc_inst_t new)
 {
 	ppc_inst_t replaced;