Skip to content

Commit 4132886

Browse files
committed
tracing: Move graph-time out of function graph options
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>
1 parent 6479325 commit 4132886

3 files changed

Lines changed: 23 additions & 14 deletions

File tree

kernel/trace/trace.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,18 +509,18 @@ EXPORT_SYMBOL_GPL(unregister_ftrace_export);
509509

510510
/* trace_flags holds trace_options default values */
511511
#define TRACE_DEFAULT_FLAGS \
512-
(FUNCTION_DEFAULT_FLAGS | \
513-
TRACE_ITER(PRINT_PARENT) | TRACE_ITER(PRINTK) | \
512+
(FUNCTION_DEFAULT_FLAGS | FPROFILE_DEFAULT_FLAGS | \
513+
TRACE_ITER(PRINT_PARENT) | TRACE_ITER(PRINTK) | \
514514
TRACE_ITER(ANNOTATE) | TRACE_ITER(CONTEXT_INFO) | \
515-
TRACE_ITER(RECORD_CMD) | TRACE_ITER(OVERWRITE) | \
515+
TRACE_ITER(RECORD_CMD) | TRACE_ITER(OVERWRITE) | \
516516
TRACE_ITER(IRQ_INFO) | TRACE_ITER(MARKERS) | \
517517
TRACE_ITER(HASH_PTR) | TRACE_ITER(TRACE_PRINTK) | \
518518
TRACE_ITER(COPY_MARKER))
519519

520520
/* trace_options that are only supported by global_trace */
521521
#define TOP_LEVEL_TRACE_FLAGS (TRACE_ITER(PRINTK) | \
522522
TRACE_ITER(PRINTK_MSGONLY) | TRACE_ITER(RECORD_CMD) | \
523-
TRACE_ITER(PROF_TEXT_OFFSET))
523+
TRACE_ITER(PROF_TEXT_OFFSET) | FPROFILE_DEFAULT_FLAGS)
524524

525525
/* trace_flags that are default zero for instances */
526526
#define ZEROED_TRACE_FLAGS \
@@ -5331,6 +5331,12 @@ int set_tracer_flag(struct trace_array *tr, u64 mask, int enabled)
53315331
trace_printk_start_stop_comm(enabled);
53325332
trace_printk_control(enabled);
53335333
break;
5334+
5335+
#if defined(CONFIG_FUNCTION_PROFILER) && defined(CONFIG_FUNCTION_GRAPH_TRACER)
5336+
case TRACE_GRAPH_GRAPH_TIME:
5337+
ftrace_graph_graph_time_control(enabled);
5338+
break;
5339+
#endif
53345340
}
53355341

53365342
return 0;

kernel/trace/trace.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1368,8 +1368,18 @@ extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
13681368
#ifdef CONFIG_FUNCTION_PROFILER
13691369
# define PROFILER_FLAGS \
13701370
C(PROF_TEXT_OFFSET, "prof-text-offset"),
1371+
# ifdef CONFIG_FUNCTION_GRAPH_TRACER
1372+
# define FPROFILE_FLAGS \
1373+
C(GRAPH_TIME, "graph-time"),
1374+
# define FPROFILE_DEFAULT_FLAGS TRACE_ITER(GRAPH_TIME)
1375+
# else
1376+
# define FPROFILE_FLAGS
1377+
# define FPROFILE_DEFAULT_FLAGS 0UL
1378+
# endif
13711379
#else
13721380
# define PROFILER_FLAGS
1381+
# define FPROFILE_FLAGS
1382+
# define FPROFILE_DEFAULT_FLAGS 0UL
13731383
# define TRACE_ITER_PROF_TEXT_OFFSET_BIT -1
13741384
#endif
13751385

@@ -1412,7 +1422,8 @@ extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
14121422
FGRAPH_FLAGS \
14131423
STACK_FLAGS \
14141424
BRANCH_FLAGS \
1415-
PROFILER_FLAGS
1425+
PROFILER_FLAGS \
1426+
FPROFILE_FLAGS
14161427

14171428
/*
14181429
* By defining C, we can make TRACE_FLAGS a list of bit names

kernel/trace/trace_functions_graph.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,14 @@ static struct tracer_opt trace_opts[] = {
8585
/* Include sleep time (scheduled out) between entry and return */
8686
{ TRACER_OPT(sleep-time, TRACE_GRAPH_SLEEP_TIME) },
8787

88-
#ifdef CONFIG_FUNCTION_PROFILER
89-
/* Include time within nested functions */
90-
{ TRACER_OPT(graph-time, TRACE_GRAPH_GRAPH_TIME) },
91-
#endif
92-
9388
{ } /* Empty entry */
9489
};
9590

9691
static struct tracer_flags tracer_flags = {
9792
/* Don't display overruns, proc, or tail by default */
9893
.val = TRACE_GRAPH_PRINT_CPU | TRACE_GRAPH_PRINT_OVERHEAD |
9994
TRACE_GRAPH_PRINT_DURATION | TRACE_GRAPH_PRINT_IRQS |
100-
TRACE_GRAPH_SLEEP_TIME | TRACE_GRAPH_GRAPH_TIME,
95+
TRACE_GRAPH_SLEEP_TIME,
10196
.opts = trace_opts
10297
};
10398

@@ -1627,9 +1622,6 @@ func_graph_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
16271622
if (bit == TRACE_GRAPH_SLEEP_TIME)
16281623
ftrace_graph_sleep_time_control(set);
16291624

1630-
if (bit == TRACE_GRAPH_GRAPH_TIME)
1631-
ftrace_graph_graph_time_control(set);
1632-
16331625
/* Do nothing if the current tracer is not this tracer */
16341626
if (tr->current_trace != &graph_trace)
16351627
return 0;

0 commit comments

Comments
 (0)