ftrace: Cleanup ftrace_dyn_arch_init()
Subsystems (14)
PATCH v3 1/1 ftrace: Cleanup ftrace_dyn_arch_init()
Most of ARCHs use empty ftrace_dyn_arch_init(), introduce a weak common ftrace_dyn_arch_init() to cleanup them.
---
Changes in v3:
-- fix unrecognized opcode on PowerPC
Changes in v2:
-- correct CONFIG_DYNAMIC_FTRACE on PowerPC
-- add Acked-by tag
--- arch/arm/kernel/ftrace.c | 5 ----- arch/arm64/kernel/ftrace.c | 5 ----- arch/csky/kernel/ftrace.c | 5 ----- arch/ia64/kernel/ftrace.c | 6 ------ arch/microblaze/kernel/ftrace.c | 5 ----- arch/mips/include/asm/ftrace.h | 2 ++ arch/nds32/kernel/ftrace.c | 5 ----- arch/parisc/kernel/ftrace.c | 5 ----- arch/powerpc/include/asm/ftrace.h | 4 ++++ arch/riscv/kernel/ftrace.c | 5 ----- arch/s390/kernel/ftrace.c | 5 ----- arch/sh/kernel/ftrace.c | 5 ----- arch/sparc/kernel/ftrace.c | 5 ----- arch/x86/kernel/ftrace.c | 5 ----- include/linux/ftrace.h | 1 - kernel/trace/ftrace.c | 5 +++++ 16 files changed, 11 insertions(+), 62 deletions(-)
arch/arm/kernel/ftrace.c +0 -5
@@ -193,11 +193,6 @@ int ftrace_make_nop(struct module *mod, return ret; } - -int __init ftrace_dyn_arch_init (void ) -{ -return 0 ; -}#endif /* CONFIG_DYNAMIC_FTRACE */ #ifdef CONFIG_FUNCTION_GRAPH_TRACER
arch/arm64/kernel/ftrace.c +0 -5
@@ -236,11 +236,6 @@ void arch_ftrace_update_code(int command) command |=FTRACE_MAY_SLEEP ; ftrace_modify_all_code(command); } - -int __init ftrace_dyn_arch_init (void ) -{ -return 0 ; -}#endif /* CONFIG_DYNAMIC_FTRACE */ #ifdef CONFIG_FUNCTION_GRAPH_TRACER
arch/csky/kernel/ftrace.c +0 -5
@@ -133,11 +133,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func) (unsigned long)func, true, true); return ret; } - -int __init ftrace_dyn_arch_init (void ) -{ -return 0 ; -}#endif /* CONFIG_DYNAMIC_FTRACE */ #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
arch/ia64/kernel/ftrace.c +0 -6
@@ -194,9 +194,3 @@ int ftrace_update_ftrace_func(ftrace_func_t func)flush_icache_range (addr, addr +16 );return 0 ; } - -/* run from kstop_machine */ -int __init ftrace_dyn_arch_init (void ) -{ -return 0 ; -}
arch/microblaze/kernel/ftrace.c +0 -5
@@ -163,11 +163,6 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)return ret; } -int __init ftrace_dyn_arch_init (void ) -{ -return 0 ; -} -int ftrace_update_ftrace_func (ftrace_func_t func) {unsigned long ip = (unsigned long )(&ftrace_call);
arch/mips/include/asm/ftrace.h +2 -0
@@ -76,6 +76,8 @@ do { \#ifdef CONFIG_DYNAMIC_FTRACE +int __init ftrace_dyn_arch_init (void ); +static inline unsigned long ftrace_call_adjust (unsigned long addr) {return addr;
arch/nds32/kernel/ftrace.c +0 -5
@@ -84,11 +84,6 @@ void _ftrace_caller(unsigned long parent_ip)/* restore all state needed by the compiler epilogue */ } -int __init ftrace_dyn_arch_init (void ) -{ -return 0 ; -} -static unsigned long gen_sethi_insn (unsigned long addr) {unsigned long opcode =0x46000000 ;
arch/parisc/kernel/ftrace.c +0 -5
@@ -94,11 +94,6 @@ int ftrace_disable_ftrace_graph_caller(void)#endif #ifdef CONFIG_DYNAMIC_FTRACE - -int __init ftrace_dyn_arch_init (void ) -{ -return 0 ; -}int ftrace_update_ftrace_func (ftrace_func_t func) {return 0 ;
arch/powerpc/include/asm/ftrace.h +4 -0
@@ -126,6 +126,10 @@ static inline void this_cpu_enable_ftrace(void) { }static inline void this_cpu_set_ftrace_enabled (u8 ftrace_enabled) { }static inline u8 this_cpu_get_ftrace_enabled (void ) {return 1 ; }#endif /* CONFIG_PPC64 */ + +#ifdef CONFIG_DYNAMIC_FTRACE +int __init ftrace_dyn_arch_init (void ); +#endif /* CONFIG_DYNAMIC_FTRACE */ #endif /* !__ASSEMBLY__ */ #endif /* _ASM_POWERPC_FTRACE */
arch/riscv/kernel/ftrace.c +0 -5
@@ -154,11 +154,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func) return ret; } - -int __init ftrace_dyn_arch_init (void ) -{ -return 0 ; -}#endif #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
arch/s390/kernel/ftrace.c +0 -5
@@ -262,11 +262,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)return 0 ; } -int __init ftrace_dyn_arch_init (void ) -{ -return 0 ; -} -void arch_ftrace_update_code (int command) {if (ftrace_shared_hotpatch_trampoline (NULL ))
arch/sh/kernel/ftrace.c +0 -5
@@ -252,11 +252,6 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) return ftrace_modify_code(rec->ip, old, new); } - -int __init ftrace_dyn_arch_init (void ) -{ -return 0 ; -}#endif /* CONFIG_DYNAMIC_FTRACE */ #ifdef CONFIG_FUNCTION_GRAPH_TRACER
arch/sparc/kernel/ftrace.c +0 -5
@@ -82,11 +82,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func) new =ftrace_call_replace (ip, (unsigned long )func); return ftrace_modify_code(ip, old, new); } - -int __init ftrace_dyn_arch_init (void ) -{ -return 0 ; -}#endif #ifdef CONFIG_FUNCTION_GRAPH_TRACER
arch/x86/kernel/ftrace.c +0 -5
@@ -252,11 +252,6 @@ void arch_ftrace_update_code(int command)ftrace_modify_all_code (command); } -int __init ftrace_dyn_arch_init (void ) -{ -return 0 ; -} -/* Currently only x86_64 supports dynamic trampolines */ #ifdef CONFIG_X86_64
include/linux/ftrace.h +0 -1
@@ -573,7 +573,6 @@ ftrace_set_early_filter(struct ftrace_ops *ops, char *buf, int enable);/* defined in arch */ extern int ftrace_ip_converted (unsigned long ip); -extern int ftrace_dyn_arch_init (void );extern void ftrace_replace_code (int enable);extern int ftrace_update_ftrace_func (ftrace_func_t func);extern void ftrace_caller (void );
kernel/trace/ftrace.c +5 -0
@@ -6846,6 +6846,11 @@ void __init ftrace_free_init_mem(void)ftrace_free_mem (NULL , start, end); } +int __init __weak ftrace_dyn_arch_init (void ) +{ +return 0 ; +} +void __init ftrace_init (void ) {extern unsigned long __start_mcount_loc[];
Signature · 1 line
2.30.2
Quoted 46 lines
-----Message d'origine-----
De : Linuxppc-dev <linuxppc-dev- [email protected]> De la part de Weizhao OuyangMost of ARCHs use empty
ftrace_dyn_arch_init(), introduce a weak commonftrace_dyn_arch_init()to cleanup them.Signed-off-by Weizhao Ouyang <[email protected]>---
Changes in v3:
-- fix unrecognized opcode on PowerPCChanges in v2:
-- correctCONFIG_DYNAMIC_FTRACEon PowerPC
-- add Acked-by tag--- arch/arm/kernel/ftrace.c | 5 ----- arch/arm64/kernel/ftrace.c | 5 ----- arch/csky/kernel/ftrace.c | 5 ----- arch/ia64/kernel/ftrace.c | 6 ------ arch/microblaze/kernel/ftrace.c | 5 ----- arch/mips/include/asm/ftrace.h | 2 ++ arch/nds32/kernel/ftrace.c | 5 ----- arch/parisc/kernel/ftrace.c | 5 ----- arch/powerpc/include/asm/ftrace.h | 4 ++++ arch/riscv/kernel/ftrace.c | 5 ----- arch/s390/kernel/ftrace.c | 5 ----- arch/sh/kernel/ftrace.c | 5 ----- arch/sparc/kernel/ftrace.c | 5 ----- arch/x86/kernel/ftrace.c | 5 ----- include/linux/ftrace.h | 1 - kernel/trace/ftrace.c | 5 +++++ 16 files changed, 11 insertions(+), 62 deletions(-)arch/mips/include/asm/ftrace.h +0
-0
arch/mips/include/asm/ftrace.h do { \ · line 80
Quoted 5 lines
arch/mips/include/asm/ftrace.h +2
-0@@ -76,6 +76,8 @@ do { \#ifdef CONFIG_DYNAMIC_FTRACE +int __init ftrace_dyn_arch_init (void ); +
Why ?
Quoted 9 lines
arch/mips/include/asm/ftrace.h +0
-0static inline unsigned long ftrace_call_adjust (unsigned long addr) {return addr;arch/powerpc/include/asm/ftrace.h +0
-0
arch/powerpc/include/asm/ftrace.h static inline void this_cpu_enable_ftrace(void) { } · line 132
Quoted 7 lines
arch/powerpc/include/asm/ftrace.h +4
-0@@ -126,6 +126,10 @@ static inline void this_cpu_enable_ftrace(void) { }static inline void this_cpu_set_ftrace_enabled (u8 ftrace_enabled) { }static inline u8 this_cpu_get_ftrace_enabled (void ) {return 1 ; }#endif /* CONFIG_PPC64 */ + +#ifdef CONFIG_DYNAMIC_FTRACE +int __init ftrace_dyn_arch_init (void ); +#endif /* CONFIG_DYNAMIC_FTRACE */
Why ?
include/linux/ftrace.h ftrace_set_early_filter(struct ftrace_ops *ops, char · line 577
Quoted 13 lines
arch/powerpc/include/asm/ftrace.h +0
-0#endif /* !__ASSEMBLY__ */ #endif /* _ASM_POWERPC_FTRACE */ include/linux/ftrace.h +0
-1@@ -573,7 +573,6 @@ ftrace_set_early_filter(struct ftrace_ops *ops, char *buf, int enable);/* defined in arch */ extern int ftrace_ip_converted (unsigned long ip); -extern int ftrace_dyn_arch_init (void );
Why removing that ?
Have you tried to build kernel/trace/ftrace.o with C=2 ? It will likely tell you that the function is not declared and that it should be static
We could eventually consider that in the past, this generic declaration was unrelevant because the definitions where in the arch specific sections. Now that you are implementing a generic weak version of this function, it would make sense to have a generic declaration as well.
I really don't see the point in duplicating the declaration of the function in the arch specific headers.
Quoted 3 lines
include/linux/ftrace.h +0
-0extern void ftrace_replace_code (int enable);extern int ftrace_update_ftrace_func (ftrace_func_t func);extern void
ftrace_caller(void);
Christophe
CS Group - Document Interne
Thanks for reply.
Quoted 81 lines · LEROY Christophe
Quoted 45 lines
-----Message d'origine-----
De : Linuxppc-dev <linuxppc-dev- [email protected]> De la part de Weizhao OuyangMost of ARCHs use empty
ftrace_dyn_arch_init(), introduce a weak commonftrace_dyn_arch_init()to cleanup them.Signed-off-by Weizhao Ouyang <[email protected]>---
Changes in v3:
-- fix unrecognized opcode on PowerPCChanges in v2:
-- correctCONFIG_DYNAMIC_FTRACEon PowerPC
-- add Acked-by tag--- arch/arm/kernel/ftrace.c | 5 ----- arch/arm64/kernel/ftrace.c | 5 ----- arch/csky/kernel/ftrace.c | 5 ----- arch/ia64/kernel/ftrace.c | 6 ------ arch/microblaze/kernel/ftrace.c | 5 ----- arch/mips/include/asm/ftrace.h | 2 ++ arch/nds32/kernel/ftrace.c | 5 ----- arch/parisc/kernel/ftrace.c | 5 ----- arch/powerpc/include/asm/ftrace.h | 4 ++++ arch/riscv/kernel/ftrace.c | 5 ----- arch/s390/kernel/ftrace.c | 5 ----- arch/sh/kernel/ftrace.c | 5 ----- arch/sparc/kernel/ftrace.c | 5 ----- arch/x86/kernel/ftrace.c | 5 ----- include/linux/ftrace.h | 1 - kernel/trace/ftrace.c | 5 +++++ 16 files changed, 11 insertions(+), 62 deletions(-)arch/mips/include/asm/ftrace.h +0
-0arch/mips/include/asm/ftrace.h do { \ · line 80
Quoted 5 lines
arch/mips/include/asm/ftrace.h +2
-0@@ -76,6 +76,8 @@ do { \#ifdef CONFIG_DYNAMIC_FTRACE +int __init ftrace_dyn_arch_init (void ); +Why ?
Quoted 9 lines
arch/mips/include/asm/ftrace.h +0
-0static inline unsigned long ftrace_call_adjust (unsigned long addr) {return addr;arch/powerpc/include/asm/ftrace.h +0
-0arch/powerpc/include/asm/ftrace.h static inline void this_cpu_enable_ftrace(void) { } · line 132
Quoted 7 lines
arch/powerpc/include/asm/ftrace.h +4
-0@@ -126,6 +126,10 @@ static inline void this_cpu_enable_ftrace(void) { }static inline void this_cpu_set_ftrace_enabled (u8 ftrace_enabled) { }static inline u8 this_cpu_get_ftrace_enabled (void ) {return 1 ; }#endif /* CONFIG_PPC64 */ + +#ifdef CONFIG_DYNAMIC_FTRACE +int __init ftrace_dyn_arch_init (void ); +#endif /* CONFIG_DYNAMIC_FTRACE */ Why ?
Quoted 10 lines
arch/powerpc/include/asm/ftrace.h +0
-0#endif /* !__ASSEMBLY__ */ #endif /* _ASM_POWERPC_FTRACE */ include/linux/ftrace.h +0
-0@@ -573,7 +573,6 @@ ftrace_set_early_filter(struct ftrace_ops *ops, char *buf, int enable);
Quoted 6 lines
include/linux/ftrace.h ftrace_set_early_filter(struct ftrace_ops *ops, char *buf, int enable); · line 576
Quoted 3 lines
include/linux/ftrace.h +0
-1/* defined in arch */ extern int ftrace_ip_converted (unsigned long ip); -extern int ftrace_dyn_arch_init (void );Why removing that ?
Have you tried to build
kernel/trace/ftrace.owith C=2 ? It will likely tell you that the function is not declared and that it should be static
Yes I missed this check. Under the situation, the function should be static.
Quoted 4 lines
We could eventually consider that in the past, this generic declaration was unrelevant because the definitions where in the arch specific sections. Now that you are implementing a generic weak version of this function, it would make sense to have a generic declaration as well.
I really don't see the point in duplicating the declaration of the function in the arch specific headers.
I use declaration in arch specific headers in tend to clarify the arch has implement ftrace_dyn_arch_init(). Anyway, it maybe pointless, a generic declaration is enough. Will update it later.
Quoted 6 lines
Quoted 3 lines
include/linux/ftrace.h +0
-0extern void ftrace_replace_code (int enable);extern int ftrace_update_ftrace_func (ftrace_func_t func);extern void
ftrace_caller(void);Christophe
CS Group - Document Interne