mbox series

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

Message ID 20230925215045.2375758-1-martin.kelly@crowdstrike.com (mailing list archive)
Headers show
Series add libbpf getters for individual ringbuffers | expand

Message

Martin Kelly Sept. 25, 2023, 9:50 p.m. UTC
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(-)

Comments

patchwork-bot+netdevbpf@kernel.org Sept. 25, 2023, 11:30 p.m. UTC | #1
Hello:

This series was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Mon, 25 Sep 2023 14:50:31 -0700 you wrote:
> 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);
> 
> [...]

Here is the summary with links:
  - [bpf-next,v2,01/14] libbpf: refactor cleanup in ring_buffer__add
    https://git.kernel.org/bpf/bpf-next/c/4448f64c549c
  - [bpf-next,v2,02/14] libbpf: switch rings to array of pointers
    https://git.kernel.org/bpf/bpf-next/c/ef3b82003e6c
  - [bpf-next,v2,03/14] libbpf: add ring_buffer__ring
    https://git.kernel.org/bpf/bpf-next/c/1c97f6afd739
  - [bpf-next,v2,04/14] selftests/bpf: add tests for ring_buffer__ring
    https://git.kernel.org/bpf/bpf-next/c/c1ad2e47f97c
  - [bpf-next,v2,05/14] libbpf: add ring__producer_pos, ring__consumer_pos
    https://git.kernel.org/bpf/bpf-next/c/059a8c0c5acd
  - [bpf-next,v2,06/14] selftests/bpf: add tests for ring__*_pos
    https://git.kernel.org/bpf/bpf-next/c/b18db8712ecf
  - [bpf-next,v2,07/14] libbpf: add ring__avail_data_size
    https://git.kernel.org/bpf/bpf-next/c/3b34d2972612
  - [bpf-next,v2,08/14] selftests/bpf: add tests for ring__avail_data_size
    https://git.kernel.org/bpf/bpf-next/c/f3a01d385fbb
  - [bpf-next,v2,09/14] libbpf: add ring__size
    https://git.kernel.org/bpf/bpf-next/c/e79abf717fce
  - [bpf-next,v2,10/14] selftests/bpf: add tests for ring__size
    https://git.kernel.org/bpf/bpf-next/c/bb32dd2c8fec
  - [bpf-next,v2,11/14] libbpf: add ring__map_fd
    https://git.kernel.org/bpf/bpf-next/c/ae769390377a
  - [bpf-next,v2,12/14] selftests/bpf: add tests for ring__map_fd
    https://git.kernel.org/bpf/bpf-next/c/6e38ba5291f9
  - [bpf-next,v2,13/14] libbpf: add ring__consume
    https://git.kernel.org/bpf/bpf-next/c/16058ff28b7e
  - [bpf-next,v2,14/14] selftests/bpf: add tests for ring__consume
    https://git.kernel.org/bpf/bpf-next/c/cb3d7dd2d0db

You are awesome, thank you!