[PATCH -tip 2/4] Tracing/ftrace: Fix pipe breaking

From: Frederic Weisbecker
Date: Mon Sep 29 2008 - 14:24:07 EST


From: Pekka Paalanen <pq@xxxxxx>

This patch fixes a bug which break the pipe when the seq is empty.

Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
---
kernel/trace/trace.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 61f33da..ed10a68 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2610,7 +2610,6 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
if (sret != -EBUSY)
return sret;
- sret = 0;

trace_seq_reset(&iter->seq);

@@ -2621,6 +2620,8 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
goto out;
}

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

if ((filp->f_flags & O_NONBLOCK)) {
@@ -2754,8 +2755,13 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
if (iter->seq.readpos >= iter->seq.len)
trace_seq_reset(&iter->seq);
+
+ /*
+ * If there was nothing to send to user, inspite of consuming trace
+ * entries, go back to wait for more entries.
+ */
if (sret == -EBUSY)
- sret = 0;
+ goto waitagain;

out:
mutex_unlock(&trace_types_lock);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/