Re: [GIT PULL] ring-buffer: Updates for v6.15

From: Linus Torvalds
Date: Thu Mar 27 2025 - 23:36:31 EST


On Thu, 27 Mar 2025 at 20:19, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Thu, 27 Mar 2025 at 20:01, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> >
> > Are you OK with the idea of moving the mapping code into the ring
> > buffer code (which I think is cleaner) and then keeping track of that
> > to get to the pages with the helper function?
> >
> > struct page *rb_get_page(struct trace_buffer *buffer, unsigned long addr)
> > {
> > if (buffer->flags & RB_FL_PHYSICAL) {
> > addr -= buffer->vmap_start;
> > addr += buffer->phys_start;
> > return pfn_to_page(addr >> PAGE_SHIFT);
> > }
> > return virt_to_page(addr);
> > }
>
> I think that would have been *enormously* better, yes

.. actually, thinking a bit more about it, I think you want another
level of abstraction to deal with the chunking side (ie I think you
want to make the subbuf_ids[] thing explicit and the 'page order' as
well).

So you have that 'meta_buffer' thing for the first page, but you also
have that subbuf_ids[] array with pages chunked by 'order'), and I
think you need another level of abstraction for those.

IOW, you'd have 'rb_get_meta_buffer_page()' for the first page, and
then something like 'rb_get_buffer_page()' for the subbuf_id[] thing.

Or something in that direction. I didn't look *too* closely at what
the code actually needs, I'm just trying to make sure that you don't
pass random kernel addresses around, but something more structured.

Preferably maybe just the page index *within* the ring buffer,
perhaps, and have the helper function do the whole "is this the meta
buffer or one of the subbuf_id things"?

Hmm?

More clear abstraction is what I'm looking for, in other words.

Linus