Skip to content

Commit db5f0c3

Browse files
committed
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 <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Andrew Morton <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 12d5189 commit db5f0c3

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

kernel/trace/ring_buffer.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4714,26 +4714,26 @@ int ring_buffer_write(struct trace_buffer *buffer,
47144714
int ret = -EBUSY;
47154715
int cpu;
47164716

4717-
preempt_disable_notrace();
4717+
guard(preempt_notrace)();
47184718

47194719
if (atomic_read(&buffer->record_disabled))
4720-
goto out;
4720+
return -EBUSY;
47214721

47224722
cpu = raw_smp_processor_id();
47234723

47244724
if (!cpumask_test_cpu(cpu, buffer->cpumask))
4725-
goto out;
4725+
return -EBUSY;
47264726

47274727
cpu_buffer = buffer->buffers[cpu];
47284728

47294729
if (atomic_read(&cpu_buffer->record_disabled))
4730-
goto out;
4730+
return -EBUSY;
47314731

47324732
if (length > buffer->max_data_size)
4733-
goto out;
4733+
return -EBUSY;
47344734

47354735
if (unlikely(trace_recursive_lock(cpu_buffer)))
4736-
goto out;
4736+
return -EBUSY;
47374737

47384738
event = rb_reserve_next_event(buffer, cpu_buffer, length);
47394739
if (!event)
@@ -4751,10 +4751,6 @@ int ring_buffer_write(struct trace_buffer *buffer,
47514751

47524752
out_unlock:
47534753
trace_recursive_unlock(cpu_buffer);
4754-
4755-
out:
4756-
preempt_enable_notrace();
4757-
47584754
return ret;
47594755
}
47604756
EXPORT_SYMBOL_GPL(ring_buffer_write);

0 commit comments

Comments
 (0)