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

From: Steven Rostedt
Date: Wed Mar 29 2023 - 09:37:07 EST


On Wed, 29 Mar 2023 14:31:07 +0100
Vincent Donnefort <vdonnefort@xxxxxxxxxx> wrote:

> We can say we update cpu_buffer->reader_page->read on the get_reader_page ioctl,
> to the most recent value possible, which will have the consequence of actually
> "flushing" those events?

Yes. It should be no different than doing a normal read of the
trace_pipe_raw file, which does the same.

>
> If the reader decides to read events past this value then it just can't expect
> them to not be duplicated?
>
> I suppose it'd be down the reader to store meta->read somehwere?
>
> prev_read = meta->read
> ioctl(fd, TRACE_MMAP_IOCTL_GET_READER_PAGE)
> /* read events from prev_read to meta->read */

Yes, in fact it shouldn't need to call the ioctl until after it read it.

Maybe, we should have the ioctl take a parameter of how much was read?
To prevent races?

That is, it should pass in the page->commit that it used to to read the
pages.

-- Steve