diff options
author | Steven Rostedt <srostedt@redhat.com> | 2013-02-28 13:44:11 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2013-03-15 00:34:49 -0400 |
commit | b627344fef0c38fa4e3050348e168e46db87c905 (patch) | |
tree | d828a640959fcb39667cbc56cd7cf8e75f34636f /kernel/trace | |
parent | cc60cdc952be09bca5b0bff9fefc7aa6185c3049 (diff) |
tracing: Fix read blocking on trace_pipe_raw
If the ring buffer is empty, a read to trace_pipe_raw wont block.
The tracing code has the infrastructure to wake up waiting readers,
but the trace_pipe_raw doesn't take advantage of that.
When a read is done to trace_pipe_raw without the O_NONBLOCK flag
set, have the read block until there's data in the requested buffer.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/trace.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 4a6e461273a9..3ec146c96df4 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -4389,6 +4389,7 @@ static int tracing_buffers_open(struct inode *inode, struct file *filp) | |||
4389 | 4389 | ||
4390 | info->iter.tr = tr; | 4390 | info->iter.tr = tr; |
4391 | info->iter.cpu_file = tc->cpu; | 4391 | info->iter.cpu_file = tc->cpu; |
4392 | info->iter.trace = tr->current_trace; | ||
4392 | info->spare = NULL; | 4393 | info->spare = NULL; |
4393 | /* Force reading ring buffer for first read */ | 4394 | /* Force reading ring buffer for first read */ |
4394 | info->read = (unsigned int)-1; | 4395 | info->read = (unsigned int)-1; |
@@ -4428,18 +4429,29 @@ tracing_buffers_read(struct file *filp, char __user *ubuf, | |||
4428 | if (info->read < PAGE_SIZE) | 4429 | if (info->read < PAGE_SIZE) |
4429 | goto read; | 4430 | goto read; |
4430 | 4431 | ||
4432 | again: | ||
4431 | trace_access_lock(iter->cpu_file); | 4433 | trace_access_lock(iter->cpu_file); |
4432 | ret = ring_buffer_read_page(iter->tr->buffer, | 4434 | ret = ring_buffer_read_page(iter->tr->buffer, |
4433 | &info->spare, | 4435 | &info->spare, |
4434 | count, | 4436 | count, |
4435 | iter->cpu_file, 0); | 4437 | iter->cpu_file, 0); |
4436 | trace_access_unlock(iter->cpu_file); | 4438 | trace_access_unlock(iter->cpu_file); |
4437 | if (ret < 0) | 4439 | |
4440 | if (ret < 0) { | ||
4441 | if (trace_empty(iter)) { | ||
4442 | if ((filp->f_flags & O_NONBLOCK)) | ||
4443 | return -EAGAIN; | ||
4444 | iter->trace->wait_pipe(iter); | ||
4445 | if (signal_pending(current)) | ||
4446 | return -EINTR; | ||
4447 | goto again; | ||
4448 | } | ||
4438 | return 0; | 4449 | return 0; |
4450 | } | ||
4439 | 4451 | ||
4440 | info->read = 0; | 4452 | info->read = 0; |
4441 | 4453 | ||
4442 | read: | 4454 | read: |
4443 | size = PAGE_SIZE - info->read; | 4455 | size = PAGE_SIZE - info->read; |
4444 | if (size > count) | 4456 | if (size > count) |
4445 | size = count; | 4457 | size = count; |
@@ -4616,7 +4628,7 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos, | |||
4616 | ret = -EAGAIN; | 4628 | ret = -EAGAIN; |
4617 | goto out; | 4629 | goto out; |
4618 | } | 4630 | } |
4619 | default_wait_pipe(iter); | 4631 | iter->trace->wait_pipe(iter); |
4620 | if (signal_pending(current)) { | 4632 | if (signal_pending(current)) { |
4621 | ret = -EINTR; | 4633 | ret = -EINTR; |
4622 | goto out; | 4634 | goto out; |