Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 140714
b: refs/heads/master
c: ff98781
h: refs/heads/master
v: v3
  • Loading branch information
Eduard - Gabriel Munteanu authored and Steven Rostedt committed Feb 9, 2009
1 parent 1719e86 commit 1fd14dd
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 30 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3c56819b14b00dd449bd776303e61f8532fad09f
refs/heads/master: ff98781bab2735e6c89793034173e0cb5007a7e5
69 changes: 40 additions & 29 deletions trunk/kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2388,37 +2388,15 @@ tracing_poll_pipe(struct file *filp, poll_table *poll_table)
}
}

/*
* Consumer reader.
*/
static ssize_t
tracing_read_pipe(struct file *filp, char __user *ubuf,
size_t cnt, loff_t *ppos)
/* Must be called with trace_types_lock mutex held. */
static int tracing_wait_pipe(struct file *filp)
{
struct trace_iterator *iter = filp->private_data;
ssize_t sret;

/* return any leftover data */
sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
if (sret != -EBUSY)
return sret;

trace_seq_reset(&iter->seq);

mutex_lock(&trace_types_lock);
if (iter->trace->read) {
sret = iter->trace->read(iter, filp, ubuf, cnt, ppos);
if (sret)
goto out;
}

waitagain:
sret = 0;
while (trace_empty(iter)) {

if ((filp->f_flags & O_NONBLOCK)) {
sret = -EAGAIN;
goto out;
return -EAGAIN;
}

/*
Expand All @@ -2443,12 +2421,11 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
iter->tr->waiter = NULL;

if (signal_pending(current)) {
sret = -EINTR;
goto out;
return -EINTR;
}

if (iter->trace != current_trace)
goto out;
return 0;

/*
* We block until we read something and tracing is disabled.
Expand All @@ -2465,9 +2442,43 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
continue;
}

return 1;
}

/*
* Consumer reader.
*/
static ssize_t
tracing_read_pipe(struct file *filp, char __user *ubuf,
size_t cnt, loff_t *ppos)
{
struct trace_iterator *iter = filp->private_data;
ssize_t sret;

/* return any leftover data */
sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
if (sret != -EBUSY)
return sret;

trace_seq_reset(&iter->seq);

mutex_lock(&trace_types_lock);
if (iter->trace->read) {
sret = iter->trace->read(iter, filp, ubuf, cnt, ppos);
if (sret)
goto out;
}

waitagain:
sret = tracing_wait_pipe(filp);
if (sret <= 0)
goto out;

/* stop when tracing is finished */
if (trace_empty(iter))
if (trace_empty(iter)) {
sret = 0;
goto out;
}

if (cnt >= PAGE_SIZE)
cnt = PAGE_SIZE - 1;
Expand Down

0 comments on commit 1fd14dd

Please sign in to comment.