tracing: Move "display-graph" option to main options
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>
Mon, 28 Sep 2015 19:37:49 +0000 (15:37 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Tue, 29 Sep 2015 16:56:40 +0000 (12:56 -0400)
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>
kernel/trace/trace.c
kernel/trace/trace.h
kernel/trace/trace_irqsoff.c
kernel/trace/trace_sched_wakeup.c

index 5d3ce29..9a4ef5a 100644 (file)
@@ -882,6 +882,7 @@ static const char *trace_options[] = {
        "irq-info",
        "markers",
        "function-trace",
+       "display-graph",
        NULL
 };
 
index 107cf08..dfa3cd2 100644 (file)
@@ -913,6 +913,7 @@ enum trace_iterator_flags {
        TRACE_ITER_IRQ_INFO             = 0x800000,
        TRACE_ITER_MARKERS              = 0x1000000,
        TRACE_ITER_FUNCTION             = 0x2000000,
+       TRACE_ITER_DISPLAY_GRAPH        = 0x4000000,
 };
 
 /*
index 8523ea3..446480a 100644 (file)
@@ -57,22 +57,16 @@ irq_trace(void)
 # define irq_trace() (0)
 #endif
 
-#define TRACE_DISPLAY_GRAPH    1
+#define is_graph() (trace_flags & TRACE_ITER_DISPLAY_GRAPH)
 
-static struct tracer_opt trace_opts[] = {
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-       /* display latency trace as call graph */
-       { TRACER_OPT(display-graph, TRACE_DISPLAY_GRAPH) },
+static int irqsoff_display_graph(struct trace_array *tr, int set);
+#else
+static inline int irqsoff_display_graph(struct trace_array *tr, int set)
+{
+       return -EINVAL;
+}
 #endif
-       { } /* Empty entry */
-};
-
-static struct tracer_flags tracer_flags = {
-       .val  = 0,
-       .opts = trace_opts,
-};
-
-#define is_graph() (tracer_flags.val & TRACE_DISPLAY_GRAPH)
 
 /*
  * Sequence count - we record it when starting a measurement and
@@ -152,14 +146,10 @@ irqsoff_tracer_call(unsigned long ip, unsigned long parent_ip,
 #endif /* CONFIG_FUNCTION_TRACER */
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-static int
-irqsoff_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
+static int irqsoff_display_graph(struct trace_array *tr, int set)
 {
        int cpu;
 
-       if (!(bit & TRACE_DISPLAY_GRAPH))
-               return -EINVAL;
-
        if (!(is_graph() ^ set))
                return 0;
 
@@ -259,12 +249,6 @@ __trace_function(struct trace_array *tr,
 #else
 #define __trace_function trace_function
 
-static int
-irqsoff_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
-{
-       return -EINVAL;
-}
-
 static int irqsoff_graph_entry(struct ftrace_graph_ent *trace)
 {
        return -1;
@@ -556,12 +540,13 @@ static void unregister_irqsoff_function(struct trace_array *tr, int graph)
        function_enabled = false;
 }
 
-static void irqsoff_function_set(struct trace_array *tr, int set)
+static int irqsoff_function_set(struct trace_array *tr, int set)
 {
        if (set)
                register_irqsoff_function(tr, is_graph(), 1);
        else
                unregister_irqsoff_function(tr, is_graph());
+       return 0;
 }
 
 static int irqsoff_flag_changed(struct trace_array *tr, u32 mask, int set)
@@ -569,7 +554,10 @@ static int irqsoff_flag_changed(struct trace_array *tr, u32 mask, int set)
        struct tracer *tracer = tr->current_trace;
 
        if (mask & TRACE_ITER_FUNCTION)
-               irqsoff_function_set(tr, set);
+               return irqsoff_function_set(tr, set);
+
+       if (mask & TRACE_ITER_DISPLAY_GRAPH)
+               return irqsoff_display_graph(tr, set);
 
        return trace_keep_overwrite(tracer, mask, set);
 }
@@ -666,8 +654,6 @@ static struct tracer irqsoff_tracer __read_mostly =
        .print_max      = true,
        .print_header   = irqsoff_print_header,
        .print_line     = irqsoff_print_line,
-       .flags          = &tracer_flags,
-       .set_flag       = irqsoff_set_flag,
        .flag_changed   = irqsoff_flag_changed,
 #ifdef CONFIG_FTRACE_SELFTEST
        .selftest    = trace_selftest_startup_irqsoff,
@@ -700,8 +686,6 @@ static struct tracer preemptoff_tracer __read_mostly =
        .print_max      = true,
        .print_header   = irqsoff_print_header,
        .print_line     = irqsoff_print_line,
-       .flags          = &tracer_flags,
-       .set_flag       = irqsoff_set_flag,
        .flag_changed   = irqsoff_flag_changed,
 #ifdef CONFIG_FTRACE_SELFTEST
        .selftest    = trace_selftest_startup_preemptoff,
@@ -736,8 +720,6 @@ static struct tracer preemptirqsoff_tracer __read_mostly =
        .print_max      = true,
        .print_header   = irqsoff_print_header,
        .print_line     = irqsoff_print_line,
-       .flags          = &tracer_flags,
-       .set_flag       = irqsoff_set_flag,
        .flag_changed   = irqsoff_flag_changed,
 #ifdef CONFIG_FTRACE_SELFTEST
        .selftest    = trace_selftest_startup_preemptirqsoff,
index c29d49e..f5d2e65 100644 (file)
@@ -40,22 +40,17 @@ static void wakeup_graph_return(struct ftrace_graph_ret *trace);
 static int save_flags;
 static bool function_enabled;
 
-#define TRACE_DISPLAY_GRAPH     1
+#define is_graph() (trace_flags & TRACE_ITER_DISPLAY_GRAPH)
 
-static struct tracer_opt trace_opts[] = {
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-       /* display latency trace as call graph */
-       { TRACER_OPT(display-graph, TRACE_DISPLAY_GRAPH) },
+static int wakeup_display_graph(struct trace_array *tr, int set);
+#else
+static inline int wakeup_display_graph(struct trace_array *tr, int set)
+{
+       return -EINVAL;
+}
 #endif
-       { } /* Empty entry */
-};
 
-static struct tracer_flags tracer_flags = {
-       .val  = 0,
-       .opts = trace_opts,
-};
-
-#define is_graph() (tracer_flags.val & TRACE_DISPLAY_GRAPH)
 
 #ifdef CONFIG_FUNCTION_TRACER
 
@@ -163,12 +158,13 @@ static void unregister_wakeup_function(struct trace_array *tr, int graph)
        function_enabled = false;
 }
 
