Skip to content

Libbpf userspace function perf_buffer__buffer

1.0.0

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 structure
  • buf_idx: the buffer index to retrieve
  • buf: (out) gets the base pointer of the mmap'ed memory
  • buf_size: (out) gets the size of the mmap'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 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