Commit 2c4a33ab authored by Steven Rostedt (Red Hat)'s avatar Steven Rostedt (Red Hat) Committed by Steven Rostedt

tracing: Fix traceon trigger condition to actually turn tracing on

While working on my tutorial for 2014 Linux Collaboration Summit
I found that the traceon trigger did not work when conditions were
used. The other triggers worked fine though. Looking into it, it
is because of the way the triggers use the ring buffer to store
the fields it will use for the condition. But if tracing is off, nothing
is stored in the buffer, and the tracepoint exits before calling the
trigger to test the condition. This is fine for all the triggers that
only work when tracing is on, but for traceon trigger that is to
work when tracing is off, nothing happens.

The fix is simple, just use a temp ring buffer to record the event
if tracing is off and the event has a trace event conditional trigger
enabled. The rest of the tracepoint code will work just fine, but
the tracepoint wont be recorded in the other buffers.

Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 87291347
...@@ -1600,15 +1600,31 @@ void trace_buffer_unlock_commit(struct ring_buffer *buffer, ...@@ -1600,15 +1600,31 @@ void trace_buffer_unlock_commit(struct ring_buffer *buffer,
} }
EXPORT_SYMBOL_GPL(trace_buffer_unlock_commit); EXPORT_SYMBOL_GPL(trace_buffer_unlock_commit);
static struct ring_buffer *temp_buffer;
struct ring_buffer_event * struct ring_buffer_event *
trace_event_buffer_lock_reserve(struct ring_buffer **current_rb, trace_event_buffer_lock_reserve(struct ring_buffer **current_rb,
struct ftrace_event_file *ftrace_file, struct ftrace_event_file *ftrace_file,
int type, unsigned long len, int type, unsigned long len,
unsigned long flags, int pc) unsigned long flags, int pc)
{ {
struct ring_buffer_event *entry;
*current_rb = ftrace_file->tr->trace_buffer.buffer; *current_rb = ftrace_file->tr->trace_buffer.buffer;
return trace_buffer_lock_reserve(*current_rb, entry = trace_buffer_lock_reserve(*current_rb,
type, len, flags, pc); type, len, flags, pc);
/*
* If tracing is off, but we have triggers enabled
* we still need to look at the event data. Use the temp_buffer
* to store the trace event for the tigger to use. It's recusive
* safe and will not be recorded anywhere.
*/
if (!entry && ftrace_file->flags & FTRACE_EVENT_FL_TRIGGER_COND) {
*current_rb = temp_buffer;
entry = trace_buffer_lock_reserve(*current_rb,
type, len, flags, pc);
}
return entry;
} }
EXPORT_SYMBOL_GPL(trace_event_buffer_lock_reserve); EXPORT_SYMBOL_GPL(trace_event_buffer_lock_reserve);
...@@ -6494,11 +6510,16 @@ __init static int tracer_alloc_buffers(void) ...@@ -6494,11 +6510,16 @@ __init static int tracer_alloc_buffers(void)
raw_spin_lock_init(&global_trace.start_lock); raw_spin_lock_init(&global_trace.start_lock);
/* Used for event triggers */
temp_buffer = ring_buffer_alloc(PAGE_SIZE, RB_FL_OVERWRITE);
if (!temp_buffer)
goto out_free_cpumask;
/* TODO: make the number of buffers hot pluggable with CPUS */ /* TODO: make the number of buffers hot pluggable with CPUS */
if (allocate_trace_buffers(&global_trace, ring_buf_size) < 0) { if (allocate_trace_buffers(&global_trace, ring_buf_size) < 0) {
printk(KERN_ERR "tracer: failed to allocate ring buffer!\n"); printk(KERN_ERR "tracer: failed to allocate ring buffer!\n");
WARN_ON(1); WARN_ON(1);
goto out_free_cpumask; goto out_free_temp_buffer;
} }
if (global_trace.buffer_disabled) if (global_trace.buffer_disabled)
...@@ -6540,6 +6561,8 @@ __init static int tracer_alloc_buffers(void) ...@@ -6540,6 +6561,8 @@ __init static int tracer_alloc_buffers(void)
return 0; return 0;
out_free_temp_buffer:
ring_buffer_free(temp_buffer);
out_free_cpumask: out_free_cpumask:
free_percpu(global_trace.trace_buffer.data); free_percpu(global_trace.trace_buffer.data);
#ifdef CONFIG_TRACER_MAX_TRACE #ifdef CONFIG_TRACER_MAX_TRACE
......
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