Commit db5f0c3e authored by Steven Rostedt's avatar Steven Rostedt Committed by Steven Rostedt (Google)
Browse files

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: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent 12d51896
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -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);