Re: [PATCH v2 1/2] ring-buffer: Introducing ring-buffer mapping functions

From: Vincent Donnefort
Date: Thu Mar 30 2023 - 10:49:04 EST


[...]

> > > struct ring_buffer_meta_page_header {
> > > #if __BITS_PER_LONG == 64
> > > __u64 entries;
> > > __u64 overrun;
> > > #else
> > > __u32 entries;
> > > __u32 overrun;
> > > #endif
> > > __u32 pages_touched;
> > > __u32 meta_page_size;
> > > __u32 reader_page; /* page ID for the reader page */
> > > __u32 nr_data_pages; /* doesn't take into account the reader_page */
> > > };
> > >
> > > BTW, shouldn't the nr_data_pages take into account the reader page? As it
> > > is part of the array we traverse isn't it?
> >
> > It depends if the reader page has ever been swapped out. If yes, the reader
> > would have to start from reader_page and then switch to the data_pages.
> > Which sounds like a fiddly interface for the userspace.
> >
> > So yeah, consuming-read only feels like a better start.
> >
>
> I agree. I'd like to get something in that can be extended, but simple
> enough that it's not too much of a barrier wrt getting the API correct.
>
> -- Steve

Something I just realized though. In the event of being able to upstream the
hypervisor tracing based on the ring_buffer_meta_page, without non-consumming
support, we wouldn't have the "trace" file which is used to reset the buffers.

I'd guess we'd have to either create one that is read-only (a bit strange) or
let trace_pipe reset the buffer(s).