[PATCH bpf-next v2 00/14] add libbpf getters for individual ringbuffers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch series adds a new ring__ API to libbpf exposing getters for
accessing the individual ringbuffers inside a struct ring_buffer. This is
useful for polling individually, getting available data, or similar use
cases. The API looks like this, and was roughly proposed by Andrii Nakryiko
in another thread:

Getting a ring struct:
struct ring *ring_buffer__ring(struct ring_buffer *rb, unsigned int idx);

Using the ring struct:
unsigned long ring__consumer_pos(const struct ring *r);
unsigned long ring__producer_pos(const struct ring *r);
size_t ring__avail_data_size(const struct ring *r);
size_t ring__size(const struct ring *r);
int ring__map_fd(const struct ring *r);
int ring__consume(struct ring *r);

Changes in v2:
- Addressed all feedback from Andrii Nakryiko

Martin Kelly (14):
  libbpf: refactor cleanup in ring_buffer__add
  libbpf: switch rings to array of pointers
  libbpf: add ring_buffer__ring
  selftests/bpf: add tests for ring_buffer__ring
  libbpf: add ring__producer_pos, ring__consumer_pos
  selftests/bpf: add tests for ring__*_pos
  libbpf: add ring__avail_data_size
  selftests/bpf: add tests for ring__avail_data_size
  libbpf: add ring__size
  selftests/bpf: add tests for ring__size
  libbpf: add ring__map_fd
  selftests/bpf: add tests for ring__map_fd
  libbpf: add ring__consume
  selftests/bpf: add tests for ring__consume

 tools/lib/bpf/libbpf.h                        | 73 ++++++++++++++++
 tools/lib/bpf/libbpf.map                      |  7 ++
 tools/lib/bpf/ringbuf.c                       | 85 ++++++++++++++++---
 .../selftests/bpf/prog_tests/ringbuf.c        | 26 ++++++
 .../selftests/bpf/prog_tests/ringbuf_multi.c  | 15 ++++
 5 files changed, 193 insertions(+), 13 deletions(-)

-- 
2.34.1





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux