Libbpf userspace function perf_buffer__new_raw
Same as perf_buffer__new
but with more control over parameters which perf_buffer__new
auto-detects.
Definition
struct perf_buffer * perf_buffer__new_raw(int map_fd, size_t page_cnt, struct perf_event_attr *attr, perf_buffer_event_fn event_cb, void *ctx, const struct perf_buffer_raw_opts *opts);
Parameters
map_fd
: file descriptor ofBPF_PERF_EVENT_ARRAY
BPF map that will be used by BPF code to send data over to user-spacepage_cnt
: number of memory pages allocated for each per-CPU buffersample_cb
: function called on each received data recordlost_cb
: function called when record loss has occurredctx
: user-provided extra context passed intosample_cb
andlost_cb
opts
: options for the perf buffer
Return
A new instance of struct perf_buffer
on success, NULL
on error with errno
containing an error code.
struct perf_buffer_raw_opts
struct perf_buffer_raw_opts {
size_t sz;
long :0;
long :0;
/* if cpu_cnt == 0, open all on all possible CPUs (up to the number of
* max_entries of given PERF_EVENT_ARRAY map)
*/
int cpu_cnt;
/* if cpu_cnt > 0, cpus is an array of CPUs to open ring buffers on */
int *cpus;
/* if cpu_cnt > 0, map_keys specify map keys to set per-CPU FDs for */
int *map_keys;
};
cpu_cnt
If cpu_cnt == 0
, open all on all possible CPUs (up to the number of max_entries
of given BPF_MAP_TYPE_PERF_EVENT_ARRAY
map).
cpus
if cpu_cnt > 0
, cpus is an array of CPUs to open ring buffers on.
map_keys
if cpu_cnt > 0
, map_keys
specify map keys to set per-CPU FDs for.
Usage
Docs could be improved
This part of the docs is incomplete, contributions are very welcome
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome