public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] libbpf: API to partially consume items from ringbuffer
@ 2024-04-01  7:19 Andrea Righi
  2024-04-01  7:19 ` [PATCH 1/2] libbpf: ringbuf: allow to consume up to a certain amount of items Andrea Righi
  2024-04-01  7:19 ` [PATCH 2/2] libbpf: Add ring__consume_max / ring_buffer__consume_max Andrea Righi
  0 siblings, 2 replies; 7+ messages in thread
From: Andrea Righi @ 2024-04-01  7:19 UTC (permalink / raw)
  To: Andrii Nakryiko, Eduard Zingerman
  Cc: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, David Vernet, Tejun Heo, bpf, linux-kernel

Introduce ring__consume_max() and ring_buffer__consume_max() API to
partially consume items from one (or more) ringbuffer(s).

This can be useful, for example, to consume just a single item or when
we need to copy multiple items to a limited user-space buffer from the
ringbuffer callback.

Practical example (where this API can be used):
https://github.com/sched-ext/scx/blob/b7c06b9ed9f72cad83c31e39e9c4e2cfd8683a55/rust/scx_rustland_core/src/bpf.rs#L217

See also:
https://lore.kernel.org/lkml/20240310154726.734289-1-andrea.righi@canonical.com/T/#u

v2:
 - introduce a new API instead of changing the callback's retcode
   behavior

Andrea Righi (2):
      libbpf: ringbuf: allow to consume up to a certain amount of items
      libbpf: Add ring__consume_max / ring_buffer__consume_max

 tools/lib/bpf/libbpf.h   | 13 +++++++++++++
 tools/lib/bpf/libbpf.map |  2 ++
 tools/lib/bpf/ringbuf.c  | 62 +++++++++++++++++++++++++++++++++++++++++++++++++-------------

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-04-02 20:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-01  7:19 [PATCH v2 0/2] libbpf: API to partially consume items from ringbuffer Andrea Righi
2024-04-01  7:19 ` [PATCH 1/2] libbpf: ringbuf: allow to consume up to a certain amount of items Andrea Righi
2024-04-02 17:58   ` Andrii Nakryiko
2024-04-02 20:37     ` Andrea Righi
2024-04-01  7:19 ` [PATCH 2/2] libbpf: Add ring__consume_max / ring_buffer__consume_max Andrea Righi
2024-04-02 18:04   ` Andrii Nakryiko
2024-04-02 20:41     ` Andrea Righi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox