tracing: Robustify wait loop
authorPeter Zijlstra <peterz@infradead.org>
Wed, 8 Oct 2014 16:51:10 +0000 (18:51 +0200)
committerSteven Rostedt <rostedt@goodmis.org>
Wed, 8 Oct 2014 23:51:01 +0000 (19:51 -0400)
The pending nested sleep debugging triggered on the potential stale
TASK_INTERRUPTIBLE in this code.

While there, fix the loop such that we won't revert to a while(1)
yield() 'spin' loop if we ever get a spurious wakeup.

And fix the actual issue by properly terminating the 'wait' loop by
setting TASK_RUNNING.

Link: http://lkml.kernel.org/p/20141008165110.GA14547@worktop.programming.kicks-ass.net
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/trace_events.c

index ef06ce7e9cf8d1d9b6ea78240f69c5d44ff426dc..0cc51edde3a899bf464fecbccb98e5eb35d71d42 100644 (file)
@@ -2513,8 +2513,11 @@ static __init int event_test_thread(void *unused)
        kfree(test_malloc);
 
        set_current_state(TASK_INTERRUPTIBLE);
-       while (!kthread_should_stop())
+       while (!kthread_should_stop()) {
                schedule();
+               set_current_state(TASK_INTERRUPTIBLE);
+       }
+       __set_current_state(TASK_RUNNING);
 
        return 0;
 }