public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: David Wei <dw@davidwei.uk>, io-uring@vger.kernel.org
Subject: Re: [PATCH 4/5] io_uring/zcrx: move zcrx region to struct io_zcrx_ifq
Date: Fri, 18 Apr 2025 17:22:19 +0100	[thread overview]
Message-ID: <a3a444fd-b219-4b70-9936-8ad347842d57@gmail.com> (raw)
In-Reply-To: <b787d94c-8398-43d5-9721-5c4fb76890ca@davidwei.uk>

On 4/18/25 17:05, David Wei wrote:
> On 2025-04-16 08:21, Pavel Begunkov wrote:
>> Refill queue region is a part of zcrx and should stay in struct
>> io_zcrx_ifq. We can't have multiple queues without it.
>>
>> Note: ctx->ifq assignments are now protected by mmap_lock as it's in
>> the mmap region look up path.
>>
>> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
>> ---
>>   include/linux/io_uring_types.h |  2 --
>>   io_uring/zcrx.c                | 20 ++++++++++++--------
>>   io_uring/zcrx.h                |  1 +
>>   3 files changed, 13 insertions(+), 10 deletions(-)
>>
>> diff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h
>> index 3b467879bca8..06d722289fc5 100644
>> --- a/include/linux/io_uring_types.h
>> +++ b/include/linux/io_uring_types.h
>> @@ -448,8 +448,6 @@ struct io_ring_ctx {
>>   	struct io_mapped_region		ring_region;
>>   	/* used for optimised request parameter and wait argument passing  */
>>   	struct io_mapped_region		param_region;
>> -	/* just one zcrx per ring for now, will move to io_zcrx_ifq eventually */
>> -	struct io_mapped_region		zcrx_region;
>>   };
>>   
>>   /*
>> diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
>> index 652daff0eb8d..d56665fd103d 100644
>> --- a/io_uring/zcrx.c
>> +++ b/io_uring/zcrx.c
>> @@ -160,12 +160,11 @@ static int io_allocate_rbuf_ring(struct io_zcrx_ifq *ifq,
>>   	if (size > rd->size)
>>   		return -EINVAL;
>>   
>> -	ret = io_create_region_mmap_safe(ifq->ctx, &ifq->ctx->zcrx_region, rd,
>> -					 IORING_MAP_OFF_ZCRX_REGION);
>> +	ret = io_create_region(ifq->ctx, &ifq->region, rd, IORING_MAP_OFF_ZCRX_REGION);
> 
> Why is this changed to io_create_region()? I don't see the caller of
> io_allocate_rbuf_ring() changing or taking mmap_lock.

We only care about mmap seeing a consistent region. The mmap holds
the ctx->mmap_lock, and *mmap_safe was making sure the region is
updated atomically from its perspective.

Now, instead of protecting the region itself, this patch is protecting
how ifq and subsequently the region is published:

-	ctx->ifq = ifq;
+	scoped_guard(mutex, &ctx->mmap_lock)
+		ctx->ifq = ifq;

And io_zcrx_get_region() is either sees NULL or ifq with a
correct region.

-- 
Pavel Begunkov


  reply	other threads:[~2025-04-18 16:21 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 [this message]
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
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=a3a444fd-b219-4b70-9936-8ad347842d57@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=dw@davidwei.uk \
    --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