From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <peterz@infradead.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Wu Fengguang <fengguang.wu@intel.com>,
Pierre Ossman <drzeus@drzeus.cx>, Pekka Paalanen <pq@iki.fi>,
Steven Rostedt <srostedt@redhat.com>
Subject: [PATCH 3/4] tracing: fix trace_wait to know to wait on all cpus or just one
Date: Wed, 11 Mar 2009 22:37:23 -0400 [thread overview]
Message-ID: <20090312023936.459886746@goodmis.org> (raw)
In-Reply-To: 20090312023720.144716747@goodmis.org
[-- Attachment #1: 0003-tracing-fix-trace_wait-to-know-to-wait-on-all-cpus.patch --]
[-- Type: text/plain, Size: 1722 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
Impact: fix to task live locking on reading trace_pipe on one CPU
The same code is used for both trace_pipe (all CPUS) and the per_cpu
trace_pipe file. When there is no data to read, it will check for
signals and wait on the trace wait queue.
The problem happens with the per_cpu wait. The trace_wait code checks
all CPUs. Thus, if there's data in another CPU buffer, then it will
exit the wait, without checking for signals or waiting on the wait queue.
It would then try to read the empty buffer, and since that will just
return nothing, then it will try to wait again. Unfortunately, that will
again fail due to there still being data in the other buffers. This
ends up with a live lock for the task.
This patch fixes the trace_wait to be aware that the iterator may only
be waiting on a single buffer.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
kernel/trace/trace.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 35ee63a..e60f4be 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1666,6 +1666,19 @@ static int trace_empty(struct trace_iterator *iter)
{
int cpu;
+ /* If we are looking at one CPU buffer, only check that one */
+ if (iter->cpu_file != TRACE_PIPE_ALL_CPU) {
+ cpu = iter->cpu_file;
+ if (iter->buffer_iter[cpu]) {
+ if (!ring_buffer_iter_empty(iter->buffer_iter[cpu]))
+ return 0;
+ } else {
+ if (!ring_buffer_empty_cpu(iter->tr->buffer, cpu))
+ return 0;
+ }
+ return 1;
+ }
+
for_each_tracing_cpu(cpu) {
if (iter->buffer_iter[cpu]) {
if (!ring_buffer_iter_empty(iter->buffer_iter[cpu]))
--
1.6.1.3
--
next prev parent reply other threads:[~2009-03-12 2:40 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-12 2:37 [PATCH 0/4] [GIT PULL] memory saving ring buffer for tip/tracing/ftrace Steven Rostedt
2009-03-12 2:37 ` [PATCH 1/4] tracing: keep ring buffer to minimum size till used Steven Rostedt
2009-03-12 3:26 ` Andrew Morton
2009-03-12 13:25 ` Steven Rostedt
2009-03-12 15:01 ` Frederic Weisbecker
2009-03-12 15:14 ` Steven Rostedt
2009-03-12 2:37 ` [PATCH 2/4] tracing: expand the ring buffers when an event is activated Steven Rostedt
2009-03-12 2:37 ` Steven Rostedt [this message]
2009-03-12 2:37 ` [PATCH 4/4] ring-buffer: only allocate buffers for online cpus Steven Rostedt
2009-03-12 3:32 ` Andrew Morton
2009-03-12 13:29 ` Steven Rostedt
2009-03-12 7:31 ` KOSAKI Motohiro
2009-03-12 13:38 ` Steven Rostedt
2009-03-12 23:47 ` KOSAKI Motohiro
2009-03-12 7:07 ` [PATCH 0/4] [GIT PULL] memory saving ring buffer for tip/tracing/ftrace Pierre Ossman
2009-03-12 7:34 ` KOSAKI Motohiro
2009-03-12 9:20 ` Pierre Ossman
2009-03-12 13:39 ` Steven Rostedt
2009-03-12 10:47 ` Neil Horman
2009-03-12 12:12 ` Pierre Ossman
2009-03-12 13:12 ` Neil Horman
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=20090312023936.459886746@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=drzeus@drzeus.cx \
--cc=fengguang.wu@intel.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=pq@iki.fi \
--cc=srostedt@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox