mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vincent Donnefort <vdonnefort@google.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: mhiramat@kernel.org, linux-trace-kernel@vger.kernel.org,
	mathieu.desnoyers@efficios.com, kernel-team@android.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] ring-buffer: Drop redundant ring_buffer_iter::event_size
Date: Thu, 5 Nov 2026 09:21:44 +0000	[thread overview]
Message-ID: <auxKqGjWEZa-7iNt@google.com> (raw)
In-Reply-To: <20261104140723.1251aee1@gandalf.local.home>

On Wed, Nov 04, 2026 at 02:07:23PM -0500, Steven Rostedt wrote:
> On Tue, 22 Sep 2026 08:29:43 +0100
> Vincent Donnefort <vdonnefort@google.com> wrote:
> 
> > event_size contains the maximum size the iterator can read for each
> > event. It corresponds to the maximum capacity of a ring-buffer page.
> > During non-consuming read, resizing is disabled. It is therefore safe to
> > just use rb_subbuf_capacity(), making event_size redundant. Remove it.
> 
> Hmm, I don't like the code dependency here. Yes, we disable resizing and
> the event_size isn't going to change, but if in the future that is no
> longer the case, then this becomes a hidden bug.
> 
> What's wrong with just having a field that keeps track of the size
> allocated? It's more robust that way and doesn't have any hidden
> dependencies.
> 
> -- Steve

Ack. It was just an attempt at cleaning up the struct, but indeed this makes an
additional assumption we didn't have before.

I can drop this patch.

-- 
Vincent

>  
> 
> > 
> > Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
> > ---
> >  kernel/trace/ring_buffer.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> > index 1a158a24b3c8..3129589e2d0e 100644
> > --- a/kernel/trace/ring_buffer.c
> > +++ b/kernel/trace/ring_buffer.c
> > @@ -680,7 +680,6 @@ struct ring_buffer_iter {
> >  	u64				read_stamp;
> >  	u64				page_stamp;
> >  	struct ring_buffer_event	*event;
> > -	size_t				event_size;
> >  	int				missed_events;
> >  };
> >  
> > @@ -3558,9 +3557,11 @@ rb_iter_head_event(struct ring_buffer_iter *iter)
> >  	 */
> >  	barrier();
> >  
> > -	if ((iter->head + length) > commit || length > iter->event_size)
> > +	if ((iter->head + length) > commit ||
> > +	    length > rb_subbuf_capacity(iter->cpu_buffer->buffer)) {
> >  		/* Writer corrupted the read? */
> >  		goto reset;
> > +	}
> >  
> >  	memcpy(iter->event, event, length);
> >  	/*
> > @@ -6488,8 +6489,7 @@ ring_buffer_read_start(struct trace_buffer *buffer, int cpu, gfp_t flags)
> >  		mutex_unlock(&buffer->mutex);
> >  
> >  	/* Holds the entire event: data and meta data. */
> > -	iter->event_size = rb_page_capacity(READ_ONCE(cpu_buffer->reader_page));
> > -	iter->event = kmalloc(iter->event_size, flags);
> > +	iter->event = kmalloc(rb_subbuf_capacity(buffer), flags);
> >  	if (!iter->event) {
> >  		atomic_dec(&cpu_buffer->resize_disabled);
> >  		return NULL;
> 

  reply	other threads:[~2026-11-05  9:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22  7:29 [PATCH 0/4] ring-buffer: Use kvmalloc variants for big allocations Vincent Donnefort
2026-09-22  7:29 ` [PATCH 1/4] ring-buffer: Use kvzalloc_objs for user mapping arrays Vincent Donnefort
2026-09-22  7:29 ` [PATCH 2/4] ring-buffer: Use kvzalloc_objs for remote buffer subbuf_ids Vincent Donnefort
2026-09-22  7:29 ` [PATCH 3/4] ring-buffer: Drop redundant ring_buffer_iter::event_size Vincent Donnefort
2026-11-04 19:07   ` Steven Rostedt
2026-11-05  9:21     ` Vincent Donnefort [this message]
2026-09-22  7:29 ` [PATCH 4/4] ring-buffer: Use kvmalloc for ring_buffer_iter::event 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=auxKqGjWEZa-7iNt@google.com \
    --to=vdonnefort@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    /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

all inboxes | Powered by JetHome®