mirror of
https://git.proxmox.com/git/mirror_ubuntu-kernels.git
synced 2025-11-16 17:26:28 +00:00
Currently, user-space extracts data from the ring-buffer via splice,
which is handy for storage or network sharing. However, due to splice
limitations, it is imposible to do real-time analysis without a copy.
A solution for that problem is to let the user-space map the ring-buffer
directly.
The mapping is exposed via the per-CPU file trace_pipe_raw. The first
element of the mapping is the meta-page. It is followed by each
subbuffer constituting the ring-buffer, ordered by their unique page ID:
* Meta-page -- include/uapi/linux/trace_mmap.h for a description
* Subbuf ID 0
* Subbuf ID 1
...
It is therefore easy to translate a subbuf ID into an offset in the
mapping:
reader_id = meta->reader->id;
reader_offset = meta->meta_page_size + reader_id * meta->subbuf_size;
When new data is available, the mapper must call a newly introduced ioctl:
TRACE_MMAP_IOCTL_GET_READER. This will update the Meta-page reader ID to
point to the next reader containing unread data.
Mapping will prevent snapshot and buffer size modifications.
Link: https://lore.kernel.org/linux-trace-kernel/20240510140435.3550353-4-vdonnefort@google.com
CC: <linux-mm@kvack.org>
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
49 lines
1.3 KiB
C
49 lines
1.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
|
#ifndef _TRACE_MMAP_H_
|
|
#define _TRACE_MMAP_H_
|
|
|
|
#include <linux/types.h>
|
|
|
|
/**
|
|
* struct trace_buffer_meta - Ring-buffer Meta-page description
|
|
* @meta_page_size: Size of this meta-page.
|
|
* @meta_struct_len: Size of this structure.
|
|
* @subbuf_size: Size of each sub-buffer.
|
|
* @nr_subbufs: Number of subbfs in the ring-buffer, including the reader.
|
|
* @reader.lost_events: Number of events lost at the time of the reader swap.
|
|
* @reader.id: subbuf ID of the current reader. ID range [0 : @nr_subbufs - 1]
|
|
* @reader.read: Number of bytes read on the reader subbuf.
|
|
* @flags: Placeholder for now, 0 until new features are supported.
|
|
* @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: Internal use only.
|
|
* @Reserved2: Internal use only.
|
|
*/
|
|
struct trace_buffer_meta {
|
|
__u32 meta_page_size;
|
|
__u32 meta_struct_len;
|
|
|
|
__u32 subbuf_size;
|
|
__u32 nr_subbufs;
|
|
|
|
struct {
|
|
__u64 lost_events;
|
|
__u32 id;
|
|
__u32 read;
|
|
} reader;
|
|
|
|
__u64 flags;
|
|
|
|
__u64 entries;
|
|
__u64 overrun;
|
|
__u64 read;
|
|
|
|
__u64 Reserved1;
|
|
__u64 Reserved2;
|
|
};
|
|
|
|
#define TRACE_MMAP_IOCTL_GET_READER _IO('T', 0x1)
|
|
|
|
#endif /* _TRACE_MMAP_H_ */
|