ring-buffer: Have mmapped ring buffer keep track of missed events
authorSteven Rostedt (Google) <rostedt@goodmis.org>
Tue, 12 Mar 2024 21:54:05 +0000 (17:54 -0400)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Mon, 13 May 2024 23:55:22 +0000 (19:55 -0400)
commitfe832be05a8eee5f1488cbcc2c562dd82d079fd6
tree6a0861727992f1dcddda7a174fe85c606474e279
parent75961e55415cdc368ca2d7f6203fb627c259d58a
ring-buffer: Have mmapped ring buffer keep track of missed events

While testing libtracefs on the mmapped ring buffer, the test that checks
if missed events are accounted for failed when using the mapped buffer.
This is because the mapped page does not update the missed events that
were dropped because the writer filled up the ring buffer before the
reader could catch it.

Add the missed events to the reader page/sub-buffer when the IOCTL is done
and a new reader page is acquired.

Note that all accesses to the reader_page via rb_page_commit() had to be
switched to rb_page_size(), and rb_page_size() which was just a copy of
rb_page_commit() but now it masks out the RB_MISSED bits. This is needed
as the mapped reader page is still active in the ring buffer code and
where it reads the commit field of the bpage for the size, it now must
mask it otherwise the missed bits that are now set will corrupt the size
returned.

Link: https://lore.kernel.org/linux-trace-kernel/20240312175405.12fb6726@gandalf.local.home
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/ring_buffer.c