Skip to contentSkip to conversation

ftrace: avoid redundant initialization in register_ftrace_direct

PATCH In review Menglong Dong 3 participants 3 messages Nov 10, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ftrace: avoid redundant initialization in register_ftrace_direct

The FTRACE_OPS_FL_INITIALIZED flag is cleared in register_ftrace_direct, which can make it initialized by ftrace_ops_init() even if it is already initialized. It seems that there is no big deal here, but let's still fix it.

Fixes f64dd4627ec6 ("ftrace: Add multi direct register/unregister interface")
---
 kernel/trace/ftrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ftrace.c +1 -1
index 42bd2ba68a82..efb5ce32298f 100644
@@ -6043,7 +6043,7 @@ int register_ftrace_direct(struct ftrace_ops *ops, unsigned long addr)
 	new_hash = NULL;
 
 	ops->func = call_direct_funcs;
-	ops->flags = MULTI_FLAGS;
+	ops->flags |= MULTI_FLAGS;
 	ops->trampoline = FTRACE_REGS_ADDR;
 	ops->direct_call = addr;
 
Signature · 1 line
2.51.2
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Menglong Dong

The FTRACE_OPS_FL_INITIALIZED flag is cleared in register_ftrace_direct, which can make it initialized by ftrace_ops_init() even if it is already initialized. It seems that there is no big deal here, but let's still fix it.

good catch

jirka

Quoted 24 lines
Fixes f64dd4627ec6 ("ftrace: Add multi direct register/unregister interface")
---
 kernel/trace/ftrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ftrace.c +1 -1
index 42bd2ba68a82..efb5ce32298f 100644
@@ -6043,7 +6043,7 @@ int register_ftrace_direct(struct ftrace_ops *ops, unsigned long addr)
 	new_hash = NULL;
 
 	ops->func = call_direct_funcs;
-	ops->flags = MULTI_FLAGS;
+	ops->flags |= MULTI_FLAGS;
 	ops->trampoline = FTRACE_REGS_ADDR;
 	ops->direct_call = addr;
 
Signature · 1 line
2.51.2
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Menglong Dong
Quoted 7 lines · On Mon, 10 Nov 2025 20:18:08 +0800 Menglong Dong <[email protected]>…

The FTRACE_OPS_FL_INITIALIZED flag is cleared in register_ftrace_direct, which can make it initialized by ftrace_ops_init() even if it is already initialized. It seems that there is no big deal here, but let's still fix it.

Fixes f64dd4627ec6 ("ftrace: Add multi direct register/unregister interface")

Looks good to me.

Thanks,

Quoted 20 lines
---
 kernel/trace/ftrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ftrace.c +1 -1
index 42bd2ba68a82..efb5ce32298f 100644
@@ -6043,7 +6043,7 @@ int register_ftrace_direct(struct ftrace_ops *ops, unsigned long addr)
 	new_hash = NULL;
 
 	ops->func = call_direct_funcs;
-	ops->flags = MULTI_FLAGS;
+	ops->flags |= MULTI_FLAGS;
 	ops->trampoline = FTRACE_REGS_ADDR;
 	ops->direct_call = addr;
 
Signature · 1 line
2.51.2
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>