lkml.org 
[lkml]   [2013]   [Mar]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[for-next][PATCH 6/7] tracing: Fix read blocking on trace_pipe_raw
    From: Steven Rostedt <srostedt@redhat.com>

    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>
    ---
    kernel/trace/trace.c | 18 +++++++++++++++---
    1 file changed, 15 insertions(+), 3 deletions(-)

    diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
    index b958e9d..32b003c 100644
    --- a/kernel/trace/trace.c
    +++ b/kernel/trace/trace.c
    @@ -4339,6 +4339,7 @@ static int tracing_buffers_open(struct inode *inode, struct file *filp)

    info->iter.tr = tr;
    info->iter.cpu_file = tc->cpu;
    + info->iter.trace = tr->current_trace;
    info->spare = NULL;
    /* Force reading ring buffer for first read */
    info->read = (unsigned int)-1;
    @@ -4378,18 +4379,29 @@ tracing_buffers_read(struct file *filp, char __user *ubuf,
    if (info->read < PAGE_SIZE)
    goto read;

    + again:
    trace_access_lock(iter->cpu_file);
    ret = ring_buffer_read_page(iter->tr->buffer,
    &info->spare,
    count,
    iter->cpu_file, 0);
    trace_access_unlock(iter->cpu_file);
    - if (ret < 0)
    +
    + if (ret < 0) {
    + if (trace_empty(iter)) {
    + if ((filp->f_flags & O_NONBLOCK))
    + return -EAGAIN;
    + iter->trace->wait_pipe(iter);
    + if (signal_pending(current))
    + return -EINTR;
    + goto again;
    + }
    return 0;
    + }

    info->read = 0;

    -read:
    + read:
    size = PAGE_SIZE - info->read;
    if (size > count)
    size = count;
    @@ -4566,7 +4578,7 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
    ret = -EAGAIN;
    goto out;
    }
    - default_wait_pipe(iter);
    + iter->trace->wait_pipe(iter);
    if (signal_pending(current)) {
    ret = -EINTR;
    goto out;
    --
    1.7.10.4



    \
     
     \ /
      Last update: 2013-03-02 05:01    [W:3.324 / U:0.056 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site