From: Andrea Righi <andrea.righi@canonical.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, David Vernet <void@manifault.com>,
Tejun Heo <tj@kernel.org>,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 0/2] libbpf: API to partially consume items from ringbuffer
Date: Sat, 6 Apr 2024 10:13:37 +0200 [thread overview]
Message-ID: <ZhEEMU_M2qSISfxB@gpd> (raw)
In-Reply-To: <CAEf4BzZyd2T_S+46NcKsM-Vv0mMnsgGd_Hzaq7tn4DFkD+GOGw@mail.gmail.com>
On Fri, Apr 05, 2024 at 04:16:34PM -0700, Andrii Nakryiko wrote:
> On Fri, Apr 5, 2024 at 3:36 PM Andrea Righi <andrea.righi@canonical.com> 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]).
Yep, I wasn't sure if should have bumped up the version as well
(in libbpf_version.h). I'll add that.
>
> Please also add a simple test to BPF selftests using the new API.
> Other than that the changes look good.
Ok, will add a selftest.
Thanks,
-Andrea
>
> [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(-)
prev parent reply other threads:[~2024-04-06 8:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-05 22:16 [PATCH v3 0/2] libbpf: API to partially consume items from ringbuffer Andrea Righi
2024-04-05 22:16 ` [PATCH v3 1/2] libbpf: ringbuf: allow to consume up to a certain amount of items Andrea Righi
2024-04-05 22:16 ` [PATCH v3 2/2] libbpf: Add ring__consume_n / ring_buffer__consume_n Andrea Righi
2024-04-05 23:16 ` [PATCH v3 0/2] libbpf: API to partially consume items from ringbuffer Andrii Nakryiko
2024-04-06 8:13 ` Andrea Righi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZhEEMU_M2qSISfxB@gpd \
--to=andrea.righi@canonical.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=tj@kernel.org \
--cc=void@manifault.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.