Skip to content

Commit 729358d

Browse files
committed
tracing: Only create function graph options when it is compiled in
Do not create fuction graph tracer options when function graph tracer is not even compiled in. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent a3418a3 commit 729358d

4 files changed

Lines changed: 32 additions & 11 deletions

File tree

‎kernel/trace/trace.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,13 @@ static inline void ftrace_trace_stack(struct ring_buffer *buffer,
489489
#endif
490490

491491
/* trace_flags holds trace_options default values */
492-
unsigned long trace_flags = TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK |
493-
TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO | TRACE_ITER_SLEEP_TIME |
494-
TRACE_ITER_GRAPH_TIME | TRACE_ITER_RECORD_CMD | TRACE_ITER_OVERWRITE |
495-
TRACE_ITER_IRQ_INFO | TRACE_ITER_MARKERS | TRACE_ITER_FUNCTION;
492+
unsigned long trace_flags =
493+
FUNCTION_GRAPH_DEFAULT_FLAGS |
494+
TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK |
495+
TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO |
496+
TRACE_ITER_RECORD_CMD | TRACE_ITER_OVERWRITE |
497+
TRACE_ITER_IRQ_INFO | TRACE_ITER_MARKERS | TRACE_ITER_FUNCTION
498+
;
496499

497500
static void tracer_tracing_on(struct trace_array *tr)
498501
{

‎kernel/trace/trace.h‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,22 @@ extern void trace_parser_put(struct trace_parser *parser);
879879
extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
880880
size_t cnt, loff_t *ppos);
881881

882+
/*
883+
* Only create function graph options if function graph is configured.
884+
*/
885+
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
886+
# define FGRAPH_FLAGS \
887+
C(SLEEP_TIME, "sleep-time"), \
888+
C(GRAPH_TIME, "graph-time"), \
889+
C(DISPLAY_GRAPH, "display-graph"),
890+
/* Initially set for trace_flags */
891+
# define FUNCTION_GRAPH_DEFAULT_FLAGS \
892+
(TRACE_ITER_SLEEP_TIME | TRACE_ITER_GRAPH_TIME)
893+
#else
894+
# define FGRAPH_FLAGS
895+
# define FUNCTION_GRAPH_DEFAULT_FLAGS 0UL
896+
#endif
897+
882898
/*
883899
* trace_iterator_flags is an enumeration that defines bit
884900
* positions into trace_flags that controls the output.
@@ -904,15 +920,13 @@ extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
904920
C(PRINTK_MSGONLY, "printk-msg-only"), \
905921
C(CONTEXT_INFO, "context-info"), /* Print pid/cpu/time */ \
906922
C(LATENCY_FMT, "latency-format"), \
907-
C(SLEEP_TIME, "sleep-time"), \
908-
C(GRAPH_TIME, "graph-time"), \
909923
C(RECORD_CMD, "record-cmd"), \
910924
C(OVERWRITE, "overwrite"), \
911925
C(STOP_ON_FREE, "disable_on_free"), \
912926
C(IRQ_INFO, "irq-info"), \
913927
C(MARKERS, "markers"), \
914928
C(FUNCTION, "function-trace"), \
915-
C(DISPLAY_GRAPH, "display-graph"),
929+
FGRAPH_FLAGS
916930

917931
/*
918932
* By defining C, we can make TRACE_FLAGS a list of bit names

‎kernel/trace/trace_irqsoff.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ irq_trace(void)
5757
# define irq_trace() (0)
5858
#endif
5959

60-
#define is_graph() (trace_flags & TRACE_ITER_DISPLAY_GRAPH)
61-
6260
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
6361
static int irqsoff_display_graph(struct trace_array *tr, int set);
62+
# define is_graph() (trace_flags & TRACE_ITER_DISPLAY_GRAPH)
6463
#else
6564
static inline int irqsoff_display_graph(struct trace_array *tr, int set)
6665
{
6766
return -EINVAL;
6867
}
68+
# define is_graph() false
6969
#endif
7070

7171
/*
@@ -556,8 +556,10 @@ static int irqsoff_flag_changed(struct trace_array *tr, u32 mask, int set)
556556
if (mask & TRACE_ITER_FUNCTION)
557557
return irqsoff_function_set(tr, set);
558558

559+
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
559560
if (mask & TRACE_ITER_DISPLAY_GRAPH)
560561
return irqsoff_display_graph(tr, set);
562+
#endif
561563

562564
return trace_keep_overwrite(tracer, mask, set);
563565
}

‎kernel/trace/trace_sched_wakeup.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ static void wakeup_graph_return(struct ftrace_graph_ret *trace);
4040
static int save_flags;
4141
static bool function_enabled;
4242

43-
#define is_graph() (trace_flags & TRACE_ITER_DISPLAY_GRAPH)
44-
4543
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
4644
static int wakeup_display_graph(struct trace_array *tr, int set);
45+
# define is_graph() (trace_flags & TRACE_ITER_DISPLAY_GRAPH)
4746
#else
4847
static inline int wakeup_display_graph(struct trace_array *tr, int set)
4948
{
5049
return -EINVAL;
5150
}
51+
# define is_graph() false
5252
#endif
5353

5454

@@ -174,8 +174,10 @@ static int wakeup_flag_changed(struct trace_array *tr, u32 mask, int set)
174174
if (mask & TRACE_ITER_FUNCTION)
175175
return wakeup_function_set(tr, set);
176176

177+
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
177178
if (mask & TRACE_ITER_DISPLAY_GRAPH)
178179
return wakeup_display_graph(tr, set);
180+
#endif
179181

180182
return trace_keep_overwrite(tracer, mask, set);
181183
}

0 commit comments

Comments
 (0)