[PATCH 2/2] tracing - putting cond_resched into tace_pipe loop

From: Jiri Olsa
Date: Sat Mar 12 2011 - 18:00:35 EST


Adding cond_resched call to the tracing_read_pipe while loop.
Plus check for signal to leave the loop.

This will protect us from soft lockup on NON preemptive kernels
and improve latency.

Thanks a lot to Oleg Nestorov for helping me to nail this down.

wbr,
jirka


Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
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 20d84f8..7d66476 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3237,10 +3237,23 @@ waitagain:
* One of the trace_seq_* functions is not used properly.
*/
WARN_ON(iter->seq.full);
+
+ /*
+ * There's a chance this loop might get quite tight,
+ * causing latency in non preemptive kernel.
+ */
+ cond_resched();
+ if (signal_pending(current)) {
+ sret = -EINTR;
+ break;
+ }
}
trace_access_unlock(iter->cpu_file);
trace_event_read_unlock();

+ if (sret == -EINTR)
+ goto out;
+
/* Now copy what we have to the user */
sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
if (iter->seq.readpos >= iter->seq.len)
--
1.7.1

--
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/