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

tracing: pass around ring buffer instead of tracer

The latency tracers (irqsoff and wakeup) can swap trace buffers
on the fly. If an event is happening and has reserved data on one of
the buffers, and the latency tracer swaps the global buffer with the
max buffer, the result is that the event may commit the data to the
wrong buffer.

This patch changes the API to the trace recording to be recieve the
buffer that was used to reserve a commit. Then this buffer can be passed
in to the commit.
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent f633903a
...@@ -93,13 +93,17 @@ void tracing_generic_entry_update(struct trace_entry *entry, ...@@ -93,13 +93,17 @@ void tracing_generic_entry_update(struct trace_entry *entry,
unsigned long flags, unsigned long flags,
int pc); int pc);
struct ring_buffer_event * struct ring_buffer_event *
trace_current_buffer_lock_reserve(int type, unsigned long len, trace_current_buffer_lock_reserve(struct ring_buffer **current_buffer,
int type, unsigned long len,
unsigned long flags, int pc); unsigned long flags, int pc);
void trace_current_buffer_unlock_commit(struct ring_buffer_event *event, void trace_current_buffer_unlock_commit(struct ring_buffer *buffer,
struct ring_buffer_event *event,
unsigned long flags, int pc); unsigned long flags, int pc);
void trace_nowake_buffer_unlock_commit(struct ring_buffer_event *event, void trace_nowake_buffer_unlock_commit(struct ring_buffer *buffer,
struct ring_buffer_event *event,
unsigned long flags, int pc); unsigned long flags, int pc);
void trace_current_buffer_discard_commit(struct ring_buffer_event *event); void trace_current_buffer_discard_commit(struct ring_buffer *buffer,
struct ring_buffer_event *event);
void tracing_record_cmdline(struct task_struct *tsk); void tracing_record_cmdline(struct task_struct *tsk);
...@@ -135,7 +139,8 @@ struct ftrace_event_call { ...@@ -135,7 +139,8 @@ struct ftrace_event_call {
extern void destroy_preds(struct ftrace_event_call *call); extern void destroy_preds(struct ftrace_event_call *call);
extern int filter_match_preds(struct ftrace_event_call *call, void *rec); extern int filter_match_preds(struct ftrace_event_call *call, void *rec);
extern int filter_current_check_discard(struct ftrace_event_call *call, extern int filter_current_check_discard(struct ring_buffer *buffer,
struct ftrace_event_call *call,
void *rec, void *rec,
struct ring_buffer_event *event); struct ring_buffer_event *event);
......
...@@ -460,13 +460,15 @@ static void ftrace_profile_disable_##call(struct ftrace_event_call *event_call)\ ...@@ -460,13 +460,15 @@ static void ftrace_profile_disable_##call(struct ftrace_event_call *event_call)\
* { * {
* struct ring_buffer_event *event; * struct ring_buffer_event *event;
* struct ftrace_raw_<call> *entry; <-- defined in stage 1 * struct ftrace_raw_<call> *entry; <-- defined in stage 1
* struct ring_buffer *buffer;
* unsigned long irq_flags; * unsigned long irq_flags;
* int pc; * int pc;
* *
* local_save_flags(irq_flags); * local_save_flags(irq_flags);
* pc = preempt_count(); * pc = preempt_count();
* *
* event = trace_current_buffer_lock_reserve(event_<call>.id, * event = trace_current_buffer_lock_reserve(&buffer,
* event_<call>.id,
* sizeof(struct ftrace_raw_<call>), * sizeof(struct ftrace_raw_<call>),
* irq_flags, pc); * irq_flags, pc);
* if (!event) * if (!event)
...@@ -476,7 +478,7 @@ static void ftrace_profile_disable_##call(struct ftrace_event_call *event_call)\ ...@@ -476,7 +478,7 @@ static void ftrace_profile_disable_##call(struct ftrace_event_call *event_call)\
* <assign>; <-- Here we assign the entries by the __field and * <assign>; <-- Here we assign the entries by the __field and
* __array macros. * __array macros.
* *
* trace_current_buffer_unlock_commit(event, irq_flags, pc); * trace_current_buffer_unlock_commit(buffer, event, irq_flags, pc);
* } * }
* *
* static int ftrace_raw_reg_event_<call>(void) * static int ftrace_raw_reg_event_<call>(void)
...@@ -568,6 +570,7 @@ static void ftrace_raw_event_##call(proto) \ ...@@ -568,6 +570,7 @@ static void ftrace_raw_event_##call(proto) \
struct ftrace_event_call *event_call = &event_##call; \ struct ftrace_event_call *event_call = &event_##call; \
struct ring_buffer_event *event; \ struct ring_buffer_event *event; \
struct ftrace_raw_##call *entry; \ struct ftrace_raw_##call *entry; \
struct ring_buffer *buffer; \
unsigned long irq_flags; \ unsigned long irq_flags; \
int __data_size; \ int __data_size; \
int pc; \ int pc; \
...@@ -577,7 +580,8 @@ static void ftrace_raw_event_##call(proto) \ ...@@ -577,7 +580,8 @@ static void ftrace_raw_event_##call(proto) \
\ \
__data_size = ftrace_get_offsets_##call(&__data_offsets, args); \ __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
\ \
event = trace_current_buffer_lock_reserve(event_##call.id, \ event = trace_current_buffer_lock_reserve(&buffer, \
event_##call.id, \
sizeof(*entry) + __data_size, \ sizeof(*entry) + __data_size, \
irq_flags, pc); \ irq_flags, pc); \
if (!event) \ if (!event) \
...@@ -589,8 +593,9 @@ static void ftrace_raw_event_##call(proto) \ ...@@ -589,8 +593,9 @@ static void ftrace_raw_event_##call(proto) \
\ \
{ assign; } \ { assign; } \
\ \
if (!filter_current_check_discard(event_call, entry, event)) \ if (!filter_current_check_discard(buffer, event_call, entry, event)) \
trace_nowake_buffer_unlock_commit(event, irq_flags, pc); \ trace_nowake_buffer_unlock_commit(buffer, \
event, irq_flags, pc); \
} \ } \
\ \
static int ftrace_raw_reg_event_##call(void *ptr) \ static int ftrace_raw_reg_event_##call(void *ptr) \
......
...@@ -65,13 +65,15 @@ static void trace_note(struct blk_trace *bt, pid_t pid, int action, ...@@ -65,13 +65,15 @@ static void trace_note(struct blk_trace *bt, pid_t pid, int action,
{ {
struct blk_io_trace *t; struct blk_io_trace *t;
struct ring_buffer_event *event = NULL; struct ring_buffer_event *event = NULL;
struct ring_buffer *buffer = NULL;
int pc = 0; int pc = 0;
int cpu = smp_processor_id(); int cpu = smp_processor_id();
bool blk_tracer = blk_tracer_enabled; bool blk_tracer = blk_tracer_enabled;
if (blk_tracer) { if (blk_tracer) {
buffer = blk_tr->buffer;
pc = preempt_count(); pc = preempt_count();
event = trace_buffer_lock_reserve(blk_tr, TRACE_BLK, event = trace_buffer_lock_reserve(buffer, TRACE_BLK,
sizeof(*t) + len, sizeof(*t) + len,
0, pc); 0, pc);
if (!event) if (!event)
...@@ -96,7 +98,7 @@ static void trace_note(struct blk_trace *bt, pid_t pid, int action, ...@@ -96,7 +98,7 @@ static void trace_note(struct blk_trace *bt, pid_t pid, int action,
memcpy((void *) t + sizeof(*t), data, len); memcpy((void *) t + sizeof(*t), data, len);
if (blk_tracer) if (blk_tracer)
trace_buffer_unlock_commit(blk_tr, event, 0, pc); trace_buffer_unlock_commit(buffer, event, 0, pc);
} }
} }
...@@ -179,6 +181,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes, ...@@ -179,6 +181,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
{ {
struct task_struct *tsk = current; struct task_struct *tsk = current;
struct ring_buffer_event *event = NULL; struct ring_buffer_event *event = NULL;
struct ring_buffer *buffer = NULL;
struct blk_io_trace *t; struct blk_io_trace *t;
unsigned long flags = 0; unsigned long flags = 0;
unsigned long *sequence; unsigned long *sequence;
...@@ -204,8 +207,9 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes, ...@@ -204,8 +207,9 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
if (blk_tracer) { if (blk_tracer) {
tracing_record_cmdline(current); tracing_record_cmdline(current);
buffer = blk_tr->buffer;
pc = preempt_count(); pc = preempt_count();
event = trace_buffer_lock_reserve(blk_tr, TRACE_BLK, event = trace_buffer_lock_reserve(buffer, TRACE_BLK,
sizeof(*t) + pdu_len, sizeof(*t) + pdu_len,
0, pc); 0, pc);
if (!event) if (!event)
...@@ -252,7 +256,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes, ...@@ -252,7 +256,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
memcpy((void *) t + sizeof(*t), pdu_data, pdu_len); memcpy((void *) t + sizeof(*t), pdu_data, pdu_len);
if (blk_tracer) { if (blk_tracer) {
trace_buffer_unlock_commit(blk_tr, event, 0, pc); trace_buffer_unlock_commit(buffer, event, 0, pc);
return; return;
} }
} }
......
This diff is collapsed.
...@@ -415,12 +415,13 @@ void init_tracer_sysprof_debugfs(struct dentry *d_tracer); ...@@ -415,12 +415,13 @@ void init_tracer_sysprof_debugfs(struct dentry *d_tracer);
struct ring_buffer_event; struct ring_buffer_event;
struct ring_buffer_event *trace_buffer_lock_reserve(struct trace_array *tr, struct ring_buffer_event *
int type, trace_buffer_lock_reserve(struct ring_buffer *buffer,
unsigned long len, int type,
unsigned long flags, unsigned long len,
int pc); unsigned long flags,
void trace_buffer_unlock_commit(struct trace_array *tr, int pc);
void trace_buffer_unlock_commit(struct ring_buffer *buffer,
struct ring_buffer_event *event, struct ring_buffer_event *event,
unsigned long flags, int pc); unsigned long flags, int pc);
...@@ -481,10 +482,10 @@ void update_max_tr_single(struct trace_array *tr, ...@@ -481,10 +482,10 @@ void update_max_tr_single(struct trace_array *tr,
#endif /* CONFIG_TRACER_MAX_TRACE */ #endif /* CONFIG_TRACER_MAX_TRACE */
#ifdef CONFIG_STACKTRACE #ifdef CONFIG_STACKTRACE
void ftrace_trace_stack(struct trace_array *tr, unsigned long flags, void ftrace_trace_stack(struct ring_buffer *buffer, unsigned long flags,
int skip, int pc); int skip, int pc);
void ftrace_trace_userstack(struct trace_array *tr, unsigned long flags, void ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags,
int pc); int pc);
void __trace_stack(struct trace_array *tr, unsigned long flags, int skip, void __trace_stack(struct trace_array *tr, unsigned long flags, int skip,
......
...@@ -130,6 +130,7 @@ struct tracer boot_tracer __read_mostly = ...@@ -130,6 +130,7 @@ struct tracer boot_tracer __read_mostly =
void trace_boot_call(struct boot_trace_call *bt, initcall_t fn) void trace_boot_call(struct boot_trace_call *bt, initcall_t fn)
{ {
struct ring_buffer_event *event; struct ring_buffer_event *event;
struct ring_buffer *buffer;
struct trace_boot_call *entry; struct trace_boot_call *entry;
struct trace_array *tr = boot_trace; struct trace_array *tr = boot_trace;
...@@ -142,13 +143,14 @@ void trace_boot_call(struct boot_trace_call *bt, initcall_t fn) ...@@ -142,13 +143,14 @@ void trace_boot_call(struct boot_trace_call *bt, initcall_t fn)
sprint_symbol(bt->func, (unsigned long)fn); sprint_symbol(bt->func, (unsigned long)fn);
preempt_disable(); preempt_disable();
event = trace_buffer_lock_reserve(tr, TRACE_BOOT_CALL, buffer = tr->buffer;
event = trace_buffer_lock_reserve(buffer, TRACE_BOOT_CALL,
sizeof(*entry), 0, 0); sizeof(*entry), 0, 0);
if (!event) if (!event)
goto out; goto out;
entry = ring_buffer_event_data(event); entry = ring_buffer_event_data(event);
entry->boot_call = *bt; entry->boot_call = *bt;
trace_buffer_unlock_commit(tr, event, 0, 0); trace_buffer_unlock_commit(buffer, event, 0, 0);
out: out:
preempt_enable(); preempt_enable();
} }
...@@ -156,6 +158,7 @@ void trace_boot_call(struct boot_trace_call *bt, initcall_t fn) ...@@ -156,6 +158,7 @@ void trace_boot_call(struct boot_trace_call *bt, initcall_t fn)
void trace_boot_ret(struct boot_trace_ret *bt, initcall_t fn) void trace_boot_ret(struct boot_trace_ret *bt, initcall_t fn)
{ {
struct ring_buffer_event *event; struct ring_buffer_event *event;
struct ring_buffer *buffer;
struct trace_boot_ret *entry; struct trace_boot_ret *entry;
struct trace_array *tr = boot_trace; struct trace_array *tr = boot_trace;
...@@ -165,13 +168,14 @@ void trace_boot_ret(struct boot_trace_ret *bt, initcall_t fn) ...@@ -165,13 +168,14 @@ void trace_boot_ret(struct boot_trace_ret *bt, initcall_t fn)
sprint_symbol(bt->func, (unsigned long)fn); sprint_symbol(bt->func, (unsigned long)fn);
preempt_disable(); preempt_disable();
event = trace_buffer_lock_reserve(tr, TRACE_BOOT_RET, buffer = tr->buffer;
event = trace_buffer_lock_reserve(buffer, TRACE_BOOT_RET,
sizeof(*entry), 0, 0); sizeof(*entry), 0, 0);
if (!event) if (!event)
goto out; goto out;
entry = ring_buffer_event_data(event); entry = ring_buffer_event_data(event);
entry->boot_ret = *bt; entry->boot_ret = *bt;
trace_buffer_unlock_commit(tr, event, 0, 0); trace_buffer_unlock_commit(buffer, event, 0, 0);
out: out:
preempt_enable(); preempt_enable();
} }
...@@ -1438,6 +1438,7 @@ static void ...@@ -1438,6 +1438,7 @@ static void
function_test_events_call(unsigned long ip, unsigned long parent_ip) function_test_events_call(unsigned long ip, unsigned long parent_ip)
{ {
struct ring_buffer_event *event; struct ring_buffer_event *event;
struct ring_buffer *buffer;
struct ftrace_entry *entry; struct ftrace_entry *entry;
unsigned long flags; unsigned long flags;
long disabled; long disabled;
...@@ -1455,7 +1456,8 @@ function_test_events_call(unsigned long ip, unsigned long parent_ip) ...@@ -1455,7 +1456,8 @@ function_test_events_call(unsigned long ip, unsigned long parent_ip)
local_save_flags(flags); local_save_flags(flags);
event = trace_current_buffer_lock_reserve(TRACE_FN, sizeof(*entry), event = trace_current_buffer_lock_reserve(&buffer,
TRACE_FN, sizeof(*entry),
flags, pc); flags, pc);
if (!event) if (!event)
goto out; goto out;
...@@ -1463,7 +1465,7 @@ function_test_events_call(unsigned long ip, unsigned long parent_ip) ...@@ -1463,7 +1465,7 @@ function_test_events_call(unsigned long ip, unsigned long parent_ip)
entry->ip = ip; entry->ip = ip;
entry->parent_ip = parent_ip; entry->parent_ip = parent_ip;
trace_nowake_buffer_unlock_commit(event, flags, pc); trace_nowake_buffer_unlock_commit(buffer, event, flags, pc);
out: out:
atomic_dec(&per_cpu(test_event_disable, cpu)); atomic_dec(&per_cpu(test_event_disable, cpu));
......
...@@ -173,19 +173,20 @@ static int __trace_graph_entry(struct trace_array *tr, ...@@ -173,19 +173,20 @@ static int __trace_graph_entry(struct trace_array *tr,
{ {
struct ftrace_event_call *call = &event_funcgraph_entry; struct ftrace_event_call *call = &event_funcgraph_entry;
struct ring_buffer_event *event; struct ring_buffer_event *event;
struct ring_buffer *buffer = tr->buffer;
struct ftrace_graph_ent_entry *entry; struct ftrace_graph_ent_entry *entry;
if (unlikely(local_read(&__get_cpu_var(ftrace_cpu_disabled)))) if (unlikely(local_read(&__get_cpu_var(ftrace_cpu_disabled))))
return 0; return 0;
event = trace_buffer_lock_reserve(tr, TRACE_GRAPH_ENT, event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_ENT,
sizeof(*entry), flags, pc); sizeof(*entry), flags, pc);
if (!event) if (!event)
return 0; return 0;
entry = ring_buffer_event_data(event); entry = ring_buffer_event_data(event);
entry->graph_ent = *trace; entry->graph_ent = *trace;
if (!filter_current_check_discard(call, entry, event)) if (!filter_current_check_discard(buffer, call, entry, event))
ring_buffer_unlock_commit(tr->buffer, event); ring_buffer_unlock_commit(buffer, event);
return 1; return 1;
} }
...@@ -236,19 +237,20 @@ static void __trace_graph_return(struct trace_array *tr, ...@@ -236,19 +237,20 @@ static void __trace_graph_return(struct trace_array *tr,
{ {
struct ftrace_event_call *call = &event_funcgraph_exit; struct ftrace_event_call *call = &event_funcgraph_exit;
struct ring_buffer_event *event; struct ring_buffer_event *event;
struct ring_buffer *buffer = tr->buffer;
struct ftrace_graph_ret_entry *entry; struct ftrace_graph_ret_entry *entry;
if (unlikely(local_read(&__get_cpu_var(ftrace_cpu_disabled)))) if (unlikely(local_read(&__get_cpu_var(ftrace_cpu_disabled))))
return; return;
event = trace_buffer_lock_reserve(tr, TRACE_GRAPH_RET, event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_RET,
sizeof(*entry), flags, pc); sizeof(*entry), flags, pc);
if (!event) if (!event)
return; return;
entry = ring_buffer_event_data(event); entry = ring_buffer_event_data(event);
entry->ret = *trace; entry->ret = *trace;
if (!filter_current_check_discard(call, entry, event)) if (!filter_current_check_discard(buffer, call, entry, event))
ring_buffer_unlock_commit(tr->buffer, event); ring_buffer_unlock_commit(buffer, event);
} }
void trace_graph_return(struct ftrace_graph_ret *trace) void trace_graph_return(struct ftrace_graph_ret *trace)
......
...@@ -307,11 +307,12 @@ static void __trace_mmiotrace_rw(struct trace_array *tr, ...@@ -307,11 +307,12 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
struct trace_array_cpu *data, struct trace_array_cpu *data,
struct mmiotrace_rw *rw) struct mmiotrace_rw *rw)
{ {
struct ring_buffer *buffer = tr->buffer;
struct ring_buffer_event *event; struct ring_buffer_event *event;
struct trace_mmiotrace_rw *entry; struct trace_mmiotrace_rw *entry;
int pc = preempt_count(); int pc = preempt_count();
event = trace_buffer_lock_reserve(tr, TRACE_MMIO_RW, event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
sizeof(*entry), 0, pc); sizeof(*entry), 0, pc);
if (!event) { if (!event) {
atomic_inc(&dropped_count); atomic_inc(&dropped_count);
...@@ -319,7 +320,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr, ...@@ -319,7 +320,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
} }
entry = ring_buffer_event_data(event); entry = ring_buffer_event_data(event);
entry->rw = *rw; entry->rw = *rw;
trace_buffer_unlock_commit(tr, event, 0, pc); trace_buffer_unlock_commit(buffer, event, 0, pc);
} }
void mmio_trace_rw(struct mmiotrace_rw *rw) void mmio_trace_rw(struct mmiotrace_rw *rw)
...@@ -333,11 +334,12 @@ static void __trace_mmiotrace_map(struct trace_array *tr, ...@@ -333,11 +334,12 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
struct trace_array_cpu *data, struct trace_array_cpu *data,
struct mmiotrace_map *map) struct mmiotrace_map *map)
{ {
struct ring_buffer *buffer = tr->buffer;
struct ring_buffer_event *event; struct ring_buffer_event *event;
struct trace_mmiotrace_map *entry; struct trace_mmiotrace_map *entry;
int pc = preempt_count(); int pc = preempt_count();
event = trace_buffer_lock_reserve(tr, TRACE_MMIO_MAP, event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
sizeof(*entry), 0, pc); sizeof(*entry), 0, pc);
if (!event) { if (!event) {
atomic_inc(&dropped_count); atomic_inc(&dropped_count);
...@@ -345,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr, ...@@ -345,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
} }
entry = ring_buffer_event_data(event); entry = ring_buffer_event_data(event);
entry->map = *map; entry->map = *map;
trace_buffer_unlock_commit(tr, event, 0, pc); trace_buffer_unlock_commit(buffer, event, 0, pc);
} }
void mmio_trace_mapping(struct mmiotrace_map *map) void mmio_trace_mapping(struct mmiotrace_map *map)
......
...@@ -38,6 +38,7 @@ static void probe_power_end(struct power_trace *it) ...@@ -38,6 +38,7 @@ static void probe_power_end(struct power_trace *it)
{ {
struct ftrace_event_call *call = &event_power; struct ftrace_event_call *call = &event_power;
struct ring_buffer_event *event; struct ring_buffer_event *event;
struct ring_buffer *buffer;
struct trace_power *entry; struct trace_power *entry;
struct trace_array_cpu *data; struct trace_array_cpu *data;
struct trace_array *tr = power_trace; struct trace_array *tr = power_trace;
...@@ -45,18 +46,20 @@ static void probe_power_end(struct power_trace *it) ...@@ -45,18 +46,20 @@ static void probe_power_end(struct power_trace *it)
if (!trace_power_enabled) if (!trace_power_enabled)
return; return;
buffer = tr->buffer;
preempt_disable(); preempt_disable();
it->end = ktime_get(); it->end = ktime_get();
data = tr->data[smp_processor_id()]; data = tr->data[smp_processor_id()];
event = trace_buffer_lock_reserve(tr, TRACE_POWER, event = trace_buffer_lock_reserve(buffer, TRACE_POWER,
sizeof(*entry), 0, 0); sizeof(*entry), 0, 0);
if (!event) if (!event)
goto out; goto out;
entry = ring_buffer_event_data(event); entry = ring_buffer_event_data(event);
entry->state_data = *it; entry->state_data = *it;
if (!filter_check_discard(call, entry, tr->buffer, event)) if (!filter_check_discard(call, entry, buffer, event))
trace_buffer_unlock_commit(tr, event, 0, 0); trace_buffer_unlock_commit(buffer, event, 0, 0);
out: out:
preempt_enable(); preempt_enable();
} }
...@@ -66,6 +69,7 @@ static void probe_power_mark(struct power_trace *it, unsigned int type, ...@@ -66,6 +69,7 @@ static void probe_power_mark(struct power_trace *it, unsigned int type,
{ {
struct ftrace_event_call *call = &event_power; struct ftrace_event_call *call = &event_power;
struct ring_buffer_event *event; struct ring_buffer_event *event;
struct ring_buffer *buffer;
struct trace_power *entry; struct trace_power *entry;
struct trace_array_cpu *data; struct trace_array_cpu *data;
struct trace_array *tr = power_trace; struct trace_array *tr = power_trace;
...@@ -73,6 +77,8 @@ static void probe_power_mark(struct power_trace *it, unsigned int type, ...@@ -73,6 +77,8 @@ static void probe_power_mark(struct power_trace *it, unsigned int type,
if (!trace_power_enabled) if (!trace_power_enabled)
return; return;
buffer = tr->buffer;
memset(it, 0, sizeof(struct power_trace)); memset(it, 0, sizeof(struct power_trace));
it->state = level; it->state = level;
it->type = type; it->type = type;
...@@ -81,14 +87,14 @@ static void probe_power_mark(struct power_trace *it, unsigned int type, ...@@ -81,14 +87,14 @@ static void probe_power_mark(struct power_trace *it, unsigned int type,
it->end = it->stamp; it->end = it->stamp;
data = tr->data[smp_processor_id()]; data = tr->data[smp_processor_id()];
event = trace_buffer_lock_reserve(tr, TRACE_POWER, event = trace_buffer_lock_reserve(buffer, TRACE_POWER,
sizeof(*entry), 0, 0); sizeof(*entry), 0, 0);
if (!event) if (!event)
goto out; goto out;
entry = ring_buffer_event_data(event); entry = ring_buffer_event_data(event);
entry->state_data = *it; entry->state_data = *it;
if (!filter_check_discard(call, entry, tr->buffer, event)) if (!filter_check_discard(call, entry, buffer, event))
trace_buffer_unlock_commit(tr, event, 0, 0); trace_buffer_unlock_commit(buffer, event, 0, 0);
out: out:
preempt_enable(); preempt_enable();
} }
......
...@@ -28,10 +28,11 @@ tracing_sched_switch_trace(struct trace_array *tr, ...@@ -28,10 +28,11 @@ tracing_sched_switch_trace(struct trace_array *tr,
unsigned long flags, int pc) unsigned long flags, int pc)
{ {
struct ftrace_event_call *call = &event_context_switch; struct ftrace_event_call *call = &event_context_switch;
struct ring_buffer *buffer = tr->buffer;
struct ring_buffer_event *event; struct ring_buffer_event *event;
struct ctx_switch_entry *entry; struct ctx_switch_entry *entry;
event = trace_buffer_lock_reserve(tr, TRACE_CTX, event = trace_buffer_lock_reserve(buffer, TRACE_CTX,
sizeof(*entry), flags, pc); sizeof(*entry), flags, pc);
if (!event) if (!event)
return; return;
...@@ -44,8 +45,8 @@ tracing_sched_switch_trace(struct trace_array *tr, ...@@ -44,8 +45,8 @@ tracing_sched_switch_trace(struct trace_array *tr,
entry->next_state = next->state; entry->next_state = next->state;
entry->next_cpu = task_cpu(next); entry->next_cpu = task_cpu(next);
if (!filter_check_discard(call, entry, tr->buffer, event)) if (!filter_check_discard(call, entry, buffer, event))
trace_buffer_unlock_commit(tr, event, flags, pc); trace_buffer_unlock_commit(buffer, event, flags, pc);
} }
static void static void
...@@ -86,8 +87,9 @@ tracing_sched_wakeup_trace(struct trace_array *tr, ...@@ -86,8 +87,9 @@ tracing_sched_wakeup_trace(struct trace_array *tr,
struct ftrace_event_call *call = &event_wakeup; struct ftrace_event_call *call = &event_wakeup;
struct ring_buffer_event *event; struct ring_buffer_event *event;
struct ctx_switch_entry *entry; struct ctx_switch_entry *entry;
struct ring_buffer *buffer = tr->buffer;
event = trace_buffer_lock_reserve(tr, TRACE_WAKE, event = trace_buffer_lock_reserve(buffer, TRACE_WAKE,
sizeof(*entry), flags, pc); sizeof(*entry), flags, pc);
if (!event) if (!event)
return; return;
...@@ -100,10 +102,10 @@ tracing_sched_wakeup_trace(struct trace_array *tr, ...@@ -100,10 +102,10 @@ tracing_sched_wakeup_trace(struct trace_array *tr,
entry->next_state = wakee->state; entry->next_state = wakee->state;
entry->next_cpu = task_cpu(wakee); entry->next_cpu = task_cpu(wakee);
if (!filter_check_discard(call, entry, tr->buffer, event)) if (!filter_check_discard(call, entry, buffer, event))
ring_buffer_unlock_commit(tr->buffer, event); ring_buffer_unlock_commit(buffer, event);
ftrace_trace_stack(tr, flags, 6, pc); ftrace_trace_stack(tr->buffer, flags, 6, pc);
ftrace_trace_userstack(tr, flags, pc); ftrace_trace_userstack(tr->buffer, flags, pc);
} }
static void static void
......
...@@ -223,6 +223,7 @@ void ftrace_syscall_enter(struct pt_regs *regs, long id) ...@@ -223,6 +223,7 @@ void ftrace_syscall_enter(struct pt_regs *regs, long id)
struct syscall_trace_enter *entry; struct syscall_trace_enter *entry;
struct syscall_metadata *sys_data; struct syscall_metadata *sys_data;
struct ring_buffer_event *event; struct ring_buffer_event *event;
struct ring_buffer *buffer;
int size; int size;
int syscall_nr; int syscall_nr;
...@@ -238,8 +239,8 @@ void ftrace_syscall_enter(struct pt_regs *regs, long id) ...@@ -238,8 +239,8 @@ void ftrace_syscall_enter(struct pt_regs *regs, long id)
size = sizeof(*entry) + sizeof(unsigned long) * sys_data->nb_args; size = sizeof(*entry) + sizeof(unsigned long) * sys_data->nb_args;
event = trace_current_buffer_lock_reserve(sys_data->enter_id, size, event = trace_current_buffer_lock_reserve(&buffer, sys_data->enter_id,
0, 0); size, 0, 0);
if (!event) if (!event)
return; return;
...@@ -247,8 +248,9 @@ void ftrace_syscall_enter(struct pt_regs *regs, long id) ...@@ -247,8 +248,9 @@ void ftrace_syscall_enter(struct pt_regs *regs, long id)
entry->nr = syscall_nr; entry->nr = syscall_nr;
syscall_get_arguments(current, regs, 0, sys_data->nb_args, entry->args); syscall_get_arguments(current, regs, 0, sys_data->nb_args, entry->args);
if (!filter_current_check_discard(sys_data->enter_event, entry, event)) if (!filter_current_check_discard(buffer, sys_data->enter_event,
trace_current_buffer_unlock_commit(event, 0, 0); entry, event))
trace_current_buffer_unlock_commit(buffer, event, 0, 0);
} }
void ftrace_syscall_exit(struct pt_regs *regs, long ret) void ftrace_syscall_exit(struct pt_regs *regs, long ret)
...@@ -256,6 +258,7 @@ void ftrace_syscall_exit(struct pt_regs *regs, long ret) ...@@ -256,6 +258,7 @@ void ftrace_syscall_exit(struct pt_regs *regs, long ret)
struct syscall_trace_exit *entry; struct syscall_trace_exit *entry;
struct syscall_metadata *sys_data; struct syscall_metadata *sys_data;
struct ring_buffer_event *event; struct ring_buffer_event *event;
struct ring_buffer *buffer;
int syscall_nr; int syscall_nr;
syscall_nr = syscall_get_nr(current, regs); syscall_nr = syscall_get_nr(current, regs);
...@@ -268,7 +271,7 @@ void ftrace_syscall_exit(struct pt_regs *regs, long ret) ...@@ -268,7 +271,7 @@ void ftrace_syscall_exit(struct pt_regs *regs, long ret)
if (!sys_data) if (!sys_data)
return; return;
event = trace_current_buffer_lock_reserve(sys_data->exit_id, event = trace_current_buffer_lock_reserve(&buffer, sys_data->exit_id,
sizeof(*entry), 0, 0); sizeof(*entry), 0, 0);
if (!event) if (!event)
return; return;
...@@ -277,8 +280,9 @@ void ftrace_syscall_exit(struct pt_regs *regs, long ret) ...@@ -277,8 +280,9 @@ void ftrace_syscall_exit(struct pt_regs *regs, long ret)
entry->nr = syscall_nr; entry->nr = syscall_nr;
entry->ret = syscall_get_return_value(current, regs); entry->ret = syscall_get_return_value(current, regs);
if (!filter_current_check_discard(sys_data->exit_event, entry, event)) if (!filter_current_check_discard(buffer, sys_data->exit_event,
trace_current_buffer_unlock_commit(event, 0, 0); entry, event))
trace_current_buffer_unlock_commit(buffer, event, 0, 0);
} }
int reg_event_syscall_enter(void *ptr) int reg_event_syscall_enter(void *ptr)
......
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