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

From: Vincent Donnefort
Date: Wed Mar 29 2023 - 09:01:14 EST


On Wed, Mar 29, 2023 at 08:51:06AM -0400, Steven Rostedt wrote:
> On Wed, 29 Mar 2023 07:03:53 -0400
> Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> > 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 */
> > };
>
> Oh, I guess we should also expose the amount read on the reader page,
> that gets updated on the ioctl. That is, if the first time we read the
> reader page and the page is not full and unmap the pages, and then new
> events were added to the reader page, we should not re-read the events
> that were read previously.
>
> That is, expose cpu_buffer->reader_page->read

Couldn't it be an issue of updating cpu_buffer->reader_page->read during the
ioctl? I guess we would write the value of the current written events on that
page, hopping for the userspace reader to read it all.

But then if new events are written, the reader doesn't need the ioctl to read
them, it can just check the meta->entries field or the commit field in the
reader_page header?

So it's much likely cpu_buffer->reader_page->read will go out of sync?

>
> -- Steve