ring-buffer: Convert ring_buffer_write() to use guard(preempt_notrace)

The function ring_buffer_write() has a goto out to only do a
preempt_enable_notrace(). This can be replaced by a guard.

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: https://lore.kernel.org/20250801203858.205479143@kernel.org
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
Steven Rostedt 2025-08-01 16:37:27 -04:00 committed by Steven Rostedt (Google)
parent 12d5189615
commit db5f0c3e3e

View file

@ -4714,26 +4714,26 @@ int ring_buffer_write(struct trace_buffer *buffer,
int ret = -EBUSY;
int cpu;
preempt_disable_notrace();
guard(preempt_notrace)();
if (atomic_read(&buffer->record_disabled))
goto out;
return -EBUSY;
cpu = raw_smp_processor_id();
if (!cpumask_test_cpu(cpu, buffer->cpumask))
goto out;
return -EBUSY;
cpu_buffer = buffer->buffers[cpu];
if (atomic_read(&cpu_buffer->record_disabled))
goto out;
return -EBUSY;
if (length > buffer->max_data_size)
goto out;
return -EBUSY;
if (unlikely(trace_recursive_lock(cpu_buffer)))
goto out;
return -EBUSY;
event = rb_reserve_next_event(buffer, cpu_buffer, length);
if (!event)
@ -4751,10 +4751,6 @@ int ring_buffer_write(struct trace_buffer *buffer,
out_unlock:
trace_recursive_unlock(cpu_buffer);
out:
preempt_enable_notrace();
return ret;
}
EXPORT_SYMBOL_GPL(ring_buffer_write);