From: David Wei <dw@davidwei.uk>
To: Pavel Begunkov <asml.silence@gmail.com>, io-uring@vger.kernel.org
Subject: Re: [PATCH 5/5] io_uring/zcrx: add support for multiple ifqs
Date: Fri, 18 Apr 2025 10:01:01 -0700 [thread overview]
Message-ID: <1b14f24b-f84a-4863-a0cb-33d0ebcd9171@davidwei.uk> (raw)
In-Reply-To: <8d8ddd5862a4793cdb1b4486601e285d427df22e.1744815316.git.asml.silence@gmail.com>
On 2025-04-16 08:21, Pavel Begunkov wrote:
> Allow the user to register multiple ifqs / zcrx contexts. With that we
> can use multiple interfaces / interface queues in a single io_uring
> instance.
>
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
> ---
> include/linux/io_uring_types.h | 5 ++--
> io_uring/io_uring.c | 3 +-
> io_uring/net.c | 8 ++---
> io_uring/zcrx.c | 53 +++++++++++++++++++++-------------
> 4 files changed, 40 insertions(+), 29 deletions(-)
>
[...]
> diff --git a/io_uring/net.c b/io_uring/net.c
> index 5f1a519d1fc6..b3a643675ce8 100644
> --- a/io_uring/net.c
> +++ b/io_uring/net.c
> @@ -1185,16 +1185,14 @@ int io_recvzc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
> struct io_recvzc *zc = io_kiocb_to_cmd(req, struct io_recvzc);
> unsigned ifq_idx;
>
> - if (unlikely(sqe->file_index || sqe->addr2 || sqe->addr ||
> - sqe->addr3))
> + if (unlikely(sqe->addr2 || sqe->addr || sqe->addr3))
> return -EINVAL;
Why remove sqe->file_index?
>
> ifq_idx = READ_ONCE(sqe->zcrx_ifq_idx);
> - if (ifq_idx != 0)
> - return -EINVAL;
> - zc->ifq = req->ctx->ifq;
> + zc->ifq = xa_load(&req->ctx->zcrx_ctxs, ifq_idx);
> if (!zc->ifq)
> return -EINVAL;
> +
> zc->len = READ_ONCE(sqe->len);
> zc->flags = READ_ONCE(sqe->ioprio);
> zc->msg_flags = READ_ONCE(sqe->msg_flags);
> diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
> index d56665fd103d..e4ce971b1257 100644
> --- a/io_uring/zcrx.c
> +++ b/io_uring/zcrx.c
> @@ -172,9 +172,6 @@ static int io_allocate_rbuf_ring(struct io_zcrx_ifq *ifq,
>
> static void io_free_rbuf_ring(struct io_zcrx_ifq *ifq)
> {
> - if (WARN_ON_ONCE(ifq->ctx->ifq))
> - return;
> -
I think this should stay.
> io_free_region(ifq->ctx, &ifq->region);
> ifq->rq_ring = NULL;
> ifq->rqes = NULL;
[...]
> @@ -440,16 +443,23 @@ int io_register_zcrx_ifq(struct io_ring_ctx *ctx,
>
> void io_unregister_zcrx_ifqs(struct io_ring_ctx *ctx)
> {
> - struct io_zcrx_ifq *ifq = ctx->ifq;
> + struct io_zcrx_ifq *ifq;
> + unsigned long id;
>
> lockdep_assert_held(&ctx->uring_lock);
>
> - if (!ifq)
> - return;
> + while (1) {
> + scoped_guard(mutex, &ctx->mmap_lock) {
> + ifq = xa_find(&ctx->zcrx_ctxs, &id, ULONG_MAX, XA_PRESENT);
> + if (ifq)
> + xa_erase(&ctx->zcrx_ctxs, id);
> + }
> + if (!ifq)
> + break;
> + io_zcrx_ifq_free(ifq);
> + }
Why not xa_for_each()? Is it weirdness with scoped_guard macro?
next prev parent reply other threads:[~2025-04-18 17:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 15:21 [PATCH 0/5] add support for multiple ifqs per io_uring Pavel Begunkov
2025-04-16 15:21 ` [PATCH 1/5] io_uring/zcrx: remove duplicated freelist init Pavel Begunkov
2025-04-18 15:06 ` David Wei
2025-04-16 15:21 ` [PATCH 2/5] io_uring/zcrx: move io_zcrx_iov_page Pavel Begunkov
2025-04-18 15:07 ` David Wei
2025-04-16 15:21 ` [PATCH 3/5] io_uring/zcrx: let zcrx choose region for mmaping Pavel Begunkov
2025-04-18 15:35 ` David Wei
2025-04-18 15:52 ` Pavel Begunkov
2025-04-16 15:21 ` [PATCH 4/5] io_uring/zcrx: move zcrx region to struct io_zcrx_ifq Pavel Begunkov
2025-04-18 16:05 ` David Wei
2025-04-18 16:22 ` Pavel Begunkov
2025-04-18 18:52 ` David Wei
2025-04-16 15:21 ` [PATCH 5/5] io_uring/zcrx: add support for multiple ifqs Pavel Begunkov
2025-04-18 17:01 ` David Wei [this message]
2025-04-18 17:22 ` Pavel Begunkov
2025-04-18 18:54 ` 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=1b14f24b-f84a-4863-a0cb-33d0ebcd9171@davidwei.uk \
--to=dw@davidwei.uk \
--cc=asml.silence@gmail.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