public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: David Wei <dw@davidwei.uk>,
	io-uring@vger.kernel.org, netdev@vger.kernel.org
Cc: Pavel Begunkov <asml.silence@gmail.com>
Subject: Re: [PATCH v1] io_uring zcrx: allow sharing of ifqs with other instances
Date: Fri, 24 Oct 2025 07:01:15 -0600	[thread overview]
Message-ID: <e3c4b0c5-72e1-4a2d-a9bf-2e57b1e191ae@kernel.dk> (raw)
In-Reply-To: <20251023213922.3451751-1-dw@davidwei.uk>

On 10/23/25 3:39 PM, David Wei wrote:
> Each ifq is bound to a HW RX queue with no way to share this across
> multiple io_uring instances. It is possible that one io_uring instance
> will not be able to fully saturate an entire HW RX queue. To handle more
> work the only way is to add additional io_uring instances w/ ifqs, but
> HW RX queues are a limited resource on a system.
> 
> From userspace it is possible to move work from this io_uring instance
> w/ an ifq to other threads, but this will incur context switch overhead.
> What I'd like to do is share an ifq (and hence a HW RX queue) across
> multiple rings.
> 
> Add a way for io_uring instances to clone an ifq from another. This is
> done by passing a new flag IORING_ZCRX_IFQ_REG_CLONE in the registration
> struct io_uring_zcrx_ifq_reg, alongside the fd and ifq id of the ifq to
> be cloned.
> 
> The cloned ifq holds two refs:
>   1. On the source io_ring_ctx percpu_ref
>   2. On the source ifq refcount_t
> 
> This ensures that the source ifq and ring ctx remains valid while there
> are proxies.
> 
> The only way to destroy an ifq today is to destroy the entire ring, so
> both the real ifq and the proxy ifq are freed together.
> 
> At runtime, io_zcrx_recv_frag checks the ifq in the net_iov->priv field.
> This is expected to be the primary ifq that is bound to a HW RX queue,
> and is what prevents another ring from issuing io_recvzc on a zero copy
> socket. Once a secondary ring clones the ifq, this check will pass.
> 
> It's expected for userspace to coordinate the sharing and
> synchronisation of the refill queue when returning buffers. The kernel
> is not involved at all.
> 
> It's also expected userspace to distributed accepted sockets with
> connections steered to zero copy queues across multiple rings for load
> balancing.

I think this would be a lot easier to review, if you split out a few
things. Like:

The locking of two rings, just make that a prep patch. You also need
to change the name, it's too generic. That was fine when it was a
static in a single file, but should be better now.

Add the reference counting. It looks a bit suspicious on the
io_shutdown_zcrx_ifqs() side, having it separate would also make
that clearer.

And then you can have the meat of it on top of those.

Side note - you need to check the return value of kzalloc(), it can
indeed return NULL.

-- 
Jens Axboe

  reply	other threads:[~2025-10-24 13:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-23 21:39 [PATCH v1] io_uring zcrx: allow sharing of ifqs with other instances David Wei
2025-10-24 13:01 ` Jens Axboe [this message]
2025-10-24 16:26   ` David Wei

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=e3c4b0c5-72e1-4a2d-a9bf-2e57b1e191ae@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=asml.silence@gmail.com \
    --cc=dw@davidwei.uk \
    --cc=io-uring@vger.kernel.org \
    --cc=netdev@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