From: "Steven Rostedt (VMware)" <rost...@goodmis.org>

Currently, when one echo's in 1 into tracing_on, the current tracer's
"start()" function is executed, even if tracing_on was already one. This can
lead to strange side effects. One being that if the hwlat tracer is enabled,
and someone does "echo 1 > tracing_on" into tracing_on, the hwlat tracer's
start() function is called again which will recreate another kernel thread,
and make it unable to remove the old one.

Link: 
http://lkml.kernel.org/r/1533120354-22923-1-git-send-email-erica.bug...@linutronix.de

Cc: sta...@vger.kernel.org
Fixes: 2df8f8a6a897e ("tracing: Fix regression with irqsoff tracer and 
tracing_on file")
Reported-by: Erica Bugden <erica.bug...@linutronix.de>
Signed-off-by: Steven Rostedt (VMware) <rost...@goodmis.org>
---
 kernel/trace/trace.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 823687997b01..2378bb4f1442 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -7628,7 +7628,9 @@ rb_simple_write(struct file *filp, const char __user 
*ubuf,
 
        if (buffer) {
                mutex_lock(&trace_types_lock);
-               if (val) {
+               if (!!val == tracer_tracing_is_on(tr)) {
+                       val = 0; /* do nothing */
+               } else if (val) {
                        tracer_tracing_on(tr);
                        if (tr->current_trace->start)
                                tr->current_trace->start(tr);
-- 
2.18.0


Reply via email to