Skip to content

Commit 0390558

Browse files
committed
tracing: Move "display-graph" option to main options
In order to facilitate making all tracer options visible even when the tracer is not active, we need to get rid of duplicate options. Any option that is shared between multiple tracers really should be a main option. As the wakeup and irqsoff tracers both use the "display-graph" option, and use it exactly the same way, move that option from the tracer options to the main options and consolidate them. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent ef92480 commit 0390558

4 files changed

Lines changed: 30 additions & 64 deletions

File tree

‎kernel/trace/trace.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ static const char *trace_options[] = {
882882
"irq-info",
883883
"markers",
884884
"function-trace",
885+
"display-graph",
885886
NULL
886887
};
887888

‎kernel/trace/trace.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ enum trace_iterator_flags {
913913
TRACE_ITER_IRQ_INFO = 0x800000,
914914
TRACE_ITER_MARKERS = 0x1000000,
915915
TRACE_ITER_FUNCTION = 0x2000000,
916+
TRACE_ITER_DISPLAY_GRAPH = 0x4000000,
916917
};
917918

918919
/*

‎kernel/trace/trace_irqsoff.c‎

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,16 @@ irq_trace(void)
5757
# define irq_trace() (0)
5858
#endif
5959

60-
#define TRACE_DISPLAY_GRAPH 1
60+
#define is_graph() (trace_flags & TRACE_ITER_DISPLAY_GRAPH)
6161

62-
static struct tracer_opt trace_opts[] = {
6362
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
64-
/* display latency trace as call graph */
65-
{ TRACER_OPT(display-graph, TRACE_DISPLAY_GRAPH) },
63+
static int irqsoff_display_graph(struct trace_array *tr, int set);
64+
#else
65+
static inline int irqsoff_display_graph(struct trace_array *tr, int set)
66+
{
67+
return -EINVAL;
68+
}
6669
#endif
67-
{ } /* Empty entry */
68-
};
69-
70-
static struct tracer_flags tracer_flags = {
71-
.val = 0,
72-
.opts = trace_opts,
73-
};
74-
75-
#define is_graph() (tracer_flags.val & TRACE_DISPLAY_GRAPH)
7670

7771
/*
7872
* Sequence count - we record it when starting a measurement and
@@ -152,14 +146,10 @@ irqsoff_tracer_call(unsigned long ip, unsigned long parent_ip,
152146
#endif /* CONFIG_FUNCTION_TRACER */
153147

