lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 5 Apr 2024 16:16:34 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Andrea Righi <andrea.righi@...onical.com>
Cc: Andrii Nakryiko <andrii@...nel.org>, Eduard Zingerman <eddyz87@...il.com>, 
	Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>, 
	Martin KaFai Lau <martin.lau@...ux.dev>, Song Liu <song@...nel.org>, 
	Yonghong Song <yonghong.song@...ux.dev>, John Fastabend <john.fastabend@...il.com>, 
	KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...gle.com>, Hao Luo <haoluo@...gle.com>, 
	Jiri Olsa <jolsa@...nel.org>, David Vernet <void@...ifault.com>, Tejun Heo <tj@...nel.org>, 
	bpf@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 0/2] libbpf: API to partially consume items from ringbuffer

On Fri, Apr 5, 2024 at 3:36 PM Andrea Righi <andrea.righi@...onicalcom> wrote:
>
> Introduce ring__consume_n() and ring_buffer__consume_n() 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
>
> [ Note: I haven't implemented the special case of n == 0 as "no limit",
> because we still need to add a bunch of extra checks for INT_MAX, making
> the code less readable and, from a performance perspective, it seems
> that we may get more downsides than benefits, but I can try to look more
> at this if you think it's worth it ]
>
> v3:
>  - rename ring__consume_max() -> ring__consume_n() and
>    ring_buffer__consume_max() -> ring_buffer__consume_n()
>  - add new API to a new 1.5.0 cycle

You also need to update Makefile, CI is failing right now ([0]).

Please also add a simple test to BPF selftests using the new API.
Other than that the changes look good.

  [0] https://github.com/kernel-patches/bpf/actions/runs/8576515495/job/23507610313#step:11:73

pw-bot: cr

>  - fixed minor nits / comments
>
> 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_n / ring_buffer__consume_n
>
>  tools/lib/bpf/libbpf.h   | 12 ++++++++++
>  tools/lib/bpf/libbpf.map |  6 +++++
>  tools/lib/bpf/ringbuf.c  | 59 ++++++++++++++++++++++++++++++++++++++++--------
>  3 files changed, 67 insertions(+), 10 deletions(-)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