-static void wakeup_function_set(struct trace_array *tr, int set)
+static int wakeup_function_set(struct trace_array *tr, int set)
 {
        if (set)
                register_wakeup_function(tr, is_graph(), 1);
        else
                unregister_wakeup_function(tr, is_graph());
+       return 0;
 }
 
 static int wakeup_flag_changed(struct trace_array *tr, u32 mask, int set)
@@ -176,7 +172,10 @@ static int wakeup_flag_changed(struct trace_array *tr, u32 mask, int set)
        struct tracer *tracer = tr->current_trace;
 
        if (mask & TRACE_ITER_FUNCTION)
-               wakeup_function_set(tr, set);
+               return wakeup_function_set(tr, set);
+
+       if (mask & TRACE_ITER_DISPLAY_GRAPH)
+               return wakeup_display_graph(tr, set);
 
        return trace_keep_overwrite(tracer, mask, set);
 }
@@ -203,13 +202,8 @@ static void stop_func_tracer(struct trace_array *tr, int graph)
 }
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-static int
-wakeup_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
+static int wakeup_display_graph(struct trace_array *tr, int set)
 {
-
-       if (!(bit & TRACE_DISPLAY_GRAPH))
-               return -EINVAL;
-
        if (!(is_graph() ^ set))
                return 0;
 
@@ -306,12 +300,6 @@ __trace_function(struct trace_array *tr,
 #else
 #define __trace_function trace_function
 
-static int
-wakeup_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
-{
-       return -EINVAL;
-}
-
 static int wakeup_graph_entry(struct ftrace_graph_ent *trace)
 {
        return -1;
@@ -740,8 +728,6 @@ static struct tracer wakeup_tracer __read_mostly =
        .print_max      = true,
        .print_header   = wakeup_print_header,
        .print_line     = wakeup_print_line,
-       .flags          = &tracer_flags,
-       .set_flag       = wakeup_set_flag,
        .flag_changed   = wakeup_flag_changed,
 #ifdef CONFIG_FTRACE_SELFTEST
        .selftest    = trace_selftest_startup_wakeup,
@@ -762,8 +748,6 @@ static struct tracer wakeup_rt_tracer __read_mostly =
        .print_max      = true,
        .print_header   = wakeup_print_header,
        .print_line     = wakeup_print_line,
-       .flags          = &tracer_flags,
-       .set_flag       = wakeup_set_flag,
        .flag_changed   = wakeup_flag_changed,
 #ifdef CONFIG_FTRACE_SELFTEST
        .selftest    = trace_selftest_startup_wakeup,
@@ -784,8 +768,6 @@ static struct tracer wakeup_dl_tracer __read_mostly =
        .print_max      = true,
        .print_header   = wakeup_print_header,
        .print_line     = wakeup_print_line,
-       .flags          = &tracer_flags,
-       .set_flag       = wakeup_set_flag,
        .flag_changed   = wakeup_flag_changed,
 #ifdef CONFIG_FTRACE_SELFTEST
        .selftest    = trace_selftest_startup_wakeup,