Libbpf userspace function perf_buffer__buffer
Returns the per-CPU raw mmap'ed underlying memory region of the ring buffer.
Definition
int perf_buffer__buffer(struct perf_buffer *pb, int buf_idx, void **buf, size_t *buf_size);
Parameters
pb: the perf buffer structurebuf_idx: the buffer index to retrievebuf: (out) gets the base pointer of themmap'ed memorybuf_size: (out) gets the size of themmap'ed region
Return
0 on success, negative error code for failure
Usage
This ring buffer can be used to implement a custom events consumer. The ring buffer starts with the struct perf_event_mmap_page, which holds the ring buffer management fields, when accessing the header structure it's important to be perf_event_read_simple for a simple example.
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome