From: Caleb Sander Mateos <csander@purestorage.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
io-uring@vger.kernel.org, Akilesh Kailash <akailash@google.com>,
bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>
Subject: Re: [PATCH 4/5] io_uring: bpf: add buffer support for IORING_OP_BPF
Date: Wed, 31 Dec 2025 12:02:19 -0500 [thread overview]
Message-ID: <CADUfDZqwZQAkgS-Co=qmbKxiK1A0hoEP8XW0uHX_Z5M6tCDGMw@mail.gmail.com> (raw)
In-Reply-To: <aVUCsQ2fuOP_hfPF@fedora>
On Wed, Dec 31, 2025 at 3:02 AM Ming Lei <ming.lei@redhat.com> wrote:
>
> On Tue, Dec 30, 2025 at 08:42:11PM -0500, Caleb Sander Mateos wrote:
> > On Tue, Nov 4, 2025 at 8:22 AM Ming Lei <ming.lei@redhat.com> wrote:
> > >
> > > Add support for passing 0-2 buffers to BPF operations through
> > > IORING_OP_BPF. Buffer types are encoded in sqe->bpf_op_flags
> > > using dedicated 3-bit fields for each buffer.
> >
> > I agree the 2 buffer limit seems a bit restrictive, and it would make
> > more sense to expose kfuncs to import plain and fixed buffers. Then
> > the BPF program could decide what buffers to import based on the SQE,
> > BPF maps, etc. This would be analogous to how uring_cmd
> > implementations import buffers.
>
> Yes, this way is too restrictive.
>
> I think there are at least two approaches:
>
> - define public buffer descriptor, which can describe plain, fixed, vector,
> fixed vector buffer, ...
>
> - user can pass this buffer descriptor array from sqe->addr & sqe->len (buf descriptor
> need to be defined in UAPI)
>
> OR
>
> - user can pass this buffer array from arena map (buf descriptor is just
> API between bpf prog and userspace)
>
> The former could be better, because `buf descriptor` is part of UAPI, and
> user still can choose to use bpf map to pass buffer. But defining 'buf
> descriptor' may take a while...
>
> The latter way could be easier to start...
I think the latter approach (buffer interface specific to io_uring BPF
program) probably makes more sense. Different programs may have
different buffer needs (e.g. 1 buffer, 2 buffers, an arbitrary number
of buffers). Programs that need an arbitrary number of buffers will
probably have to specify the address and length of a struct iovec
array in the SQE, or communicate via some BPF map. But this additional
indirection would add unnecessary overhead for programs that only
accept 1 or 2 buffers. Leaving it up to the io_uring BPF program how
to interpret the SQE fields makes a lot of sense to me, as
->uring_cmd() implementations already have that responsibility.
>
> >
> > >
> > > Buffer 1 can be:
> > > - None (no buffer)
> > > - Plain user buffer (addr=sqe->addr, len=sqe->len)
> > > - Fixed/registered buffer (index=sqe->buf_index, offset=sqe->addr,
> >
> > Should this say "addr=" instead of "offset="? It's passed as buf_addr
> > to io_bpf_import_buffer(), so it's an absolute userspace address. The
> > offset into the fixed buffer depends on the starting address of the
> > fixed buffer.
>
> For user fixed buffer, offset is the buff addr.
>
> For kernel fixed buffer, it is offset.
Yes, good point. I think fixed buffers are usually described in terms
of user registered buffers (probably since those were the only kind of
registered buffers until recently). It wouldn't hurt to be explicit
that addr vs. offset depends on the type of registered buffer. I think
it would also be fine to just say that this is an addr for both kinds
of buffers, as you can think of kernel registered buffers as
implicitly having a starting address of 0.
Best,
Caleb
next prev parent reply other threads:[~2025-12-31 17:02 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-04 16:21 [PATCH 0/5] io_uring: add IORING_OP_BPF for extending io_uring Ming Lei
2025-11-04 16:21 ` [PATCH 1/5] io_uring: prepare for extending io_uring with bpf Ming Lei
2025-12-31 1:13 ` Caleb Sander Mateos
2025-12-31 9:33 ` Ming Lei
2025-11-04 16:21 ` [PATCH 2/5] io_uring: bpf: add io_uring_ctx setup for BPF into one list Ming Lei
2025-12-31 1:13 ` Caleb Sander Mateos
2025-12-31 9:49 ` Ming Lei
2025-12-31 16:19 ` Caleb Sander Mateos
2025-11-04 16:21 ` [PATCH 3/5] io_uring: bpf: extend io_uring with bpf struct_ops Ming Lei
2025-11-07 19:02 ` kernel test robot
2025-11-08 6:53 ` kernel test robot
2025-11-13 10:32 ` Stefan Metzmacher
2025-11-13 10:59 ` Ming Lei
2025-11-13 11:19 ` Stefan Metzmacher
2025-11-14 3:00 ` Ming Lei
2025-12-08 22:45 ` Caleb Sander Mateos
2025-12-09 3:08 ` Ming Lei
2025-12-10 16:11 ` Caleb Sander Mateos
2025-11-19 14:39 ` Jonathan Corbet
2025-11-20 1:46 ` Ming Lei
2025-11-20 1:51 ` Ming Lei
2025-12-31 1:19 ` Caleb Sander Mateos
2025-12-31 10:32 ` Ming Lei
2025-12-31 16:48 ` Caleb Sander Mateos
2025-11-04 16:21 ` [PATCH 4/5] io_uring: bpf: add buffer support for IORING_OP_BPF Ming Lei
2025-11-13 10:42 ` Stefan Metzmacher
2025-11-13 11:04 ` Ming Lei
2025-11-13 11:25 ` Stefan Metzmacher
2025-12-31 1:42 ` Caleb Sander Mateos
2025-12-31 11:02 ` Ming Lei
2025-12-31 17:02 ` Caleb Sander Mateos [this message]
2025-11-04 16:21 ` [PATCH 5/5] io_uring: bpf: add io_uring_bpf_req_memcpy() kfunc Ming Lei
2025-11-07 18:51 ` kernel test robot
2025-12-31 1:42 ` Caleb Sander Mateos
2025-11-05 12:47 ` [PATCH 0/5] io_uring: add IORING_OP_BPF for extending io_uring Pavel Begunkov
2025-11-05 15:57 ` Ming Lei
2025-11-06 16:03 ` Pavel Begunkov
2025-11-07 15:54 ` Ming Lei
2025-11-11 14:07 ` Pavel Begunkov
2025-11-13 4:18 ` Ming Lei
2025-11-19 19:00 ` Pavel Begunkov
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='CADUfDZqwZQAkgS-Co=qmbKxiK1A0hoEP8XW0uHX_Z5M6tCDGMw@mail.gmail.com' \
--to=csander@purestorage.com \
--cc=akailash@google.com \
--cc=ast@kernel.org \
--cc=axboe@kernel.dk \
--cc=bpf@vger.kernel.org \
--cc=io-uring@vger.kernel.org \
--cc=ming.lei@redhat.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