Commit b304d044 authored by Steven Rostedt's avatar Steven Rostedt Committed by Steven Rostedt

tracing: Do not trace in irq when funcgraph-irq option is zero

When the function graph tracer funcgraph-irq option is zero, disable
tracing in IRQs. This makes the option have two effects.

1) When reading the trace file, do not display the functions that
   happen in interrupt context (when detected)

2) [*new*] When recording a trace, skip those that are detected
   to be in interrupt by the 'in_irq()' function

Note, in_irq() is updated at irq_enter() and irq_exit(). There are
still functions that are recorded by the function graph tracer that
is in interrupt context but outside the irq_enter/exit() routines.
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 2bd16212
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
#include "trace.h" #include "trace.h"
#include "trace_output.h" #include "trace_output.h"
/* When set, irq functions will be ignored */
static int ftrace_graph_skip_irqs;
struct fgraph_cpu_data { struct fgraph_cpu_data {
pid_t last_pid; pid_t last_pid;
int depth; int depth;
...@@ -208,6 +211,14 @@ int __trace_graph_entry(struct trace_array *tr, ...@@ -208,6 +211,14 @@ int __trace_graph_entry(struct trace_array *tr,
return 1; return 1;
} }
static inline int ftrace_graph_ignore_irqs(void)
{
if (!ftrace_graph_skip_irqs)
return 0;
return in_irq();
}
int trace_graph_entry(struct ftrace_graph_ent *trace) int trace_graph_entry(struct ftrace_graph_ent *trace)
{ {
struct trace_array *tr = graph_array; struct trace_array *tr = graph_array;
...@@ -222,7 +233,8 @@ int trace_graph_entry(struct ftrace_graph_ent *trace) ...@@ -222,7 +233,8 @@ int trace_graph_entry(struct ftrace_graph_ent *trace)
return 0; return 0;
/* trace it when it is-nested-in or is a function enabled. */ /* trace it when it is-nested-in or is a function enabled. */
if (!(trace->depth || ftrace_graph_addr(trace->func))) if (!(trace->depth || ftrace_graph_addr(trace->func)) ||
ftrace_graph_ignore_irqs())
return 0; return 0;
local_irq_save(flags); local_irq_save(flags);
...@@ -1334,6 +1346,14 @@ void graph_trace_close(struct trace_iterator *iter) ...@@ -1334,6 +1346,14 @@ void graph_trace_close(struct trace_iterator *iter)
} }
} }
static int func_graph_set_flag(u32 old_flags, u32 bit, int set)
{
if (bit == TRACE_GRAPH_PRINT_IRQS)
ftrace_graph_skip_irqs = !set;
return 0;
}
static struct trace_event_functions graph_functions = { static struct trace_event_functions graph_functions = {
.trace = print_graph_function_event, .trace = print_graph_function_event,
}; };
...@@ -1360,6 +1380,7 @@ static struct tracer graph_trace __read_mostly = { ...@@ -1360,6 +1380,7 @@ static struct tracer graph_trace __read_mostly = {
.print_line = print_graph_function, .print_line = print_graph_function,
.print_header = print_graph_headers, .print_header = print_graph_headers,
.flags = &tracer_flags, .flags = &tracer_flags,
.set_flag = func_graph_set_flag,
#ifdef CONFIG_FTRACE_SELFTEST #ifdef CONFIG_FTRACE_SELFTEST
.selftest = trace_selftest_startup_function_graph, .selftest = trace_selftest_startup_function_graph,
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment