Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

function_graph: Make fgraph_update_pid_func() a stub for !DYNAMIC_FTRACE

When CONFIG_DYNAMIC_FTRACE is not set, the function
fgraph_update_pid_func() doesn't do anything. Currently, most of its logic
is within a "#ifdef CONFIG_DYNAMIC_FTRACE" block, but its variables were
declared outside that, and when DYNAMIC_FTRACE is not set, it produces
unused variable warnings.

Instead, just place it (and the helper function fgraph_pid_func()) within
the #ifdef block and have the header file use a empty stub function for
when DYNAMIC_FTRACE is not defined.

Link: https://lore.kernel.org/linux-trace-kernel/20240607094833.6a787d73@rorschach.local.home

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202406071806.BRjaC5FF-lkp@intel.com/
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+6 -2
+2 -2
kernel/trace/fgraph.c
··· 1138 1138 kfree(ret_stack); 1139 1139 } 1140 1140 1141 + #ifdef CONFIG_DYNAMIC_FTRACE 1141 1142 static int fgraph_pid_func(struct ftrace_graph_ent *trace, 1142 1143 struct fgraph_ops *gops) 1143 1144 { ··· 1165 1164 if (!(graph_ops.flags & FTRACE_OPS_FL_INITIALIZED)) 1166 1165 return; 1167 1166 1168 - #ifdef CONFIG_DYNAMIC_FTRACE 1169 1167 list_for_each_entry(op, &graph_ops.subop_list, list) { 1170 1168 if (op->flags & FTRACE_OPS_FL_PID) { 1171 1169 gops = container_of(op, struct fgraph_ops, ops); ··· 1174 1174 static_call_update(fgraph_func, gops->entryfunc); 1175 1175 } 1176 1176 } 1177 - #endif 1178 1177 } 1178 + #endif 1179 1179 1180 1180 /* Allocate a return stack for each task */ 1181 1181 static int start_graph_tracing(void)
+4
kernel/trace/ftrace_internal.h
··· 52 52 53 53 #ifdef CONFIG_FUNCTION_GRAPH_TRACER 54 54 extern int ftrace_graph_active; 55 + # ifdef CONFIG_DYNAMIC_FTRACE 55 56 extern void fgraph_update_pid_func(void); 57 + # else 58 + static inline void fgraph_update_pid_func(void) {} 59 + # endif 56 60 #else /* !CONFIG_FUNCTION_GRAPH_TRACER */ 57 61 # define ftrace_graph_active 0 58 62 static inline void fgraph_update_pid_func(void) {}