[PATCH 1/3] libtracefs: Enable mmapped ring buffer

Steven Rostedt <[email protected]>
Newsgroups org.kernel.vger.linux-trace-devel
Message-ID <[email protected]>
From: "Steven Rostedt (Google)" <[email protected]>

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) <[email protected]>
---
 src/tracefs-mmap.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

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)
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.