]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ftrace: Have funcgraph-args take affect during tracing
authorSteven Rostedt <rostedt@goodmis.org>
Thu, 27 Feb 2025 18:58:07 +0000 (13:58 -0500)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Tue, 4 Mar 2025 16:27:23 +0000 (11:27 -0500)
Currently, when function_graph is started, it looks at the option
funcgraph-args, and if it is set, it will enable tracing of the arguments.

But if tracing is already running, and the user enables funcgraph-args, it
will have no effect. Instead, it should enable argument tracing when it is
enabled, even if it means disabling the function graph tracing for a short
time in order to do the transition.

Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Guo Ren <guoren@kernel.org>
Cc: Donglin Peng <dolinux.peng@gmail.com>
Cc: Zheng Yejian <zhengyejian@huaweicloud.com>
Link: https://lore.kernel.org/20250227185822.978998710@goodmis.org
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/trace_functions_graph.c

index 5049fe25ceef75e0b4cfc8073169e160f8459336..71b2fb068b6bd935c0cceae64343e820751c6b17 100644 (file)
@@ -464,7 +464,7 @@ static int graph_trace_init(struct trace_array *tr)
        else
                tr->gops->retfunc = trace_graph_return;
 
-       /* Make gops functions are visible before we start tracing */
+       /* Make gops functions visible before we start tracing */
        smp_mb();
 
        ret = register_ftrace_graph(tr->gops);
@@ -475,6 +475,28 @@ static int graph_trace_init(struct trace_array *tr)
        return 0;
 }
 
+static int ftrace_graph_trace_args(struct trace_array *tr, int set)
+{
+       trace_func_graph_ent_t entry;
+
+       if (set)
+               entry = trace_graph_entry_args;
+       else
+               entry = trace_graph_entry;
+
+       /* See if there's any changes */
+       if (tr->gops->entryfunc == entry)
+               return 0;
+
+       unregister_ftrace_graph(tr->gops);
+
+       tr->gops->entryfunc = entry;
+
+       /* Make gops functions visible before we start tracing */
+       smp_mb();
+       return register_ftrace_graph(tr->gops);
+}
+
 static void graph_trace_reset(struct trace_array *tr)
 {
        tracing_stop_cmdline_record();
@@ -1607,6 +1629,9 @@ func_graph_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
        if (bit == TRACE_GRAPH_GRAPH_TIME)
                ftrace_graph_graph_time_control(set);
 
+       if (bit == TRACE_GRAPH_ARGS)
+               return ftrace_graph_trace_args(tr, set);
+
        return 0;
 }