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] [day] [month] [year] [list]
Message-ID: <ZMNvE-v3oyFWt2R_@Momo.fritz.box>
Date:   Fri, 28 Jul 2023 09:32:35 +0200
From:   Adam Sindelar <adam@...signal.io>
To:     Yonghong Song <yonghong.song@...ux.dev>
Cc:     bpf@...r.kernel.org, Adam Sindelar <ats@...com>,
        David Vernet <void@...ifault.com>,
        Brendan Jackman <jackmanb@...gle.com>,
        KP Singh <kpsingh@...omium.org>, linux-kernel@...r.kernel.org,
        Alexei Starovoitov <ast@...nel.org>,
        Florent Revest <revest@...omium.org>
Subject: Re: [PATCH bpf-next v4] libbpf: Expose API to consume one ring at a
 time

On Thu, Jul 27, 2023 at 03:11:00PM -0700, Yonghong Song wrote:
> 
> 
> On 7/27/23 1:34 AM, Adam Sindelar wrote:
> > We already provide ring_buffer__epoll_fd to enable use of external
> > polling systems. However, the only API available to consume the ring
> > buffer is ring_buffer__consume, which always checks all rings. When
> > polling for many events, this can be wasteful.
> > 
> > Signed-off-by: Adam Sindelar <adam@...signal.io>
> > ---
> > v1->v2: Added entry to libbpf.map
> > v2->v3: Correctly set errno and handle overflow
> > v3->v4: Fixed an embarrasing typo from zealous autocomplete
> > 
> >   tools/lib/bpf/libbpf.h   |  1 +
> >   tools/lib/bpf/libbpf.map |  1 +
> >   tools/lib/bpf/ringbuf.c  | 22 ++++++++++++++++++++++
> >   3 files changed, 24 insertions(+)
> 
> Could you add a selftest to exercise ring_buffer__consume_ring()?
> This way, people can better understand how this API could be used.
> 

Yes, will do - I'll try to send out v5 with a test case this afternoon.

As a note, I looked at the perf ring buffer API and it turns out Andrii
Nakryiko saw the same problem and solved in a similar way in 2020. (See
perf_buffer__consume_buffer).

> > 
> > diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
> > index 55b97b2087540..20ccc65eb3f9d 100644
> > --- a/tools/lib/bpf/libbpf.h
> > +++ b/tools/lib/bpf/libbpf.h
> > @@ -1195,6 +1195,7 @@ LIBBPF_API int ring_buffer__add(struct ring_buffer *rb, int map_fd,
> >   				ring_buffer_sample_fn sample_cb, void *ctx);
> >   LIBBPF_API int ring_buffer__poll(struct ring_buffer *rb, int timeout_ms);
> >   LIBBPF_API int ring_buffer__consume(struct ring_buffer *rb);
> > +LIBBPF_API int ring_buffer__consume_ring(struct ring_buffer *rb, uint32_t ring_id);
> >   LIBBPF_API int ring_buffer__epoll_fd(const struct ring_buffer *rb);
> [...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