Skip to content

Commit 07edf71

Browse files
fweisbecIngo Molnar
authored andcommitted
tracing/events: don't use wake up for events
Impact: fix hard-lockup with sched switch events Some ftrace events, such as sched wakeup, can be traced while the runqueue lock is hold. Since they are using trace_current_buffer_unlock_commit(), they call wake_up() which can try to grab the runqueue lock too, resulting in a deadlock. Now for all event, we call a new helper: trace_nowake_buffer_unlock_commit() which do pretty the same than trace_current_buffer_unlock_commit() except than it doesn't call trace_wake_up(). Reported-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> LKML-Reference: <1237759847-21025-4-git-send-email-fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 9bd7d09 commit 07edf71

3 files changed

Lines changed: 24 additions & 6 deletions

File tree

‎kernel/trace/trace.c‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -860,15 +860,25 @@ static void ftrace_trace_stack(struct trace_array *tr,
860860
static void ftrace_trace_userstack(struct trace_array *tr,
861861
unsigned long flags, int pc);
862862

863-
void trace_buffer_unlock_commit(struct trace_array *tr,
864-
struct ring_buffer_event *event,
865-
unsigned long flags, int pc)
863+
static inline void __trace_buffer_unlock_commit(struct trace_array *tr,
864+
struct ring_buffer_event *event,
865+
unsigned long flags, int pc,
866+
int wake)
866867
{
867868
ring_buffer_unlock_commit(tr->buffer, event);
868869

869870
ftrace_trace_stack(tr, flags, 6, pc);
870871
ftrace_trace_userstack(tr, flags, pc);
871-
trace_wake_up();
872+
873+
if (wake)
874+
trace_wake_up();
875+
}
876+
877+
void trace_buffer_unlock_commit(struct trace_array *tr,
878+
struct ring_buffer_event *event,
879+
unsigned long flags, int pc)
880+
{
881+
__trace_buffer_unlock_commit(tr, event, flags, pc, 1);
872882
}
873883

874884
struct ring_buffer_event *
@@ -882,7 +892,13 @@ trace_current_buffer_lock_reserve(unsigned char type, unsigned long len,
882892
void trace_current_buffer_unlock_commit(struct ring_buffer_event *event,
883893
unsigned long flags, int pc)
884894
{
885-
return trace_buffer_unlock_commit(&global_trace, event, flags, pc);
895+
return __trace_buffer_unlock_commit(&global_trace, event, flags, pc, 1);
896+
}
897+
898+
void trace_nowake_buffer_unlock_commit(struct ring_buffer_event *event,
899+
unsigned long flags, int pc)
900+
{
901+
return __trace_buffer_unlock_commit(&global_trace, event, flags, pc, 0);
886902
}
887903

888904
void

‎kernel/trace/trace.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,8 @@ trace_current_buffer_lock_reserve(unsigned char type, unsigned long len,
483483
unsigned long flags, int pc);
484484
void trace_current_buffer_unlock_commit(struct ring_buffer_event *event,
485485
unsigned long flags, int pc);
486+
void trace_nowake_buffer_unlock_commit(struct ring_buffer_event *event,
487+
unsigned long flags, int pc);
486488

487489
struct trace_entry *tracing_get_trace_entry(struct trace_array *tr,
488490
struct trace_array_cpu *data);

‎kernel/trace/trace_events_stage_3.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static void ftrace_raw_event_##call(proto) \
222222
\
223223
assign; \
224224
\
225-
trace_current_buffer_unlock_commit(event, irq_flags, pc); \
225+
trace_nowake_buffer_unlock_commit(event, irq_flags, pc); \
226226
\
227227
if (call->preds && !filter_match_preds(call, entry)) \
228228
ring_buffer_event_discard(event); \

0 commit comments

Comments
 (0)