* [PATCH] ring-buffer: Remove jump to out label in ring_buffer_swap_cpu()
@ 2025-05-27 18:57 Steven Rostedt
2025-05-28 0:32 ` Masami Hiramatsu
0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2025-05-27 18:57 UTC (permalink / raw)
To: LKML, Linux Trace Kernel; +Cc: Masami Hiramatsu, Mathieu Desnoyers
From: Steven Rostedt <rostedt@goodmis.org>
The function ring_buffer_swap_cpu() has a bunch of jumps to the label out
that simply returns "ret". There's no reason to jump to a label that
simply returns a value. Just return directly from there.
This goes back to almost the beginning when commit 8aabee573dff
("ring-buffer: remove unneeded get_online_cpus") was introduced. That
commit removed a put_online_cpus() from that label, but never updated all
the jumps to it that now no longer needed to do anything but return a
value.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
kernel/trace/ring_buffer.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 897ce51d3bbf..e2aa90dc8d9e 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -6309,37 +6309,33 @@ int ring_buffer_swap_cpu(struct trace_buffer *buffer_a,
if (!cpumask_test_cpu(cpu, buffer_a->cpumask) ||
!cpumask_test_cpu(cpu, buffer_b->cpumask))
- goto out;
+ return -EINVAL;
cpu_buffer_a = buffer_a->buffers[cpu];
cpu_buffer_b = buffer_b->buffers[cpu];
/* It's up to the callers to not try to swap mapped buffers */
- if (WARN_ON_ONCE(cpu_buffer_a->mapped || cpu_buffer_b->mapped)) {
- ret = -EBUSY;
- goto out;
- }
+ if (WARN_ON_ONCE(cpu_buffer_a->mapped || cpu_buffer_b->mapped))
+ return -EBUSY;
/* At least make sure the two buffers are somewhat the same */
if (cpu_buffer_a->nr_pages != cpu_buffer_b->nr_pages)
- goto out;
+ return -EINVAL;
if (buffer_a->subbuf_order != buffer_b->subbuf_order)
- goto out;
-
- ret = -EAGAIN;
+ return -EINVAL;
if (atomic_read(&buffer_a->record_disabled))
- goto out;
+ return -EAGAIN;
if (atomic_read(&buffer_b->record_disabled))
- goto out;
+ return -EAGAIN;
if (atomic_read(&cpu_buffer_a->record_disabled))
- goto out;
+ return -EAGAIN;
if (atomic_read(&cpu_buffer_b->record_disabled))
- goto out;
+ return -EAGAIN;
/*
* We can't do a synchronize_rcu here because this
@@ -6376,7 +6372,6 @@ int ring_buffer_swap_cpu(struct trace_buffer *buffer_a,
out_dec:
atomic_dec(&cpu_buffer_a->record_disabled);
atomic_dec(&cpu_buffer_b->record_disabled);
-out:
return ret;
}
EXPORT_SYMBOL_GPL(ring_buffer_swap_cpu);
--
2.47.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ring-buffer: Remove jump to out label in ring_buffer_swap_cpu()
2025-05-27 18:57 [PATCH] ring-buffer: Remove jump to out label in ring_buffer_swap_cpu() Steven Rostedt
@ 2025-05-28 0:32 ` Masami Hiramatsu
0 siblings, 0 replies; 2+ messages in thread
From: Masami Hiramatsu @ 2025-05-28 0:32 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Mathieu Desnoyers
On Tue, 27 May 2025 14:57:53 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
>
> The function ring_buffer_swap_cpu() has a bunch of jumps to the label out
> that simply returns "ret". There's no reason to jump to a label that
> simply returns a value. Just return directly from there.
>
> This goes back to almost the beginning when commit 8aabee573dff
> ("ring-buffer: remove unneeded get_online_cpus") was introduced. That
> commit removed a put_online_cpus() from that label, but never updated all
> the jumps to it that now no longer needed to do anything but return a
> value.
>
Looks good to me.
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
> kernel/trace/ring_buffer.c | 23 +++++++++--------------
> 1 file changed, 9 insertions(+), 14 deletions(-)
>
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index 897ce51d3bbf..e2aa90dc8d9e 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -6309,37 +6309,33 @@ int ring_buffer_swap_cpu(struct trace_buffer *buffer_a,
>
> if (!cpumask_test_cpu(cpu, buffer_a->cpumask) ||
> !cpumask_test_cpu(cpu, buffer_b->cpumask))
> - goto out;
> + return -EINVAL;
>
> cpu_buffer_a = buffer_a->buffers[cpu];
> cpu_buffer_b = buffer_b->buffers[cpu];
>
> /* It's up to the callers to not try to swap mapped buffers */
> - if (WARN_ON_ONCE(cpu_buffer_a->mapped || cpu_buffer_b->mapped)) {
> - ret = -EBUSY;
> - goto out;
> - }
> + if (WARN_ON_ONCE(cpu_buffer_a->mapped || cpu_buffer_b->mapped))
> + return -EBUSY;
>
> /* At least make sure the two buffers are somewhat the same */
> if (cpu_buffer_a->nr_pages != cpu_buffer_b->nr_pages)
> - goto out;
> + return -EINVAL;
>
> if (buffer_a->subbuf_order != buffer_b->subbuf_order)
> - goto out;
> -
> - ret = -EAGAIN;
> + return -EINVAL;
>
> if (atomic_read(&buffer_a->record_disabled))
> - goto out;
> + return -EAGAIN;
>
> if (atomic_read(&buffer_b->record_disabled))
> - goto out;
> + return -EAGAIN;
>
> if (atomic_read(&cpu_buffer_a->record_disabled))
> - goto out;
> + return -EAGAIN;
>
> if (atomic_read(&cpu_buffer_b->record_disabled))
> - goto out;
> + return -EAGAIN;
>
> /*
> * We can't do a synchronize_rcu here because this
> @@ -6376,7 +6372,6 @@ int ring_buffer_swap_cpu(struct trace_buffer *buffer_a,
> out_dec:
> atomic_dec(&cpu_buffer_a->record_disabled);
> atomic_dec(&cpu_buffer_b->record_disabled);
> -out:
> return ret;
> }
> EXPORT_SYMBOL_GPL(ring_buffer_swap_cpu);
> --
> 2.47.2
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-05-28 0:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-27 18:57 [PATCH] ring-buffer: Remove jump to out label in ring_buffer_swap_cpu() Steven Rostedt
2025-05-28 0:32 ` Masami Hiramatsu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).