bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Jonathan Corbet <corbet@lwn.net>
Cc: Jens Axboe <axboe@kernel.dk>,
	io-uring@vger.kernel.org,
	Caleb Sander Mateos <csander@purestorage.com>,
	Akilesh Kailash <akailash@google.com>,
	bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>
Subject: Re: [PATCH 3/5] io_uring: bpf: extend io_uring with bpf struct_ops
Date: Thu, 20 Nov 2025 09:46:06 +0800	[thread overview]
Message-ID: <aR5y3pFTgDDNptdx@fedora> (raw)
In-Reply-To: <87346a2ijz.fsf@trenco.lwn.net>

On Wed, Nov 19, 2025 at 07:39:12AM -0700, Jonathan Corbet wrote:
> Ming Lei <ming.lei@redhat.com> writes:
> 
> > io_uring can be extended with bpf struct_ops in the following ways:
> 
> So I have a probably dumb question I ran into as I tried to figure this
> stuff out.  You define this maximum here...
> 
> > +#define MAX_BPF_OPS_COUNT	(1 << IORING_BPF_OP_BITS)
> 
> ...which sizes the bpf_ops array:
> 
> > +static struct uring_bpf_ops bpf_ops[MAX_BPF_OPS_COUNT];
> 
> Later, you do registration here:
> 
> > +static int io_bpf_reg_unreg(struct uring_bpf_ops *ops, bool reg)
> > +{
> > +	struct io_ring_ctx *ctx;
> > +	int ret = 0;
> > +
> > +	guard(mutex)(&uring_bpf_ctx_lock);
> > +	list_for_each_entry(ctx, &uring_bpf_ctx_list, bpf_node)
> > +		mutex_lock(&ctx->uring_lock);
> > +
> > +	if (reg) {
> > +		if (bpf_ops[ops->id].issue_fn)
> > +			ret = -EBUSY;
> > +		else
> > +			bpf_ops[ops->id] = *ops;
> > +	} else {
> > +		bpf_ops[ops->id] = (struct uring_bpf_ops) {0};
> > +	}
> > +
> > +	synchronize_srcu(&uring_bpf_srcu);
> > +
> > +	list_for_each_entry(ctx, &uring_bpf_ctx_list, bpf_node)
> > +		mutex_unlock(&ctx->uring_lock);
> > +
> > +	return ret;
> > +}
> 
> Nowhere do I find a test ensuring that ops->id is within range;
> MAX_BPF_OPS_COUNT never appears in a test.  What am I missing?

bits of `ops->id` is limited by IORING_BPF_OP_BITS and it is stored in top
8bits of ->bpf_flags, so ops->id is within the range naturally.


Thanks,
Ming


  reply	other threads:[~2025-11-20  1:46 UTC|newest]

Thread overview: 29+ 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-11-04 16:21 ` [PATCH 2/5] io_uring: bpf: add io_uring_ctx setup for BPF into one list Ming Lei
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 [this message]
2025-11-20  1:51       ` Ming Lei
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-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-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=aR5y3pFTgDDNptdx@fedora \
    --to=ming.lei@redhat.com \
    --cc=akailash@google.com \
    --cc=ast@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=bpf@vger.kernel.org \
    --cc=corbet@lwn.net \
    --cc=csander@purestorage.com \
    --cc=io-uring@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).