| title | Libbpf userspace function 'perf_buffer__buffer' |
|---|---|
| description | This page documents the 'perf_buffer__buffer' libbpf userspace function, including its definition, usage, and examples. |
Returns the per-CPU raw mmap'ed underlying memory region of the ring buffer.
#!c 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
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 SMP aware. You can refer to perf_event_read_simple for a simple example.
!!! example "Docs could be improved" This part of the docs is incomplete, contributions are very welcome