154148
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
155-
static int
156-
irqsoff_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
149+
static int irqsoff_display_graph(struct trace_array *tr, int set)
157150
{
158151
int cpu;
159152

160-
if (!(bit & TRACE_DISPLAY_GRAPH))
161-
return -EINVAL;
162-
163153
if (!(is_graph() ^ set))
164154
return 0;
165155

@@ -259,12 +249,6 @@ __trace_function(struct trace_array *tr,
259249
#else
260250
#define __trace_function trace_function
261251

262-
static int
263-
irqsoff_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
264-
{
265-
return -EINVAL;
266-
}
267-
268252
static int irqsoff_graph_entry(struct ftrace_graph_ent *trace)
269253
{
270254
return -1;
@@ -556,20 +540,24 @@ static void unregister_irqsoff_function(struct trace_array *tr, int graph)
556540
function_enabled = false;
557541
}
558542

559-
static void irqsoff_function_set(struct trace_array *tr, int set)
543+
static int irqsoff_function_set(struct trace_array *tr, int set)
560544
{
561545
if (set)
562546
register_irqsoff_function(tr, is_graph(), 1);
563547
else
564548
unregister_irqsoff_function(tr, is_graph());
549+
return 0;
565550
}
566551

567552
static int irqsoff_flag_changed(struct trace_array *tr, u32 mask, int set)
568553
{
569554
struct tracer *tracer = tr->current_trace;
570555

571556
if (mask & TRACE_ITER_FUNCTION)
572-
irqsoff_function_set(tr, set);
557+
return irqsoff_function_set(tr, set);
558+
559+
if (mask & TRACE_ITER_DISPLAY_GRAPH)
560+
return irqsoff_display_graph(tr, set);
573561

574562
return trace_keep_overwrite(tracer, mask, set);
575563
}
@@ -666,8 +654,6 @@ static struct tracer irqsoff_tracer __read_mostly =
666654
.print_max = true,
667655
.print_header = irqsoff_print_header,
668656
.print_line = irqsoff_print_line,
669-
.flags = &tracer_flags,
670-
.set_flag = irqsoff_set_flag,
671657
.flag_changed = irqsoff_flag_changed,
672658
#ifdef CONFIG_FTRACE_SELFTEST
673659
.selftest = trace_selftest_startup_irqsoff,
@@ -700,8 +686,6 @@ static struct tracer preemptoff_tracer __read_mostly =
700686
.print_max = true,
701687
.print_header = irqsoff_print_header,
702688
.print_line = irqsoff_print_line,
703-
.flags = &tracer_flags,
704-
.set_flag = irqsoff_set_flag,
705689
.flag_changed = irqsoff_flag_changed,
706690
#ifdef CONFIG_FTRACE_SELFTEST
707691
.selftest = trace_selftest_startup_preemptoff,
@@ -736,8 +720,6 @@ static struct tracer preemptirqsoff_tracer __read_mostly =
736720
.print_max = true,
737721
.print_header = irqsoff_print_header,
738722
.print_line = irqsoff_print_line,
739-
.flags = &tracer_flags,
740-
.set_flag = irqsoff_set_flag,
741723
.flag_changed = irqsoff_flag_changed,
742724
#ifdef CONFIG_FTRACE_SELFTEST
743725
.selftest = trace_selftest_startup_preemptirqsoff,

‎kernel/trace/trace_sched_wakeup.c‎

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

43-
#define TRACE_DISPLAY_GRAPH 1
43+
#define is_graph() (trace_flags & TRACE_ITER_DISPLAY_GRAPH)
4444

45-
static struct tracer_opt trace_opts[] = {
4645
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
47-
/* display latency trace as call graph */
48-
{ TRACER_OPT(display-graph, TRACE_DISPLAY_GRAPH) },
46+
static int wakeup_display_graph(struct trace_array *tr, int set);
47+
#else
48+
static inline int wakeup_display_graph(struct trace_array *tr, int set)
49+
{
50+
return -EINVAL;
51+
}
4952
#endif
50-
{ } /* Empty entry */
51-
};
5253

53-
static struct tracer_flags tracer_flags = {
54-
.val = 0,
55-
.opts = trace_opts,
56-
};
57-
58-
#define is_graph() (tracer_flags.val & TRACE_DISPLAY_GRAPH)
5954

6055
#ifdef CONFIG_FUNCTION_TRACER
6156

@@ -163,20 +158,24 @@ static void unregister_wakeup_function(struct trace_array *tr, int graph)
163158
function_enabled = false;
164159
}
165160

166-
static void wakeup_function_set(struct trace_array *tr, int set)
161+
static int wakeup_function_set(struct trace_array *tr, int set)
167162
{
168163
if (set)
169164
register_wakeup_function(tr, is_graph(), 1);
170165
else
171166
unregister_wakeup_function(tr, is_graph());
167+
return 0;
172168
}
173169

174170
static int wakeup_flag_changed(struct trace_array *tr, u32 mask, int set)
175171
{
176172
struct tracer *tracer = tr->current_trace;
177173

178174
if (mask & TRACE_ITER_FUNCTION)
179-
wakeup_function_set(tr, set);
175+
return wakeup_function_set(tr, set);
176+
177+
if (mask & TRACE_ITER_DISPLAY_GRAPH)
178+
return wakeup_display_graph(tr, set);
180179

181180
return trace_keep_overwrite(tracer, mask, set);
182181
}
@@ -203,13 +202,8 @@ static void stop_func_tracer(struct trace_array *tr, int graph)
203202
}
204203

205204
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
206-
static int
207-
wakeup_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
205+
static int wakeup_display_graph(struct trace_array *tr, int set)
208206
{
209-
210-
if (!(bit & TRACE_DISPLAY_GRAPH))
211-
return -EINVAL;
212-
213207
if (!(is_graph() ^ set))
214208
return 0;
215209

@@ -306,12 +300,6 @@ __trace_function(struct trace_array *tr,
306300
#else
307301
#define __trace_function trace_function
308302

309-
static int
310-
wakeup_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
311-
{
312-
return -EINVAL;
313-
}
314-
315303
static int wakeup_graph_entry(struct ftrace_graph_ent *trace)
316304
{
317305
return -1;
@@ -740,8 +728,6 @@ static struct tracer wakeup_tracer __read_mostly =
740728
.print_max = true,
741729
.print_header = wakeup_print_header,
742730
.print_line = wakeup_print_line,
743-
.flags = &tracer_flags,
744-
.set_flag = wakeup_set_flag,
745731
.flag_changed = wakeup_flag_changed,
746732
#ifdef CONFIG_FTRACE_SELFTEST
747733
.selftest = trace_selftest_startup_wakeup,
@@ -762,8 +748,6 @@ static struct tracer wakeup_rt_tracer __read_mostly =
762748
.print_max = true,
763749
.print_header = wakeup_print_header,
764750
.print_line = wakeup_print_line,
765-
.flags = &tracer_flags,
766-
.set_flag = wakeup_set_flag,
767751
.flag_changed = wakeup_flag_changed,
768752
#ifdef CONFIG_FTRACE_SELFTEST
769753
.selftest = trace_selftest_startup_wakeup,
@@ -784,8 +768,6 @@ static struct tracer wakeup_dl_tracer __read_mostly =
784768
.print_max = true,
785769
.print_header = wakeup_print_header,
786770
.print_line = wakeup_print_line,
787-
.flags = &tracer_flags,
788-
.set_flag = wakeup_set_flag,
789771
.flag_changed = wakeup_flag_changed,
790772
#ifdef CONFIG_FTRACE_SELFTEST
791773
.selftest = trace_selftest_startup_wakeup,

0 commit comments

Comments
 (0)