From: Yonghong Song <yonghong.song@linux.dev>
To: Adam Sindelar <adam@wowsignal.io>, bpf@vger.kernel.org
Cc: Adam Sindelar <ats@fb.com>, David Vernet <void@manifault.com>,
Brendan Jackman <jackmanb@google.com>,
KP Singh <kpsingh@chromium.org>,
linux-kernel@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Florent Revest <revest@chromium.org>
Subject: Re: [PATCH bpf-next v4] libbpf: Expose API to consume one ring at a time
Date: Thu, 27 Jul 2023 15:11:00 -0700 [thread overview]
Message-ID: <38a585f1-fcbe-01ec-cc4c-63058b824f2f@linux.dev> (raw)
In-Reply-To: <20230727083436.293201-1-adam@wowsignal.io>
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@wowsignal.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.
>
> 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);
>
[...]
next prev parent reply other threads:[~2023-07-27 22:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-27 8:34 Adam Sindelar
2023-07-27 19:00 ` John Fastabend
2023-07-27 21:02 ` Adam Sindelar
2023-07-27 22:11 ` Yonghong Song [this message]
2023-07-28 7:32 ` Adam Sindelar
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=38a585f1-fcbe-01ec-cc4c-63058b824f2f@linux.dev \
--to=yonghong.song@linux.dev \
--cc=adam@wowsignal.io \
--cc=ast@kernel.org \
--cc=ats@fb.com \
--cc=bpf@vger.kernel.org \
--cc=jackmanb@google.com \
--cc=kpsingh@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=revest@chromium.org \
--cc=void@manifault.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®