On 6/6/25 7:58 AM, Pavel Begunkov wrote: > Add ring_fd to the struct_ops and implement [un]registration. > > Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx> > --- > io_uring/bpf.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++- > io_uring/bpf.h | 3 +++ > 2 files changed, 69 insertions(+), 1 deletion(-) > > diff --git a/io_uring/bpf.c b/io_uring/bpf.c > index 3096c54e4fb3..0f82acf09959 100644 > --- a/io_uring/bpf.c > +++ b/io_uring/bpf.c > @@ -3,6 +3,8 @@ > #include "bpf.h" > #include "register.h" > > +DEFINE_MUTEX(io_bpf_ctrl_mutex); > + > static struct io_uring_ops io_bpf_ops_stubs = { > }; > > @@ -50,20 +52,83 @@ static int bpf_io_init_member(const struct btf_type *t, > const struct btf_member *member, > void *kdata, const void *udata) > { > + u32 moff = __btf_member_bit_offset(t, member) / 8; > + const struct io_uring_ops *uops = udata; > + struct io_uring_ops *ops = kdata; > + > + switch (moff) { > + case offsetof(struct io_uring_ops, ring_fd): > + ops->ring_fd = uops->ring_fd; > + return 1; > + } > + return 0; Possible to pass in here whether the ring fd is registered or not? Such that it can be used in bpf_io_reg() as well. > +static int io_register_bpf_ops(struct io_ring_ctx *ctx, struct io_uring_ops *ops) > +{ > + if (ctx->bpf_ops) > + return -EBUSY; > + if (!(ctx->flags & IORING_SETUP_DEFER_TASKRUN)) > + return -EOPNOTSUPP; > + > + percpu_ref_get(&ctx->refs); > + ops->ctx = ctx; > + ctx->bpf_ops = ops; > return 0; > } Haven't looked too deeply yet, but what's the dependency with DEFER_TASKRUN? -- Jens Axboe