Libbpf userspace function user_ring_buffer__reserve
Reserves a pointer to a sample in the user ring buffer.
Definition
void *user_ring_buffer__reserve(struct user_ring_buffer *rb, __u32 size);
Parameters
rb
: A pointer to a user ring buffer.size
: The size of the sample, in bytes.
Return
A pointer to an 8-byte aligned reserved region of the user ring
buffer; NULL
, and errno
being set if a sample could not be reserved.
Usage
This function is not
thread safe, and callers must synchronize accessing this function if there are multiple producers. If a size is requested that is larger than the size of the entire ring buffer, errno
will be set to E2BIG
and NULL
is returned. If the ring buffer could accommodate the size, but currently does not have enough space, errno
is set to ENOSPC
and NULL
is returned.
After initializing the sample, callers must invoke user_ring_buffer__submit
to post the sample to the kernel. Otherwise, the sample must be freed with user_ring_buffer__discard
.
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome