diff mbox series

[1/3] libtracefs: Enable mmapped ring buffer

Message ID 20240723220853.489058-2-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit 4ede86e9a48dbd03b07aa06954a7f68c004e1637
Headers show
Series libtracefs: Enable ring buffer user space memory mapping | expand

Commit Message

Steven Rostedt July 23, 2024, 10:07 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

As of v6.10, ring buffer user space mapping is now supported by the Linux
kernel. This also means that it is an official API. Copy the latest API from
that kernel into the trace_mmap.h file and make it accessible to user space
programs.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 src/tracefs-mmap.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/src/tracefs-mmap.c b/src/tracefs-mmap.c
index a0130bbc1cbe..44d1597f1ba5 100644
--- a/src/tracefs-mmap.c
+++ b/src/tracefs-mmap.c
@@ -22,8 +22,8 @@ 
  * @entries:		Number of entries in the ring-buffer.
  * @overrun:		Number of entries lost in the ring-buffer.
  * @read:		Number of entries that have been read.
- * @Reserved1:		Reserved for future use.
- * @Reserved2:		Reserved for future use.
+ * @Reserved1:		Internal use only.
+ * @Reserved2:		Internal use only.
  */
 struct trace_buffer_meta {
 	__u32		meta_page_size;
@@ -48,7 +48,7 @@  struct trace_buffer_meta {
 	__u64	Reserved2;
 };
 
-#define TRACE_MMAP_IOCTL_GET_READER		_IO('T', 0x1)
+#define TRACE_MMAP_IOCTL_GET_READER		_IO('R', 0x20)
 
 struct trace_mmap {
 	struct trace_buffer_meta	*map;
@@ -78,10 +78,6 @@  __hidden void *trace_mmap(int fd, struct kbuffer *kbuf)
 	void *meta;
 	void *data;
 
-#ifndef FORCE_MMAP_ENABLE
-	return NULL;
-#endif
-
 	page_size = getpagesize();
 	meta = mmap(NULL, page_size, PROT_READ, MAP_SHARED, fd, 0);
 	if (meta == MAP_FAILED)