ftrace: Minor fixes for sparse and kernel test robot
Steven Rostedt
maintainercover ftrace: Minor fixes for sparse and kernel test robot
Recieved some minor bug reports from the kernel test robot. First I started cleaning up some of the sparse warnings. There's many more, but most changes are not really helping anything, but just quieting the warnings.
But the reports from kernel test robot need to be fixed.
Steven Rostedt (Google) (6):
ftrace: Declare function_trace_op in header to quiet sparse warning
ftrace: Assign ftrace_list_end to ftrace_ops_list type cast to RCU
ftrace: Assign RCU list variable with rcu_assign_ptr()
ftrace: Fix prototypes for ftrace_startup/shutdown_subops()
function_graph: Make fgraph_do_direct static key static
function_graph: Do not update pid func if CONFIG_DYNAMIC_FTRACE not enabled
----
include/linux/ftrace.h | 3 +++ kernel/trace/fgraph.c | 4 +++- kernel/trace/ftrace.c | 4 ++-- kernel/trace/ftrace_internal.h | 9 +++++++++ kernel/trace/trace.h | 1 - 5 files changed, 17 insertions(+), 4 deletions(-)
Steven Rostedt
maintainerPATCH 1/6 ftrace: Declare function_trace_op in header to quiet sparse warning
From: "Steven Rostedt (Google)" <[email protected]>
Sparse complains that function_trace_op is not static but is not declared in a header file. It is used only in assembly code. But add it to a header so that sparse no longer complains:
kernel/trace/ftrace.c:99:19: warning: symbol 'function_trace_op' was not declared. Should it be static?
--- include/linux/ftrace.h | 3 +++ 1 file changed, 3 insertions(+)
include/linux/ftrace.h +3 -0
@@ -1131,6 +1131,9 @@ extern void ftrace_graph_init_task(struct task_struct *t);extern void ftrace_graph_exit_task (struct task_struct *t);extern void ftrace_graph_init_idle_task (struct task_struct *t,int cpu); +/* Used by assembly, but to quiet sparse warnings */ +extern struct ftrace_ops *function_trace_op; +static inline void pause_graph_tracing (void ) {atomic_inc (¤t->tracing_graph_pause);
Signature · 1 line
2.43.0
Steven Rostedt
maintainerPATCH 2/6 ftrace: Assign ftrace_list_end to ftrace_ops_list type cast to RCU
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
Use a type cast to convert ftrace_list_end to RCU when assigning ftrace_ops_list. This will quiet the sparse warning:
kernel/trace/ftrace.c:125:59: warning: incorrect type in initializer (different address spaces)
kernel/trace/ftrace.c:125:59: expected struct ftrace_ops [noderef] __rcu *[addressable] [toplevel] ftrace_ops_list
kernel/trace/ftrace.c:125:59: got struct ftrace_ops *
--- kernel/trace/ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ftrace.c +1 -1
@@ -122,7 +122,7 @@ static int ftrace_disabled __read_mostly;DEFINE_MUTEX (ftrace_lock); -struct ftrace_ops __rcu *ftrace_ops_list__read_mostly = &ftrace_list_end; +struct ftrace_ops __rcu *ftrace_ops_list__read_mostly = (struct ftrace_ops __rcu *)&ftrace_list_end;ftrace_func_t ftrace_trace_function__read_mostly = ftrace_stub;struct ftrace_ops global_ops;
Signature · 1 line
2.43.0
Steven Rostedt
maintainerPATCH 3/6 ftrace: Assign RCU list variable with rcu_assign_ptr()
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
Use rcu_assign_ptr() to assign the list pointer as it is marked as RCU, and this quiets the sparse warning:
kernel/trace/ftrace.c:313:23: warning: incorrect type in assignment (different address spaces)
kernel/trace/ftrace.c:313:23: expected struct ftrace_ops [noderef] __rcu *
kernel/trace/ftrace.c:313:23: got struct ftrace_ops *
--- kernel/trace/ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ftrace.c +1 -1
@@ -310,7 +310,7 @@ static int remove_ftrace_ops(struct ftrace_ops __rcu **list, lockdep_is_held(&ftrace_lock)) == ops && rcu_dereference_protected(ops->next, lockdep_is_held(&ftrace_lock)) == &ftrace_list_end) { - *list = &ftrace_list_end; +rcu_assign_pointer (*list, &ftrace_list_end);return 0 ; }
Signature · 1 line
2.43.0
Steven Rostedt
maintainerPATCH 4/6 ftrace: Fix prototypes for ftrace_startup/shutdown_subops()
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
The ftrace_startup_subops() was in the wrong header, and both functions were not defined on !CONFIG_DYNAMIC_FTRACE.
--- kernel/trace/ftrace_internal.h | 9 +++++++++ kernel/trace/trace.h | 1 - 2 files changed, 9 insertions(+), 1 deletion(-)
kernel/trace/ftrace_internal.h +9 -0
@@ -15,6 +15,7 @@ extern struct ftrace_ops global_ops;int ftrace_startup (struct ftrace_ops *ops,int command);int ftrace_shutdown (struct ftrace_ops *ops,int command);int ftrace_ops_test (struct ftrace_ops *ops,unsigned long ip,void *regs); +int ftrace_startup_subops (struct ftrace_ops *ops,struct ftrace_ops *subops,int command);int ftrace_shutdown_subops (struct ftrace_ops *ops,struct ftrace_ops *subops,int command);#else /* !CONFIG_DYNAMIC_FTRACE */
@@ -39,6 +40,14 @@ ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip, void *regs) {return 1 ; } +static inline int ftrace_startup_subops (struct ftrace_ops *ops,struct ftrace_ops *subops,int command) +{ +return -EINVAL ; +} +static inline int ftrace_shutdown_subops (struct ftrace_ops *ops,struct ftrace_ops *subops,int command) +{ +return -EINVAL ; +}#endif /* CONFIG_DYNAMIC_FTRACE */ #ifdef CONFIG_FUNCTION_GRAPH_TRACER
kernel/trace/trace.h +0 -1
@@ -1186,7 +1186,6 @@ extern int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf, int len, int reset);extern int ftrace_set_notrace (struct ftrace_ops *ops,unsigned char *buf,int len,int reset); -extern int ftrace_startup_subops (struct ftrace_ops *ops,struct ftrace_ops *subops,int command);#else struct ftrace_func_command ;
Signature · 1 line
2.43.0
Steven Rostedt
maintainerPATCH 5/6 function_graph: Make fgraph_do_direct static key static
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
The static branch key "fgraph_do_direct" was not declared static but is only used in one file. Change it to a static variable.
--- kernel/trace/fgraph.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/fgraph.c +1 -1
@@ -515,7 +515,7 @@ static struct fgraph_ops fgraph_stub = {static struct fgraph_ops *fgraph_direct_gops = &fgraph_stub;DEFINE_STATIC_CALL (fgraph_func, ftrace_graph_entry_stub);DEFINE_STATIC_CALL (fgraph_retfunc, ftrace_graph_ret_stub); -DEFINE_STATIC_KEY_TRUE (fgraph_do_direct); +static DEFINE_STATIC_KEY_TRUE (fgraph_do_direct);/** * ftrace_graph_stop - set to permanently disable function graph tracing
Signature · 1 line
2.43.0
Steven Rostedt
maintainerPATCH 6/6 function_graph: Do not update pid func if CONFIG_DYNAMIC_FTRACE not enabled
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
The ftrace subops is only defined if CONFIG_DYNAMIC_FTRACE is enabled. If it is not, function tracing is extremely limited, and the subops in the ftrace_ops structure is not defined (and will fail to compile). If DYNAMIC_FTRACE is not enabled, then function graph filtering will not work (as it shouldn't).
--- kernel/trace/fgraph.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/trace/fgraph.c +2 -0
@@ -1177,6 +1177,7 @@ void fgraph_update_pid_func(void)if (!(graph_ops.flags &FTRACE_OPS_FL_INITIALIZED ))return ; +#ifdef CONFIG_DYNAMIC_FTRACE list_for_each_entry (op, &graph_ops.subop_list, list) {if (op->flags &FTRACE_OPS_FL_PID ) { gops = container_of(op, struct fgraph_ops, ops);
@@ -1186,6 +1187,7 @@ void fgraph_update_pid_func(void) static_call_update(fgraph_func, gops->entryfunc); } } +#endif }/* Allocate a return stack for each task */
Signature · 1 line
2.43.0
Quoted 6 lines · On Wed, 05 Jun 2024 16:26:44 -0400 Steven Rostedt <[email protected]> wrote:
Recieved some minor bug reports from the kernel test robot. First I started cleaning up some of the sparse warnings. There's many more, but most changes are not really helping anything, but just quieting the warnings.
But the reports from kernel test robot need to be fixed.
All looks good to me.
Thank you!
Quoted 16 lines
Steven Rostedt (Google) (6):
ftrace: Declarefunction_trace_opin header to quiet sparse warning
ftrace: Assignftrace_list_endtoftrace_ops_listtype cast to RCU
ftrace: Assign RCU list variable withrcu_assign_ptr()
ftrace: Fix prototypes for ftrace_startup/shutdown_subops()
function_graph: Makefgraph_do_directstatic key static
function_graph: Do not update pid func ifCONFIG_DYNAMIC_FTRACEnot enabled----
include/linux/ftrace.h | 3 +++ kernel/trace/fgraph.c | 4 +++- kernel/trace/ftrace.c | 4 ++-- kernel/trace/ftrace_internal.h | 9 +++++++++ kernel/trace/trace.h | 1 - 5 files changed, 17 insertions(+), 4 deletions(-)
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>