ring-buffer: Introducing ring-buffer mapping functions
authorVincent Donnefort <vdonnefort@google.com>
Fri, 10 May 2024 14:04:31 +0000 (15:04 +0100)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Mon, 13 May 2024 22:09:56 +0000 (18:09 -0400)
commit117c39200d9d760cbd5944bb89efb7b9c51965aa
tree003f572f19f8adebff414ee19bfe88126361a647
parentc09d4167b550f91ecf5c3db883eea314edc7f532
ring-buffer: Introducing ring-buffer mapping functions

In preparation for allowing the user-space to map a ring-buffer, add
a set of mapping functions:

  ring_buffer_{map,unmap}()

And controls on the ring-buffer:

  ring_buffer_map_get_reader()  /* swap reader and head */

Mapping the ring-buffer also involves:

  A unique ID for each subbuf of the ring-buffer, currently they are
  only identified through their in-kernel VA.

  A meta-page, where are stored ring-buffer statistics and a
  description for the current reader

The linear mapping exposes the meta-page, and each subbuf of the
ring-buffer, ordered following their unique ID, assigned during the
first mapping.

Once mapped, no subbuf can get in or out of the ring-buffer: the buffer
size will remain unmodified and the splice enabling functions will in
reality simply memcpy the data instead of swapping subbufs.

Link: https://lore.kernel.org/linux-trace-kernel/20240510140435.3550353-3-vdonnefort@google.com
CC: <linux-mm@kvack.org>
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
Acked-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
include/linux/ring_buffer.h
include/uapi/linux/trace_mmap.h [new file with mode: 0644]
kernel/trace/ring_buffer.c