mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
libbpf: Add ring__size
Add ring__size to get the total size of a given ringbuffer. Signed-off-by: Martin Kelly <martin.kelly@crowdstrike.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20230925215045.2375758-10-martin.kelly@crowdstrike.com
This commit is contained in:
parent
f3a01d385f
commit
e79abf717f
3 changed files with 16 additions and 0 deletions
|
|
@ -1293,6 +1293,16 @@ LIBBPF_API unsigned long ring__producer_pos(const struct ring *r);
|
||||||
*/
|
*/
|
||||||
LIBBPF_API size_t ring__avail_data_size(const struct ring *r);
|
LIBBPF_API size_t ring__avail_data_size(const struct ring *r);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief **ring__size()** returns the total size of the ringbuffer's map data
|
||||||
|
* area (excluding special producer/consumer pages). Effectively this gives the
|
||||||
|
* amount of usable bytes of data inside the ringbuffer.
|
||||||
|
*
|
||||||
|
* @param r A ringbuffer object.
|
||||||
|
* @return The total size of the ringbuffer map data area.
|
||||||
|
*/
|
||||||
|
LIBBPF_API size_t ring__size(const struct ring *r);
|
||||||
|
|
||||||
struct user_ring_buffer_opts {
|
struct user_ring_buffer_opts {
|
||||||
size_t sz; /* size of this struct, for forward/backward compatibility */
|
size_t sz; /* size of this struct, for forward/backward compatibility */
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -403,5 +403,6 @@ LIBBPF_1.3.0 {
|
||||||
ring__avail_data_size;
|
ring__avail_data_size;
|
||||||
ring__consumer_pos;
|
ring__consumer_pos;
|
||||||
ring__producer_pos;
|
ring__producer_pos;
|
||||||
|
ring__size;
|
||||||
ring_buffer__ring;
|
ring_buffer__ring;
|
||||||
} LIBBPF_1.2.0;
|
} LIBBPF_1.2.0;
|
||||||
|
|
|
||||||
|
|
@ -361,6 +361,11 @@ size_t ring__avail_data_size(const struct ring *r)
|
||||||
return prod_pos - cons_pos;
|
return prod_pos - cons_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t ring__size(const struct ring *r)
|
||||||
|
{
|
||||||
|
return r->mask + 1;
|
||||||
|
}
|
||||||
|
|
||||||
static void user_ringbuf_unmap_ring(struct user_ring_buffer *rb)
|
static void user_ringbuf_unmap_ring(struct user_ring_buffer *rb)
|
||||||
{
|
{
|
||||||
if (rb->consumer_pos) {
|
if (rb->consumer_pos) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue