Commit 983f938a authored by Steven Rostedt (Red Hat)'s avatar Steven Rostedt (Red Hat) Committed by Steven Rostedt

tracing: Move trace_flags from global to a trace_array field

In preparation to make trace options per instance, the global trace_flags
needs to be moved from being a global variable to a field within the trace
instance trace_array structure.

There's still more work to do, as there's some functions that use
trace_flags without passing in a way to get to the current_trace array. For
those, the global_trace is used directly (from trace.c). This includes
setting and clearing the trace_flags. This means that when a new instance is
created, it just gets the trace_flags of the global_trace and will not be
able to modify them. Depending on the functions that have access to the
trace_array, the flags of an instance may not affect parts of its trace,
where the global_trace is used. These will be fixed in future changes.
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 55577204
...@@ -1343,6 +1343,7 @@ static const struct { ...@@ -1343,6 +1343,7 @@ static const struct {
static enum print_line_t print_one_line(struct trace_iterator *iter, static enum print_line_t print_one_line(struct trace_iterator *iter,
bool classic) bool classic)
{ {
struct trace_array *tr = iter->tr;
struct trace_seq *s = &iter->seq; struct trace_seq *s = &iter->seq;
const struct blk_io_trace *t; const struct blk_io_trace *t;
u16 what; u16 what;
...@@ -1351,7 +1352,7 @@ static enum print_line_t print_one_line(struct trace_iterator *iter, ...@@ -1351,7 +1352,7 @@ static enum print_line_t print_one_line(struct trace_iterator *iter,
t = te_blk_io_trace(iter->ent); t = te_blk_io_trace(iter->ent);
what = t->action & ((1 << BLK_TC_SHIFT) - 1); what = t->action & ((1 << BLK_TC_SHIFT) - 1);
long_act = !!(trace_flags & TRACE_ITER_VERBOSE); long_act = !!(tr->trace_flags & TRACE_ITER_VERBOSE);
log_action = classic ? &blk_log_action_classic : &blk_log_action; log_action = classic ? &blk_log_action_classic : &blk_log_action;
if (t->action == BLK_TN_MESSAGE) { if (t->action == BLK_TN_MESSAGE) {
...@@ -1413,9 +1414,9 @@ blk_tracer_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set) ...@@ -1413,9 +1414,9 @@ blk_tracer_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
/* don't output context-info for blk_classic output */ /* don't output context-info for blk_classic output */
if (bit == TRACE_BLK_OPT_CLASSIC) { if (bit == TRACE_BLK_OPT_CLASSIC) {
if (set) if (set)
trace_flags &= ~TRACE_ITER_CONTEXT_INFO; tr->trace_flags &= ~TRACE_ITER_CONTEXT_INFO;
else else
trace_flags |= TRACE_ITER_CONTEXT_INFO; tr->trace_flags |= TRACE_ITER_CONTEXT_INFO;
} }
return 0; return 0;
} }
......
This diff is collapsed.
...@@ -217,6 +217,7 @@ struct trace_array { ...@@ -217,6 +217,7 @@ struct trace_array {
int stop_count; int stop_count;
int clock_id; int clock_id;
struct tracer *current_trace; struct tracer *current_trace;
unsigned int trace_flags;
unsigned int flags; unsigned int flags;
raw_spinlock_t start_lock; raw_spinlock_t start_lock;
struct dentry *dir; struct dentry *dir;
...@@ -698,8 +699,6 @@ int trace_array_printk_buf(struct ring_buffer *buffer, ...@@ -698,8 +699,6 @@ int trace_array_printk_buf(struct ring_buffer *buffer,
void trace_printk_seq(struct trace_seq *s); void trace_printk_seq(struct trace_seq *s);
enum print_line_t print_trace_line(struct trace_iterator *iter); enum print_line_t print_trace_line(struct trace_iterator *iter);
extern unsigned long trace_flags;
extern char trace_find_mark(unsigned long long duration); extern char trace_find_mark(unsigned long long duration);
/* Standard output formatting function used for function return traces */ /* Standard output formatting function used for function return traces */
...@@ -994,7 +993,7 @@ extern int enable_branch_tracing(struct trace_array *tr); ...@@ -994,7 +993,7 @@ extern int enable_branch_tracing(struct trace_array *tr);
extern void disable_branch_tracing(void); extern void disable_branch_tracing(void);
static inline int trace_branch_enable(struct trace_array *tr) static inline int trace_branch_enable(struct trace_array *tr)
{ {
if (trace_flags & TRACE_ITER_BRANCH) if (tr->trace_flags & TRACE_ITER_BRANCH)
return enable_branch_tracing(tr); return enable_branch_tracing(tr);
return 0; return 0;
} }
......
...@@ -338,6 +338,7 @@ static int __ftrace_event_enable_disable(struct trace_event_file *file, ...@@ -338,6 +338,7 @@ static int __ftrace_event_enable_disable(struct trace_event_file *file,
int enable, int soft_disable) int enable, int soft_disable)
{ {
struct trace_event_call *call = file->event_call; struct trace_event_call *call = file->event_call;
struct trace_array *tr = file->tr;
int ret = 0; int ret = 0;
int disable; int disable;
...@@ -401,7 +402,7 @@ static int __ftrace_event_enable_disable(struct trace_event_file *file, ...@@ -401,7 +402,7 @@ static int __ftrace_event_enable_disable(struct trace_event_file *file,
if (soft_disable) if (soft_disable)
set_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &file->flags); set_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &file->flags);
if (trace_flags & TRACE_ITER_RECORD_CMD) { if (tr->trace_flags & TRACE_ITER_RECORD_CMD) {
tracing_start_cmdline_record(); tracing_start_cmdline_record();
set_bit(EVENT_FILE_FL_RECORDED_CMD_BIT, &file->flags); set_bit(EVENT_FILE_FL_RECORDED_CMD_BIT, &file->flags);
} }
......
...@@ -112,8 +112,8 @@ enum { ...@@ -112,8 +112,8 @@ enum {
}; };
static void static void
print_graph_duration(unsigned long long duration, struct trace_seq *s, print_graph_duration(struct trace_array *tr, unsigned long long duration,
u32 flags); struct trace_seq *s, u32 flags);
/* Add a function return address to the trace stack on thread info.*/ /* Add a function return address to the trace stack on thread info.*/
int int
...@@ -658,6 +658,7 @@ static void ...@@ -658,6 +658,7 @@ static void
print_graph_irq(struct trace_iterator *iter, unsigned long addr, print_graph_irq(struct trace_iterator *iter, unsigned long addr,
enum trace_type type, int cpu, pid_t pid, u32 flags) enum trace_type type, int cpu, pid_t pid, u32 flags)
{ {
struct trace_array *tr = iter->tr;
struct trace_seq *s = &iter->seq; struct trace_seq *s = &iter->seq;
struct trace_entry *ent = iter->ent; struct trace_entry *ent = iter->ent;
...@@ -665,7 +666,7 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr, ...@@ -665,7 +666,7 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
addr >= (unsigned long)__irqentry_text_end) addr >= (unsigned long)__irqentry_text_end)
return; return;
if (trace_flags & TRACE_ITER_CONTEXT_INFO) { if (tr->trace_flags & TRACE_ITER_CONTEXT_INFO) {
/* Absolute time */ /* Absolute time */
if (flags & TRACE_GRAPH_PRINT_ABS_TIME) if (flags & TRACE_GRAPH_PRINT_ABS_TIME)
print_graph_abs_time(iter->ts, s); print_graph_abs_time(iter->ts, s);
...@@ -681,19 +682,19 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr, ...@@ -681,19 +682,19 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
} }
/* Latency format */ /* Latency format */
if (trace_flags & TRACE_ITER_LATENCY_FMT) if (tr->trace_flags & TRACE_ITER_LATENCY_FMT)
print_graph_lat_fmt(s, ent); print_graph_lat_fmt(s, ent);
} }
/* No overhead */ /* No overhead */
print_graph_duration(0, s, flags | FLAGS_FILL_START); print_graph_duration(tr, 0, s, flags | FLAGS_FILL_START);
if (type == TRACE_GRAPH_ENT) if (type == TRACE_GRAPH_ENT)
trace_seq_puts(s, "==========>"); trace_seq_puts(s, "==========>");
else else
trace_seq_puts(s, "<=========="); trace_seq_puts(s, "<==========");
print_graph_duration(0, s, flags | FLAGS_FILL_END); print_graph_duration(tr, 0, s, flags | FLAGS_FILL_END);
trace_seq_putc(s, '\n'); trace_seq_putc(s, '\n');
} }
...@@ -731,11 +732,11 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s) ...@@ -731,11 +732,11 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s)
} }
static void static void
print_graph_duration(unsigned long long duration, struct trace_seq *s, print_graph_duration(struct trace_array *tr, unsigned long long duration,
u32 flags) struct trace_seq *s, u32 flags)
{ {
if (!(flags & TRACE_GRAPH_PRINT_DURATION) || if (!(flags & TRACE_GRAPH_PRINT_DURATION) ||
!(trace_flags & TRACE_ITER_CONTEXT_INFO)) !(tr->trace_flags & TRACE_ITER_CONTEXT_INFO))
return; return;
/* No real adata, just filling the column with spaces */ /* No real adata, just filling the column with spaces */
...@@ -769,6 +770,7 @@ print_graph_entry_leaf(struct trace_iterator *iter, ...@@ -769,6 +770,7 @@ print_graph_entry_leaf(struct trace_iterator *iter,
struct trace_seq *s, u32 flags) struct trace_seq *s, u32 flags)
{ {
struct fgraph_data *data = iter->private; struct fgraph_data *data = iter->private;
struct trace_array *tr = iter->tr;
struct ftrace_graph_ret *graph_ret; struct ftrace_graph_ret *graph_ret;
struct ftrace_graph_ent *call; struct ftrace_graph_ent *call;
unsigned long long duration; unsigned long long duration;
...@@ -797,7 +799,7 @@ print_graph_entry_leaf(struct trace_iterator *iter, ...@@ -797,7 +799,7 @@ print_graph_entry_leaf(struct trace_iterator *iter,
} }
/* Overhead and duration */ /* Overhead and duration */
print_graph_duration(duration, s, flags); print_graph_duration(tr, duration, s, flags);
/* Function */ /* Function */
for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++)
...@@ -815,6 +817,7 @@ print_graph_entry_nested(struct trace_iterator *iter, ...@@ -815,6 +817,7 @@ print_graph_entry_nested(struct trace_iterator *iter,
{ {
struct ftrace_graph_ent *call = &entry->graph_ent; struct ftrace_graph_ent *call = &entry->graph_ent;
struct fgraph_data *data = iter->private; struct fgraph_data *data = iter->private;
struct trace_array *tr = iter->tr;
int i; int i;
if (data) { if (data) {
...@@ -830,7 +833,7 @@ print_graph_entry_nested(struct trace_iterator *iter, ...@@ -830,7 +833,7 @@ print_graph_entry_nested(struct trace_iterator *iter,
} }
/* No time */ /* No time */
print_graph_duration(0, s, flags | FLAGS_FILL_FULL); print_graph_duration(tr, 0, s, flags | FLAGS_FILL_FULL);
/* Function */ /* Function */
for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++)
...@@ -854,6 +857,7 @@ print_graph_prologue(struct trace_iterator *iter, struct trace_seq *s, ...@@ -854,6 +857,7 @@ print_graph_prologue(struct trace_iterator *iter, struct trace_seq *s,
{ {
struct fgraph_data *data = iter->private; struct fgraph_data *data = iter->private;
struct trace_entry *ent = iter->ent; struct trace_entry *ent = iter->ent;
struct trace_array *tr = iter->tr;
int cpu = iter->cpu; int cpu = iter->cpu;
/* Pid */ /* Pid */
...@@ -863,7 +867,7 @@ print_graph_prologue(struct trace_iterator *iter, struct trace_seq *s, ...@@ -863,7 +867,7 @@ print_graph_prologue(struct trace_iterator *iter, struct trace_seq *s,
/* Interrupt */ /* Interrupt */
print_graph_irq(iter, addr, type, cpu, ent->pid, flags); print_graph_irq(iter, addr, type, cpu, ent->pid, flags);
if (!(trace_flags & TRACE_ITER_CONTEXT_INFO)) if (!(tr->trace_flags & TRACE_ITER_CONTEXT_INFO))
return; return;
/* Absolute time */ /* Absolute time */
...@@ -881,7 +885,7 @@ print_graph_prologue(struct trace_iterator *iter, struct trace_seq *s, ...@@ -881,7 +885,7 @@ print_graph_prologue(struct trace_iterator *iter, struct trace_seq *s,
} }
/* Latency format */ /* Latency format */
if (trace_flags & TRACE_ITER_LATENCY_FMT) if (tr->trace_flags & TRACE_ITER_LATENCY_FMT)
print_graph_lat_fmt(s, ent); print_graph_lat_fmt(s, ent);
return; return;
...@@ -1032,6 +1036,7 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s, ...@@ -1032,6 +1036,7 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s,
{ {
unsigned long long duration = trace->rettime - trace->calltime; unsigned long long duration = trace->rettime - trace->calltime;
struct fgraph_data *data = iter->private; struct fgraph_data *data = iter->private;
struct trace_array *tr = iter->tr;
pid_t pid = ent->pid; pid_t pid = ent->pid;
int cpu = iter->cpu; int cpu = iter->cpu;
int func_match = 1; int func_match = 1;
...@@ -1063,7 +1068,7 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s, ...@@ -1063,7 +1068,7 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s,
print_graph_prologue(iter, s, 0, 0, flags); print_graph_prologue(iter, s, 0, 0, flags);
/* Overhead and duration */ /* Overhead and duration */
print_graph_duration(duration, s, flags); print_graph_duration(tr, duration, s, flags);
/* Closing brace */ /* Closing brace */
for (i = 0; i < trace->depth * TRACE_GRAPH_INDENT; i++) for (i = 0; i < trace->depth * TRACE_GRAPH_INDENT; i++)
...@@ -1096,7 +1101,8 @@ static enum print_line_t ...@@ -1096,7 +1101,8 @@ static enum print_line_t
print_graph_comment(struct trace_seq *s, struct trace_entry *ent, print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
struct trace_iterator *iter, u32 flags) struct trace_iterator *iter, u32 flags)
{ {
unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK); struct trace_array *tr = iter->tr;
unsigned long sym_flags = (tr->trace_flags & TRACE_ITER_SYM_MASK);
struct fgraph_data *data = iter->private; struct fgraph_data *data = iter->private;
struct trace_event *event; struct trace_event *event;
int depth = 0; int depth = 0;
...@@ -1109,7 +1115,7 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent, ...@@ -1109,7 +1115,7 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
print_graph_prologue(iter, s, 0, 0, flags); print_graph_prologue(iter, s, 0, 0, flags);
/* No time */ /* No time */
print_graph_duration(0, s, flags | FLAGS_FILL_FULL); print_graph_duration(tr, 0, s, flags | FLAGS_FILL_FULL);
/* Indentation */ /* Indentation */
if (depth > 0) if (depth > 0)
...@@ -1250,9 +1256,10 @@ static void print_lat_header(struct seq_file *s, u32 flags) ...@@ -1250,9 +1256,10 @@ static void print_lat_header(struct seq_file *s, u32 flags)
seq_printf(s, "#%.*s||| / \n", size, spaces); seq_printf(s, "#%.*s||| / \n", size, spaces);
} }
static void __print_graph_headers_flags(struct seq_file *s, u32 flags) static void __print_graph_headers_flags(struct trace_array *tr,
struct seq_file *s, u32 flags)
{ {
int lat = trace_flags & TRACE_ITER_LATENCY_FMT; int lat = tr->trace_flags & TRACE_ITER_LATENCY_FMT;
if (lat) if (lat)
print_lat_header(s, flags); print_lat_header(s, flags);
...@@ -1294,11 +1301,12 @@ static void print_graph_headers(struct seq_file *s) ...@@ -1294,11 +1301,12 @@ static void print_graph_headers(struct seq_file *s)
void print_graph_headers_flags(struct seq_file *s, u32 flags) void print_graph_headers_flags(struct seq_file *s, u32 flags)
{ {
struct trace_iterator *iter = s->private; struct trace_iterator *iter = s->private;
struct trace_array *tr = iter->tr;
if (!(trace_flags & TRACE_ITER_CONTEXT_INFO)) if (!(tr->trace_flags & TRACE_ITER_CONTEXT_INFO))
return; return;
if (trace_flags & TRACE_ITER_LATENCY_FMT) { if (tr->trace_flags & TRACE_ITER_LATENCY_FMT) {
/* print nothing if the buffers are empty */ /* print nothing if the buffers are empty */
if (trace_empty(iter)) if (trace_empty(iter))
return; return;
...@@ -1306,7 +1314,7 @@ void print_graph_headers_flags(struct seq_file *s, u32 flags) ...@@ -1306,7 +1314,7 @@ void print_graph_headers_flags(struct seq_file *s, u32 flags)
print_trace_header(s, iter); print_trace_header(s, iter);
} }
__print_graph_headers_flags(s, flags); __print_graph_headers_flags(tr, s, flags);
} }
void graph_trace_open(struct trace_iterator *iter) void graph_trace_open(struct trace_iterator *iter)
......
...@@ -58,13 +58,13 @@ irq_trace(void) ...@@ -58,13 +58,13 @@ irq_trace(void)
#ifdef CONFIG_FUNCTION_GRAPH_TRACER #ifdef CONFIG_FUNCTION_GRAPH_TRACER
static int irqsoff_display_graph(struct trace_array *tr, int set); static int irqsoff_display_graph(struct trace_array *tr, int set);
# define is_graph() (trace_flags & TRACE_ITER_DISPLAY_GRAPH) # define is_graph(tr) ((tr)->trace_flags & TRACE_ITER_DISPLAY_GRAPH)
#else #else
static inline int irqsoff_display_graph(struct trace_array *tr, int set) static inline int irqsoff_display_graph(struct trace_array *tr, int set)
{ {
return -EINVAL; return -EINVAL;
} }
# define is_graph() false # define is_graph(tr) false
#endif #endif
/* /*
...@@ -149,7 +149,7 @@ static int irqsoff_display_graph(struct trace_array *tr, int set) ...@@ -149,7 +149,7 @@ static int irqsoff_display_graph(struct trace_array *tr, int set)
{ {
int cpu; int cpu;
if (!(is_graph() ^ set)) if (!(is_graph(tr) ^ set))
return 0; return 0;
stop_irqsoff_tracer(irqsoff_trace, !set); stop_irqsoff_tracer(irqsoff_trace, !set);
...@@ -198,7 +198,7 @@ static void irqsoff_graph_return(struct ftrace_graph_ret *trace) ...@@ -198,7 +198,7 @@ static void irqsoff_graph_return(struct ftrace_graph_ret *trace)
static void irqsoff_trace_open(struct trace_iterator *iter) static void irqsoff_trace_open(struct trace_iterator *iter)
{ {
if (is_graph()) if (is_graph(iter->tr))
graph_trace_open(iter); graph_trace_open(iter);
} }
...@@ -220,7 +220,7 @@ static enum print_line_t irqsoff_print_line(struct trace_iterator *iter) ...@@ -220,7 +220,7 @@ static enum print_line_t irqsoff_print_line(struct trace_iterator *iter)
* In graph mode call the graph tracer output function, * In graph mode call the graph tracer output function,
* otherwise go with the TRACE_FN event handler * otherwise go with the TRACE_FN event handler
*/ */
if (is_graph()) if (is_graph(iter->tr))
return print_graph_function_flags(iter, GRAPH_TRACER_FLAGS); return print_graph_function_flags(iter, GRAPH_TRACER_FLAGS);
return TRACE_TYPE_UNHANDLED; return TRACE_TYPE_UNHANDLED;
...@@ -228,7 +228,9 @@ static enum print_line_t irqsoff_print_line(struct trace_iterator *iter) ...@@ -228,7 +228,9 @@ static enum print_line_t irqsoff_print_line(struct trace_iterator *iter)
static void irqsoff_print_header(struct seq_file *s) static void irqsoff_print_header(struct seq_file *s)
{ {
if (is_graph()) struct trace_array *tr = irqsoff_trace;
if (is_graph(tr))
print_graph_headers_flags(s, GRAPH_TRACER_FLAGS); print_graph_headers_flags(s, GRAPH_TRACER_FLAGS);
else else
trace_default_header(s); trace_default_header(s);
...@@ -239,7 +241,7 @@ __trace_function(struct trace_array *tr, ...@@ -239,7 +241,7 @@ __trace_function(struct trace_array *tr,
unsigned long ip, unsigned long parent_ip, unsigned long ip, unsigned long parent_ip,
unsigned long flags, int pc) unsigned long flags, int pc)
{ {
if (is_graph()) if (is_graph(tr))
trace_graph_function(tr, ip, parent_ip, flags, pc); trace_graph_function(tr, ip, parent_ip, flags, pc);
else else
trace_function(tr, ip, parent_ip, flags, pc); trace_function(tr, ip, parent_ip, flags, pc);
...@@ -516,7 +518,7 @@ static int register_irqsoff_function(struct trace_array *tr, int graph, int set) ...@@ -516,7 +518,7 @@ static int register_irqsoff_function(struct trace_array *tr, int graph, int set)
int ret; int ret;
/* 'set' is set if TRACE_ITER_FUNCTION is about to be set */ /* 'set' is set if TRACE_ITER_FUNCTION is about to be set */
if (function_enabled || (!set && !(trace_flags & TRACE_ITER_FUNCTION))) if (function_enabled || (!set && !(tr->trace_flags & TRACE_ITER_FUNCTION)))
return 0; return 0;
if (graph) if (graph)
...@@ -550,9 +552,9 @@ static int irqsoff_function_set(struct trace_array *tr, u32 mask, int set) ...@@ -550,9 +552,9 @@ static int irqsoff_function_set(struct trace_array *tr, u32 mask, int set)
return 0; return 0;
if (set) if (set)
register_irqsoff_function(tr, is_graph(), 1); register_irqsoff_function(tr, is_graph(tr), 1);
else else
unregister_irqsoff_function(tr, is_graph()); unregister_irqsoff_function(tr, is_graph(tr));
return 1; return 1;
} }
#else #else
...@@ -610,7 +612,7 @@ static int __irqsoff_tracer_init(struct trace_array *tr) ...@@ -610,7 +612,7 @@ static int __irqsoff_tracer_init(struct trace_array *tr)
if (irqsoff_busy) if (irqsoff_busy)
return -EBUSY; return -EBUSY;
save_flags = trace_flags; save_flags = tr->trace_flags;
/* non overwrite screws up the latency tracers */ /* non overwrite screws up the latency tracers */
set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1); set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1);
...@@ -626,7 +628,7 @@ static int __irqsoff_tracer_init(struct trace_array *tr) ...@@ -626,7 +628,7 @@ static int __irqsoff_tracer_init(struct trace_array *tr)
/* Only toplevel instance supports graph tracing */ /* Only toplevel instance supports graph tracing */
if (start_irqsoff_tracer(tr, (tr->flags & TRACE_ARRAY_FL_GLOBAL && if (start_irqsoff_tracer(tr, (tr->flags & TRACE_ARRAY_FL_GLOBAL &&
is_graph()))) is_graph(tr))))
printk(KERN_ERR "failed to start irqsoff tracer\n"); printk(KERN_ERR "failed to start irqsoff tracer\n");
irqsoff_busy = true; irqsoff_busy = true;
...@@ -638,7 +640,7 @@ static void irqsoff_tracer_reset(struct trace_array *tr) ...@@ -638,7 +640,7 @@ static void irqsoff_tracer_reset(struct trace_array *tr)
int lat_flag = save_flags & TRACE_ITER_LATENCY_FMT; int lat_flag = save_flags & TRACE_ITER_LATENCY_FMT;
int overwrite_flag = save_flags & TRACE_ITER_OVERWRITE; int overwrite_flag = save_flags & TRACE_ITER_OVERWRITE;
stop_irqsoff_tracer(tr, is_graph()); stop_irqsoff_tracer(tr, is_graph(tr));
set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, lat_flag); set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, lat_flag);
set_tracer_flag(tr, TRACE_ITER_OVERWRITE, overwrite_flag); set_tracer_flag(tr, TRACE_ITER_OVERWRITE, overwrite_flag);
......
...@@ -21,20 +21,22 @@ static void ftrace_dump_buf(int skip_lines, long cpu_file) ...@@ -21,20 +21,22 @@ static void ftrace_dump_buf(int skip_lines, long cpu_file)
/* use static because iter can be a bit big for the stack */ /* use static because iter can be a bit big for the stack */
static struct trace_iterator iter; static struct trace_iterator iter;
static struct ring_buffer_iter *buffer_iter[CONFIG_NR_CPUS]; static struct ring_buffer_iter *buffer_iter[CONFIG_NR_CPUS];
struct trace_array *tr;
unsigned int old_userobj; unsigned int old_userobj;
int cnt = 0, cpu; int cnt = 0, cpu;
trace_init_global_iter(&iter); trace_init_global_iter(&iter);
iter.buffer_iter = buffer_iter; iter.buffer_iter = buffer_iter;
tr = iter.tr;
for_each_tracing_cpu(cpu) { for_each_tracing_cpu(cpu) {
atomic_inc(&per_cpu_ptr(iter.trace_buffer->data, cpu)->disabled); atomic_inc(&per_cpu_ptr(iter.trace_buffer->data, cpu)->disabled);
} }
old_userobj = trace_flags; old_userobj = tr->trace_flags;
/* don't look at user memory in panic mode */ /* don't look at user memory in panic mode */
trace_flags &= ~TRACE_ITER_SYM_USEROBJ; tr->trace_flags &= ~TRACE_ITER_SYM_USEROBJ;
kdb_printf("Dumping ftrace buffer:\n"); kdb_printf("Dumping ftrace buffer:\n");
...@@ -82,7 +84,7 @@ static void ftrace_dump_buf(int skip_lines, long cpu_file) ...@@ -82,7 +84,7 @@ static void ftrace_dump_buf(int skip_lines, long cpu_file)
kdb_printf("---------------------------------\n"); kdb_printf("---------------------------------\n");
out: out:
trace_flags = old_userobj; tr->trace_flags = old_userobj;
for_each_tracing_cpu(cpu) { for_each_tracing_cpu(cpu) {
atomic_dec(&per_cpu_ptr(iter.trace_buffer->data, cpu)->disabled); atomic_dec(&per_cpu_ptr(iter.trace_buffer->data, cpu)->disabled);
......
...@@ -476,7 +476,8 @@ char trace_find_mark(unsigned long long d) ...@@ -476,7 +476,8 @@ char trace_find_mark(unsigned long long d)
static int static int
lat_print_timestamp(struct trace_iterator *iter, u64 next_ts) lat_print_timestamp(struct trace_iterator *iter, u64 next_ts)
{ {
unsigned long verbose = trace_flags & TRACE_ITER_VERBOSE; struct trace_array *tr = iter->tr;
unsigned long verbose = tr->trace_flags & TRACE_ITER_VERBOSE;
unsigned long in_ns = iter->iter_flags & TRACE_FILE_TIME_IN_NS; unsigned long in_ns = iter->iter_flags & TRACE_FILE_TIME_IN_NS;
unsigned long long abs_ts = iter->ts - iter->trace_buffer->time_start; unsigned long long abs_ts = iter->ts - iter->trace_buffer->time_start;
unsigned long long rel_ts = next_ts - iter->ts; unsigned long long rel_ts = next_ts - iter->ts;
...@@ -519,6 +520,7 @@ lat_print_timestamp(struct trace_iterator *iter, u64 next_ts) ...@@ -519,6 +520,7 @@ lat_print_timestamp(struct trace_iterator *iter, u64 next_ts)
int trace_print_context(struct trace_iterator *iter) int trace_print_context(struct trace_iterator *iter)
{ {
struct trace_array *tr = iter->tr;
struct trace_seq *s = &iter->seq; struct trace_seq *s = &iter->seq;
struct trace_entry *entry = iter->ent; struct trace_entry *entry = iter->ent;
unsigned long long t; unsigned long long t;
...@@ -530,7 +532,7 @@ int trace_print_context(struct trace_iterator *iter) ...@@ -530,7 +532,7 @@ int trace_print_context(struct trace_iterator *iter)
trace_seq_printf(s, "%16s-%-5d [%03d] ", trace_seq_printf(s, "%16s-%-5d [%03d] ",
comm, entry->pid, iter->cpu); comm, entry->pid, iter->cpu);
if (trace_flags & TRACE_ITER_IRQ_INFO) if (tr->trace_flags & TRACE_ITER_IRQ_INFO)
trace_print_lat_fmt(s, entry); trace_print_lat_fmt(s, entry);
if (iter->iter_flags & TRACE_FILE_TIME_IN_NS) { if (iter->iter_flags & TRACE_FILE_TIME_IN_NS) {
...@@ -546,14 +548,15 @@ int trace_print_context(struct trace_iterator *iter) ...@@ -546,14 +548,15 @@ int trace_print_context(struct trace_iterator *iter)
int trace_print_lat_context(struct trace_iterator *iter) int trace_print_lat_context(struct trace_iterator *iter)
{ {
u64 next_ts; struct trace_array *tr = iter->tr;
/* trace_find_next_entry will reset ent_size */ /* trace_find_next_entry will reset ent_size */
int ent_size = iter->ent_size; int ent_size = iter->ent_size;
struct trace_seq *s = &iter->seq; struct trace_seq *s = &iter->seq;
u64 next_ts;
struct trace_entry *entry = iter->ent, struct trace_entry *entry = iter->ent,
*next_entry = trace_find_next_entry(iter, NULL, *next_entry = trace_find_next_entry(iter, NULL,
&next_ts); &next_ts);
unsigned long verbose = (trace_flags & TRACE_ITER_VERBOSE); unsigned long verbose = (tr->trace_flags & TRACE_ITER_VERBOSE);
/* Restore the original ent_size */ /* Restore the original ent_size */
iter->ent_size = ent_size; iter->ent_size = ent_size;
...@@ -1035,6 +1038,7 @@ static struct trace_event trace_stack_event = { ...@@ -1035,6 +1038,7 @@ static struct trace_event trace_stack_event = {
static enum print_line_t trace_user_stack_print(struct trace_iterator *iter, static enum print_line_t trace_user_stack_print(struct trace_iterator *iter,
int flags, struct trace_event *event) int flags, struct trace_event *event)
{ {
struct trace_array *tr = iter->tr;
struct userstack_entry *field; struct userstack_entry *field;
struct trace_seq *s = &iter->seq; struct trace_seq *s = &iter->seq;
struct mm_struct *mm = NULL; struct mm_struct *mm = NULL;
...@@ -1044,7 +1048,7 @@ static enum print_line_t trace_user_stack_print(struct trace_iterator *iter, ...@@ -1044,7 +1048,7 @@ static enum print_line_t trace_user_stack_print(struct trace_iterator *iter,
trace_seq_puts(s, "<user stack trace>\n"); trace_seq_puts(s, "<user stack trace>\n");
if (trace_flags & TRACE_ITER_SYM_USEROBJ) { if (tr->trace_flags & TRACE_ITER_SYM_USEROBJ) {
struct task_struct *task; struct task_struct *task;
/* /*
* we do the lookup on the thread group leader, * we do the lookup on the thread group leader,
......
...@@ -39,13 +39,13 @@ static int save_flags; ...@@ -39,13 +39,13 @@ static int save_flags;
#ifdef CONFIG_FUNCTION_GRAPH_TRACER #ifdef CONFIG_FUNCTION_GRAPH_TRACER
static int wakeup_display_graph(struct trace_array *tr, int set); static int wakeup_display_graph(struct trace_array *tr, int set);
# define is_graph() (trace_flags & TRACE_ITER_DISPLAY_GRAPH) # define is_graph(tr) ((tr)->trace_flags & TRACE_ITER_DISPLAY_GRAPH)
#else #else
static inline int wakeup_display_graph(struct trace_array *tr, int set) static inline int wakeup_display_graph(struct trace_array *tr, int set)
{ {
return 0; return 0;
} }
# define is_graph() false # define is_graph(tr) false
#endif #endif
...@@ -131,7 +131,7 @@ static int register_wakeup_function(struct trace_array *tr, int graph, int set) ...@@ -131,7 +131,7 @@ static int register_wakeup_function(struct trace_array *tr, int graph, int set)
int ret; int ret;
/* 'set' is set if TRACE_ITER_FUNCTION is about to be set */ /* 'set' is set if TRACE_ITER_FUNCTION is about to be set */
if (function_enabled || (!set && !(trace_flags & TRACE_ITER_FUNCTION))) if (function_enabled || (!set && !(tr->trace_flags & TRACE_ITER_FUNCTION)))
return 0; return 0;
if (graph) if (graph)
...@@ -165,9 +165,9 @@ static int wakeup_function_set(struct trace_array *tr, u32 mask, int set) ...@@ -165,9 +165,9 @@ static int wakeup_function_set(struct trace_array *tr, u32 mask, int set)
return 0; return 0;
if (set) if (set)
register_wakeup_function(tr, is_graph(), 1); register_wakeup_function(tr, is_graph(tr), 1);
else else
unregister_wakeup_function(tr, is_graph()); unregister_wakeup_function(tr, is_graph(tr));
return 1; return 1;
} }
#else #else
...@@ -221,7 +221,7 @@ static void stop_func_tracer(struct trace_array *tr, int graph) ...@@ -221,7 +221,7 @@ static void stop_func_tracer(struct trace_array *tr, int graph)
#ifdef CONFIG_FUNCTION_GRAPH_TRACER #ifdef CONFIG_FUNCTION_GRAPH_TRACER
static int wakeup_display_graph(struct trace_array *tr, int set) static int wakeup_display_graph(struct trace_array *tr, int set)
{ {
if (!(is_graph() ^ set)) if (!(is_graph(tr) ^ set))
return 0; return 0;
stop_func_tracer(tr, !set); stop_func_tracer(tr, !set);
...@@ -270,7 +270,7 @@ static void wakeup_graph_return(struct ftrace_graph_ret *trace) ...@@ -270,7 +270,7 @@ static void wakeup_graph_return(struct ftrace_graph_ret *trace)
static void wakeup_trace_open(struct trace_iterator *iter) static void wakeup_trace_open(struct trace_iterator *iter)
{ {
if (is_graph()) if (is_graph(iter->tr))
graph_trace_open(iter); graph_trace_open(iter);
} }
...@@ -290,7 +290,7 @@ static enum print_line_t wakeup_print_line(struct trace_iterator *iter) ...@@ -290,7 +290,7 @@ static enum print_line_t wakeup_print_line(struct trace_iterator *iter)
* In graph mode call the graph tracer output function, * In graph mode call the graph tracer output function,
* otherwise go with the TRACE_FN event handler * otherwise go with the TRACE_FN event handler
*/ */
if (is_graph()) if (is_graph(iter->tr))
return print_graph_function_flags(iter, GRAPH_TRACER_FLAGS); return print_graph_function_flags(iter, GRAPH_TRACER_FLAGS);
return TRACE_TYPE_UNHANDLED; return TRACE_TYPE_UNHANDLED;
...@@ -298,7 +298,7 @@ static enum print_line_t wakeup_print_line(struct trace_iterator *iter) ...@@ -298,7 +298,7 @@ static enum print_line_t wakeup_print_line(struct trace_iterator *iter)
static void wakeup_print_header(struct seq_file *s) static void wakeup_print_header(struct seq_file *s)
{ {
if (is_graph()) if (is_graph(wakeup_trace))
print_graph_headers_flags(s, GRAPH_TRACER_FLAGS); print_graph_headers_flags(s, GRAPH_TRACER_FLAGS);
else else
trace_default_header(s); trace_default_header(s);
...@@ -309,7 +309,7 @@ __trace_function(struct trace_array *tr, ...@@ -309,7 +309,7 @@ __trace_function(struct trace_array *tr,
unsigned long ip, unsigned long parent_ip, unsigned long ip, unsigned long parent_ip,
unsigned long flags, int pc) unsigned long flags, int pc)
{ {
if (is_graph()) if (is_graph(tr))
trace_graph_function(tr, ip, parent_ip, flags, pc); trace_graph_function(tr, ip, parent_ip, flags, pc);
else else
trace_function(tr, ip, parent_ip, flags, pc); trace_function(tr, ip, parent_ip, flags, pc);
...@@ -639,7 +639,7 @@ static void start_wakeup_tracer(struct trace_array *tr) ...@@ -639,7 +639,7 @@ static void start_wakeup_tracer(struct trace_array *tr)
*/ */
smp_wmb(); smp_wmb();
if (start_func_tracer(tr, is_graph())) if (start_func_tracer(tr, is_graph(tr)))
printk(KERN_ERR "failed to start wakeup tracer\n"); printk(KERN_ERR "failed to start wakeup tracer\n");
return; return;
...@@ -652,7 +652,7 @@ static void start_wakeup_tracer(struct trace_array *tr) ...@@ -652,7 +652,7 @@ static void start_wakeup_tracer(struct trace_array *tr)
static void stop_wakeup_tracer(struct trace_array *tr) static void stop_wakeup_tracer(struct trace_array *tr)
{ {
tracer_enabled = 0; tracer_enabled = 0;
stop_func_tracer(tr, is_graph()); stop_func_tracer(tr, is_graph(tr));
unregister_trace_sched_switch(probe_wakeup_sched_switch, NULL); unregister_trace_sched_switch(probe_wakeup_sched_switch, NULL);
unregister_trace_sched_wakeup_new(probe_wakeup, NULL); unregister_trace_sched_wakeup_new(probe_wakeup, NULL);
unregister_trace_sched_wakeup(probe_wakeup, NULL); unregister_trace_sched_wakeup(probe_wakeup, NULL);
...@@ -663,7 +663,7 @@ static bool wakeup_busy; ...@@ -663,7 +663,7 @@ static bool wakeup_busy;
static int __wakeup_tracer_init(struct trace_array *tr) static int __wakeup_tracer_init(struct trace_array *tr)
{ {
save_flags = trace_flags; save_flags = tr->trace_flags;
/* non overwrite screws up the latency tracers */ /* non overwrite screws up the latency tracers */
set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1); set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1);
......
...@@ -110,6 +110,7 @@ static enum print_line_t ...@@ -110,6 +110,7 @@ static enum print_line_t
print_syscall_enter(struct trace_iterator *iter, int flags, print_syscall_enter(struct trace_iterator *iter, int flags,
struct trace_event *event) struct trace_event *event)
{ {
struct trace_array *tr = iter->tr;
struct trace_seq *s = &iter->seq; struct trace_seq *s = &iter->seq;
struct trace_entry *ent = iter->ent; struct trace_entry *ent = iter->ent;
struct syscall_trace_enter *trace; struct syscall_trace_enter *trace;
...@@ -136,7 +137,7 @@ print_syscall_enter(struct trace_iterator *iter, int flags, ...@@ -136,7 +137,7 @@ print_syscall_enter(struct trace_iterator *iter, int flags,
goto end; goto end;
/* parameter types */ /* parameter types */
if (trace_flags & TRACE_ITER_VERBOSE) if (tr->trace_flags & TRACE_ITER_VERBOSE)
trace_seq_printf(s, "%s ", entry->types[i]); trace_seq_printf(s, "%s ", entry->types[i]);
/* parameter values */ /* parameter values */
......
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