tracing: Wake up waiters when tracing is disabled
authorSteven Rostedt (Google) <rostedt@goodmis.org>
Wed, 28 Sep 2022 22:22:20 +0000 (18:22 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 10:34:31 +0000 (12:34 +0200)
commit 2b0fd9a59b7990c161fa1cb7b79edb22847c87c2 upstream.

When tracing is disabled, there's no reason that waiters should stay
waiting, wake them up, otherwise tasks get stuck when they should be
flushing the buffers.

Cc: stable@vger.kernel.org
Fixes: e30f53aad2202 ("tracing: Do not busy wait in buffer splice")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/trace/trace.c

index bf0b693..2f98c0a 100644 (file)
@@ -8291,6 +8291,10 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
                if (ret)
                        goto out;
 
+               /* No need to wait after waking up when tracing is off */
+               if (!tracer_tracing_is_on(iter->tr))
+                       goto out;
+
                /* Make sure we see the new wait_index */
                smp_rmb();
                if (wait_index != iter->wait_index)
@@ -9000,6 +9004,8 @@ rb_simple_write(struct file *filp, const char __user *ubuf,
                        tracer_tracing_off(tr);
                        if (tr->current_trace->stop)
                                tr->current_trace->stop(tr);
+                       /* Wake up any waiters */
+                       ring_buffer_wake_waiters(buffer, RING_BUFFER_ALL_CPUS);
                }
                mutex_unlock(&trace_types_lock);
        }