Re: [PATCH] tracing: Fix nr_subbufs initialization in simple_ring_buffer_init_mm()
From: Steven Rostedt
Date: Thu Mar 19 2026 - 17:13:35 EST
On Thu, 19 Mar 2026 09:26:52 +0000
Vincent Donnefort <vdonnefort@xxxxxxxxxx> wrote:
> I don't think it is fixing anything at the moment. It sets nr_subbufs for the
> sack of completing the meta_page but this field isn't read by the kernel. It
> doesn't need it because the reader is using the ring_buffer_desc.
>
> Nonetheless it's probably worth to fix now, that will be less work if later we
> e.g. allow remotes to be mapped by userspace. (Not something I have on my todo
> list).
Or add a comment to why it was set to zero.
>
> >
> > >
> > > Fixes: 34e5b958bdad ("tracing: Introduce simple_ring_buffer")
> > > Signed-off-by: David Carlier <devnexen@xxxxxxxxx>
> > > ---
> > > kernel/trace/simple_ring_buffer.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/kernel/trace/simple_ring_buffer.c b/kernel/trace/simple_ring_buffer.c
> > > index 02af2297ae5a..e991a0d8def2 100644
> > > --- a/kernel/trace/simple_ring_buffer.c
> > > +++ b/kernel/trace/simple_ring_buffer.c
> > > @@ -395,7 +395,7 @@ int simple_ring_buffer_init_mm(struct simple_rb_per_cpu *cpu_buffer,
> > >
> > > memset(cpu_buffer->meta, 0, sizeof(*cpu_buffer->meta));
> > > cpu_buffer->meta->meta_page_size = PAGE_SIZE;
> > > - cpu_buffer->meta->nr_subbufs = cpu_buffer->nr_pages;
> > > + cpu_buffer->meta->nr_subbufs = desc->nr_page_va;
>
> I would just move this assignment later to make sure cpu_buffer->nr_pages is
> aligned with the meta page, instead of relying on the ring_buffer_desc.
I was thinking the same thing.
-- Steve
>
> > >
> > > /* The reader page is not part of the ring initially */
> > > page = load_page(desc->page_va[0]);
> >