From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Vincent Donnefort <vdonnefort@google.com>
Cc: rostedt@goodmis.org, linux-trace-kernel@vger.kernel.org,
mathieu.desnoyers@efficios.com, kernel-team@android.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] ring-buffer: Rename ring_buffer_size() to ring_buffer_capacity()
Date: Mon, 7 Sep 2026 23:41:46 +0900 [thread overview]
Message-ID: <20260907234146.9739977b015a6c8c39ce3693@kernel.org> (raw)
In-Reply-To: <20260907094238.3624013-1-vdonnefort@google.com>
On Mon, 7 Sep 2026 10:42:38 +0100
Vincent Donnefort <vdonnefort@google.com> wrote:
> Since commit 8a5f63637890 ("ring-buffer: Fix subbuf resize race with ring
> buffer readers"), "capacity" refers to the memory available for events
> (excluding subbuffer headers) while "size" refers to the raw allocation.
> ring_buffer_size() actually calculates this event capacity. Rename it to
> ring_buffer_capacity() to align with this convention.
I think this is OK, but I have a question.
[...]
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 8658cad53cb5..f0251788ec75 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -4712,9 +4712,9 @@ void trace_set_buffer_entries(struct array_buffer *buf, unsigned long val)
> static void update_buffer_entries(struct array_buffer *buf, int cpu)
> {
> if (cpu == RING_BUFFER_ALL_CPUS) {
> - trace_set_buffer_entries(buf, ring_buffer_size(buf->buffer, 0));
> + trace_set_buffer_entries(buf, ring_buffer_capacity(buf->buffer, 0));
> } else {
> - per_cpu_ptr(buf->data, cpu)->entries = ring_buffer_size(buf->buffer, cpu);
> + per_cpu_ptr(buf->data, cpu)->entries = ring_buffer_capacity(buf->buffer, cpu);
nit: Don't we need to re-word this "entries" with "capacity" too?
Actually, this "entries" is a bit odd because
- ring_buffer_entries() returns the number of events.
- trace_set_buffer_entries() sets the buffer capacity in bytes.
It seems we call it as "entries" historical reason, but now it becomes the
source of confusion. Maybe we should change it too. (but in the separate patch)
Thanks,
> }
> }
>
> @@ -8476,7 +8476,7 @@ int allocate_trace_buffer(struct trace_array *tr, struct array_buffer *buf, int
>
> /* Allocate the first page for all buffers */
> trace_set_buffer_entries(&tr->array_buffer,
> - ring_buffer_size(tr->array_buffer.buffer, 0));
> + ring_buffer_capacity(tr->array_buffer.buffer, 0));
>
> return 0;
> }
>
> base-commit: df2908090cda368b01ff43709f51890076c56157
> --
> 2.55.0.979.g7e5102b832-goog
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2026-09-07 14:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 9:42 [PATCH v1] ring-buffer: Rename ring_buffer_size() to ring_buffer_capacity() Vincent Donnefort
2026-09-07 9:44 ` Vincent Donnefort
2026-09-07 9:51 ` sashiko-bot
2026-09-07 14:41 ` Masami Hiramatsu [this message]
2026-09-07 16:39 ` Vincent Donnefort
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260907234146.9739977b015a6c8c39ce3693@kernel.org \
--to=mhiramat@kernel.org \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=rostedt@goodmis.org \
--cc=vdonnefort@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).