Skip to content

Commit

Permalink
tracing/events: don't discard an event after commit
Browse files Browse the repository at this point in the history
When we want to filter an event, the filter test is done after
the event is commited to the ring-buffer to be discarded later if
needed.

But a reader could be reading this event while we are trying to discard
it. Other kind of racy events can even happen because the event is
commited and can be read and/or consumed.

What we want is to discard the event before committing it.

Reported-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <1237763919-21505-1-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Frederic Weisbecker authored and Ingo Molnar committed Mar 23, 2009
1 parent 7e6ea92 commit b118415
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kernel/trace/trace_events_stage_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,11 @@ static void ftrace_raw_event_##call(proto) \
\
assign; \
\
trace_nowake_buffer_unlock_commit(event, irq_flags, pc); \
\
if (call->preds && !filter_match_preds(call, entry)) \
ring_buffer_event_discard(event); \
\
trace_nowake_buffer_unlock_commit(event, irq_flags, pc); \
\
} \
\
static int ftrace_raw_reg_event_##call(void) \
Expand Down

0 comments on commit b118415

Please sign in to comment.