]> Gentwo Git Trees - linux/.git/commitdiff
tracing: Move graph-time out of function graph options
authorSteven Rostedt <rostedt@goodmis.org>
Fri, 14 Nov 2025 19:22:31 +0000 (14:22 -0500)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Fri, 14 Nov 2025 19:30:55 +0000 (14:30 -0500)
The option "graph-time" affects the function profiler when it is using the
function graph infrastructure. It has nothing to do with the function
graph tracer itself. The option only affects the global function profiler
and does nothing to the function graph tracer.

Move it out of the function graph tracer options and make it a global
option that is only available at the top level instance.

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: https://patch.msgid.link/20251114192318.781711154@kernel.org
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/trace.c
kernel/trace/trace.h
kernel/trace/trace_functions_graph.c

index 9268489d2ce8e83ebf66e43c4308d001089b5cb0..8ae95800592d64ffc69dbf1fe42c7fb35b83ad8a 100644 (file)
@@ -509,10 +509,10 @@ EXPORT_SYMBOL_GPL(unregister_ftrace_export);
 
 /* trace_flags holds trace_options default values */
 #define TRACE_DEFAULT_FLAGS                                            \
-       (FUNCTION_DEFAULT_FLAGS |                                       \
-        TRACE_ITER(PRINT_PARENT) | TRACE_ITER(PRINTK) |                        \
+       (FUNCTION_DEFAULT_FLAGS | FPROFILE_DEFAULT_FLAGS |              \
+        TRACE_ITER(PRINT_PARENT) | TRACE_ITER(PRINTK) |                \
         TRACE_ITER(ANNOTATE) | TRACE_ITER(CONTEXT_INFO) |              \
-        TRACE_ITER(RECORD_CMD) | TRACE_ITER(OVERWRITE) |                       \
+        TRACE_ITER(RECORD_CMD) | TRACE_ITER(OVERWRITE) |               \
         TRACE_ITER(IRQ_INFO) | TRACE_ITER(MARKERS) |                   \
         TRACE_ITER(HASH_PTR) | TRACE_ITER(TRACE_PRINTK) |              \
         TRACE_ITER(COPY_MARKER))
@@ -520,7 +520,7 @@ EXPORT_SYMBOL_GPL(unregister_ftrace_export);
 /* trace_options that are only supported by global_trace */
 #define TOP_LEVEL_TRACE_FLAGS (TRACE_ITER(PRINTK) |                    \
               TRACE_ITER(PRINTK_MSGONLY) | TRACE_ITER(RECORD_CMD) |    \
-              TRACE_ITER(PROF_TEXT_OFFSET))
+              TRACE_ITER(PROF_TEXT_OFFSET) | FPROFILE_DEFAULT_FLAGS)
 
 /* trace_flags that are default zero for instances */
 #define ZEROED_TRACE_FLAGS \
@@ -5331,6 +5331,12 @@ int set_tracer_flag(struct trace_array *tr, u64 mask, int enabled)
                trace_printk_start_stop_comm(enabled);
                trace_printk_control(enabled);
                break;
+
+#if defined(CONFIG_FUNCTION_PROFILER) && defined(CONFIG_FUNCTION_GRAPH_TRACER)
+       case TRACE_GRAPH_GRAPH_TIME:
+               ftrace_graph_graph_time_control(enabled);
+               break;
+#endif
        }
 
        return 0;
index 299862aad66cc575c10e72a225da611fd7c2cbac..41b416a22450288ee3aa9874ef4f56c43fcacfe9 100644 (file)
@@ -1368,8 +1368,18 @@ extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
 #ifdef CONFIG_FUNCTION_PROFILER
 # define PROFILER_FLAGS                                        \
                C(PROF_TEXT_OFFSET,     "prof-text-offset"),
+# ifdef CONFIG_FUNCTION_GRAPH_TRACER
+#  define FPROFILE_FLAGS                               \
+               C(GRAPH_TIME,           "graph-time"),
+#  define FPROFILE_DEFAULT_FLAGS       TRACE_ITER(GRAPH_TIME)
+# else
+#  define FPROFILE_FLAGS
+#  define FPROFILE_DEFAULT_FLAGS       0UL
+# endif
 #else
 # define PROFILER_FLAGS
+# define FPROFILE_FLAGS
+# define FPROFILE_DEFAULT_FLAGS                        0UL
 # define TRACE_ITER_PROF_TEXT_OFFSET_BIT       -1
 #endif
 
@@ -1412,7 +1422,8 @@ extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
                FGRAPH_FLAGS                                    \
                STACK_FLAGS                                     \
                BRANCH_FLAGS                                    \
-               PROFILER_FLAGS
+               PROFILER_FLAGS                                  \
+               FPROFILE_FLAGS
 
 /*
  * By defining C, we can make TRACE_FLAGS a list of bit names
index 3f55b49cf64e7bd5fd5162efe70bf7f400d79265..53adbe4bfedb37d80b1ed5a677e9f1090b45effe 100644 (file)
@@ -85,11 +85,6 @@ static struct tracer_opt trace_opts[] = {
        /* Include sleep time (scheduled out) between entry and return */
        { TRACER_OPT(sleep-time, TRACE_GRAPH_SLEEP_TIME) },
 
-#ifdef CONFIG_FUNCTION_PROFILER
-       /* Include time within nested functions */
-       { TRACER_OPT(graph-time, TRACE_GRAPH_GRAPH_TIME) },
-#endif
-
        { } /* Empty entry */
 };
 
@@ -97,7 +92,7 @@ static struct tracer_flags tracer_flags = {
        /* Don't display overruns, proc, or tail by default */
        .val = TRACE_GRAPH_PRINT_CPU | TRACE_GRAPH_PRINT_OVERHEAD |
               TRACE_GRAPH_PRINT_DURATION | TRACE_GRAPH_PRINT_IRQS |
-              TRACE_GRAPH_SLEEP_TIME | TRACE_GRAPH_GRAPH_TIME,
+              TRACE_GRAPH_SLEEP_TIME,
        .opts = trace_opts
 };
 
@@ -1627,9 +1622,6 @@ func_graph_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
        if (bit == TRACE_GRAPH_SLEEP_TIME)
                ftrace_graph_sleep_time_control(set);
 
-       if (bit == TRACE_GRAPH_GRAPH_TIME)
-               ftrace_graph_graph_time_control(set);
-
        /* Do nothing if the current tracer is not this tracer */
        if (tr->current_trace != &graph_trace)
                return 0;