From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: io-uring@vger.kernel.org,
Caleb Sander Mateos <csander@purestorage.com>,
Akilesh Kailash <akailash@google.com>,
bpf@vger.kernel.org, Xiao Ni <xni@redhat.com>,
Alexei Starovoitov <ast@kernel.org>
Subject: Re: [PATCH V3 05/12] io_uring: bpf: extend io_uring with bpf struct_ops
Date: Fri, 3 Apr 2026 12:05:24 +0800 [thread overview]
Message-ID: <ac88hCYgrFXBX3-g@fedora> (raw)
In-Reply-To: <5e8766d3-a801-48e0-8d27-60e75523ebd1@kernel.dk>
On Wed, Mar 25, 2026 at 07:49:22PM -0600, Jens Axboe wrote:
> On 3/24/26 10:37 AM, Ming Lei wrote:
> > @@ -493,7 +494,16 @@ struct io_ring_ctx {
> > DECLARE_HASHTABLE(napi_ht, 4);
> > #endif
> >
> > - struct io_uring_bpf_ops *bpf_ops;
> > + /*
> > + * bpf_ops and bpf_ext_ops are mutually exclusive: bpf_ops is used
> > + * for io_uring_bpf_ops struct_ops, while bpf_ext_ops provides
> > + * per-opcode BPF extension operations (IORING_SETUP_BPF_EXT).
> > + * The two cannot be active at the same time on the same ring.
> > + */
> > + union {
> > + struct io_uring_bpf_ops *bpf_ops;
> > + struct uring_bpf_ops_kern *bpf_ext_ops;
> > + };
>
> What am I missing here, why is this the case? What makes the use of both
> at the same time impossible?
Please see the following code:
static inline bool io_has_loop_ops(struct io_ring_ctx *ctx)
{
return data_race(ctx->loop_step);
}
io_uring_enter():
...
if (io_has_loop_ops(ctx)) {
ret = io_run_loop(ctx);
goto out;
}
...
So if ->loop_step is assigned from io_install_bpf() called from bpf_ops
registration, traditional userspace SQE submission and CQE reap are
bypassed completely, then IORING_OP_BPF and any other OP can't be handled
at all.
>
> > diff --git a/io_uring/bpf-ops.c b/io_uring/bpf-ops.c
> > index e4b244337aa9..e91c6964405c 100644
> > --- a/io_uring/bpf-ops.c
> > +++ b/io_uring/bpf-ops.c
> > @@ -162,7 +162,6 @@ static int io_install_bpf(struct io_ring_ctx *ctx, struct io_uring_bpf_ops *ops)
> > return -EOPNOTSUPP;
> > if (!(ctx->flags & IORING_SETUP_DEFER_TASKRUN))
> > return -EOPNOTSUPP;
> > -
> > if (ctx->bpf_ops)
> > return -EBUSY;
> > if (WARN_ON_ONCE(!ops->loop_step))
>
> Spurious whitespace change.
Will remove it in next version.
>
> > diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h
> > index 91cf67b5d85b..1af33a89ed2f 100644
> > --- a/io_uring/io_uring.h
> > +++ b/io_uring/io_uring.h
> > @@ -49,7 +49,8 @@ struct io_ctx_config {
> > IORING_FEAT_RECVSEND_BUNDLE |\
> > IORING_FEAT_MIN_TIMEOUT |\
> > IORING_FEAT_RW_ATTR |\
> > - IORING_FEAT_NO_IOWAIT)
> > + IORING_FEAT_NO_IOWAIT |\
> > + IORING_FEAT_BPF)
>
> Do we need this FEAT flag? If you think so, then it should at least be
> dependent on whether the kernel supports this feature, eg if
> CONFIG_IO_URING_BPF_EXT is set
Good catch!
Thanks,
Ming
next prev parent reply other threads:[~2026-04-03 4:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 16:37 [PATCH v3 0/12] io_uring: add IORING_OP_BPF for extending io_uring Ming Lei
2026-03-24 16:37 ` [PATCH V3 01/12] io_uring: make io_import_fixed() global Ming Lei
2026-03-24 16:37 ` [PATCH V3 02/12] io_uring: refactor io_prep_reg_iovec() for BPF kfunc use Ming Lei
2026-03-24 16:37 ` [PATCH V3 03/12] io_uring: refactor io_import_reg_vec() " Ming Lei
2026-03-24 16:37 ` [PATCH V3 04/12] io_uring: prepare for extending io_uring with bpf Ming Lei
2026-03-24 16:37 ` [PATCH V3 05/12] io_uring: bpf: extend io_uring with bpf struct_ops Ming Lei
2026-03-26 1:49 ` Jens Axboe
2026-04-03 4:05 ` Ming Lei [this message]
2026-04-03 15:44 ` Jens Axboe
2026-04-04 2:53 ` Ming Lei
2026-03-26 2:09 ` Jens Axboe
2026-04-03 4:17 ` Ming Lei
2026-04-03 15:46 ` Jens Axboe
2026-04-04 2:54 ` Ming Lei
2026-03-24 16:37 ` [PATCH V3 06/12] io_uring: bpf: implement struct_ops registration Ming Lei
2026-03-24 16:37 ` [PATCH V3 07/12] io_uring: bpf: add BPF buffer descriptor for IORING_OP_BPF Ming Lei
2026-03-24 16:37 ` [PATCH V3 08/12] io_uring: bpf: add per-buffer iterator kfuncs Ming Lei
2026-03-24 16:37 ` [PATCH V3 09/12] bpf: add bpf_uring_buf_dynptr to special_kfunc_list Ming Lei
2026-03-24 16:37 ` [PATCH V3 10/12] selftests/io_uring: add io_uring_unregister_buffers() Ming Lei
2026-03-24 16:37 ` [PATCH V3 11/12] selftests/io_uring: add BPF struct_ops and kfunc tests Ming Lei
2026-03-24 16:37 ` [PATCH V3 12/12] selftests/io_uring: add buffer iterator selftest with BPF arena Ming Lei
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=ac88hCYgrFXBX3-g@fedora \
--to=ming.lei@redhat.com \
--cc=akailash@google.com \
--cc=ast@kernel.org \
--cc=axboe@kernel.dk \
--cc=bpf@vger.kernel.org \
--cc=csander@purestorage.com \
--cc=io-uring@vger.kernel.org \
--cc=xni@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