All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: [PATCH 4/5] tracing/events: don't use wake up for events
Date: Sun, 22 Mar 2009 23:10:46 +0100	[thread overview]
Message-ID: <1237759847-21025-4-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <1237759847-21025-1-git-send-email-fweisbec@gmail.com>

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>
---
 kernel/trace/trace.c                |   26 +++++++++++++++++++++-----
 kernel/trace/trace.h                |    2 ++
 kernel/trace/trace_events_stage_3.h |    2 +-
 3 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index f0e1337..8dddb42 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -860,15 +860,25 @@ static void ftrace_trace_stack(struct trace_array *tr,
 static void ftrace_trace_userstack(struct trace_array *tr,
 				   unsigned long flags, int pc);
 
-void trace_buffer_unlock_commit(struct trace_array *tr,
-				struct ring_buffer_event *event,
-				unsigned long flags, int pc)
+static inline void __trace_buffer_unlock_commit(struct trace_array *tr,
+					struct ring_buffer_event *event,
+					unsigned long flags, int pc,
+					int wake)
 {
 	ring_buffer_unlock_commit(tr->buffer, event);
 
 	ftrace_trace_stack(tr, flags, 6, pc);
 	ftrace_trace_userstack(tr, flags, pc);
-	trace_wake_up();
+
+	if (wake)
+		trace_wake_up();
+}
+
+void trace_buffer_unlock_commit(struct trace_array *tr,
+					struct ring_buffer_event *event,
+					unsigned long flags, int pc)
+{
+	__trace_buffer_unlock_commit(tr, event, flags, pc, 1);
 }
 
 struct ring_buffer_event *
@@ -882,7 +892,13 @@ trace_current_buffer_lock_reserve(unsigned char type, unsigned long len,
 void trace_current_buffer_unlock_commit(struct ring_buffer_event *event,
 					unsigned long flags, int pc)
 {
-	return trace_buffer_unlock_commit(&global_trace, event, flags, pc);
+	return __trace_buffer_unlock_commit(&global_trace, event, flags, pc, 1);
+}
+
+void trace_nowake_buffer_unlock_commit(struct ring_buffer_event *event,
+					unsigned long flags, int pc)
+{
+	return __trace_buffer_unlock_commit(&global_trace, event, flags, pc, 0);
 }
 
 void
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index f267723..54fd9bc 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -483,6 +483,8 @@ trace_current_buffer_lock_reserve(unsigned char type, unsigned long len,
 				  unsigned long flags, int pc);
 void trace_current_buffer_unlock_commit(struct ring_buffer_event *event,
 					unsigned long flags, int pc);
+void trace_nowake_buffer_unlock_commit(struct ring_buffer_event *event,
+					unsigned long flags, int pc);
 
 struct trace_entry *tracing_get_trace_entry(struct trace_array *tr,
 						struct trace_array_cpu *data);
diff --git a/kernel/trace/trace_events_stage_3.h b/kernel/trace/trace_events_stage_3.h
index ebf215e..9a3bd49 100644
--- a/kernel/trace/trace_events_stage_3.h
+++ b/kernel/trace/trace_events_stage_3.h
@@ -222,7 +222,7 @@ static void ftrace_raw_event_##call(proto)				\
 									\
 	assign;								\
 									\
-	trace_current_buffer_unlock_commit(event, irq_flags, pc);	\
+	trace_nowake_buffer_unlock_commit(event, irq_flags, pc);	\
 									\
 	if (call->preds && !filter_match_preds(call, entry))		\
 		ring_buffer_event_discard(event);			\
-- 
1.6.1


  parent reply	other threads:[~2009-03-22 22:12 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-22 22:10 [PATCH 1/5] tracing/events: make the filter files writable Frederic Weisbecker
2009-03-22 22:10 ` [PATCH 2/5] debugfs: function to know if debugfs is initialized Frederic Weisbecker
2009-03-23  8:18   ` Ingo Molnar
2009-03-23 14:41     ` Greg KH
2009-03-23 16:08       ` Ingo Molnar
2009-03-23 15:57   ` [tip:tracing/ftrace] " Frederic Weisbecker
2009-03-22 22:10 ` [PATCH 3/5] tracing/ftrace: check if debugfs is registered before creating files Frederic Weisbecker
2009-03-23  8:26   ` Ingo Molnar
2009-03-23 15:57   ` [tip:tracing/ftrace] " Frederic Weisbecker
2009-03-23 19:18   ` [PATCH 3/5] " Steven Rostedt
2009-03-23 19:22     ` Ingo Molnar
2009-03-23 19:47     ` Frederic Weisbecker
2009-03-22 22:10 ` Frederic Weisbecker [this message]
2009-03-23  8:30   ` [tip:tracing/filters] tracing/events: don't use wake up for events Frederic Weisbecker
2009-03-23 19:21     ` Steven Rostedt
2009-03-23 19:33       ` Frederic Weisbecker
2009-03-22 22:10 ` [PATCH 5/5] tracing/ftrace: make nop using polling wait for events on pipe Frederic Weisbecker
2009-03-23  8:31   ` [tip:tracing/filters] tracing/ftrace: make nop-tracer use " Frederic Weisbecker
2009-03-22 22:12 ` [PATCH 1/5] tracing/events: make the filter files writable Frederic Weisbecker
2009-03-23  8:25 ` Ingo Molnar
2009-03-23  8:31   ` Frederic Weisbecker
2009-03-23  8:30 ` [tip:tracing/filters] " Frederic Weisbecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1237759847-21025-4-git-send-email-fweisbec@gmail.com \
    --to=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.