]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ring-buffer: Simplify reset_disabled_cpu_buffer() with use of guard()
authorSteven Rostedt <rostedt@goodmis.org>
Tue, 27 May 2025 18:46:23 +0000 (14:46 -0400)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Thu, 29 May 2025 12:24:07 +0000 (08:24 -0400)
Use guard(raw_spinlock_irqsave)() in reset_disabled_cpu_buffer() to
simplify the locking.

Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://lore.kernel.org/20250527144623.77a9cc47@gandalf.local.home
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/ring_buffer.c

index c912ce4c8c89aca41ab31c05dd4ed2cd9f5a284b..58cca10f482bf31eb7f3f864f7c87ebfe75359c2 100644 (file)
@@ -6113,21 +6113,16 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
 /* Must have disabled the cpu buffer then done a synchronize_rcu */
 static void reset_disabled_cpu_buffer(struct ring_buffer_per_cpu *cpu_buffer)
 {
-       unsigned long flags;
-
-       raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
+       guard(raw_spinlock_irqsave)(&cpu_buffer->reader_lock);
 
        if (RB_WARN_ON(cpu_buffer, local_read(&cpu_buffer->committing)))
-               goto out;
+               return;
 
        arch_spin_lock(&cpu_buffer->lock);
 
        rb_reset_cpu(cpu_buffer);
 
        arch_spin_unlock(&cpu_buffer->lock);
-
- out:
-       raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
 }
 
 /**