io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com
Subject: [zcrx-next 10/10] io_uring/zcrx: rely on cache size truncation on refill
Date: Sun, 17 Aug 2025 23:43:36 +0100	[thread overview]
Message-ID: <0c2f21938000e9d7b5ae6285cca20b787f439d06.1755467432.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1755467432.git.asml.silence@gmail.com>

The return value of io_zcrx_rqring_entries() is truncated by rq_size so
that refilling doesn't loop indefinitely. However, io_zcrx_ring_refill()
is already protected against that by iterating no more than
PP_ALLOC_CACHE_REFILL times. Remove the truncation.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 io_uring/zcrx.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 6d6b09b932d2..859bb5f54892 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -716,10 +716,7 @@ void io_shutdown_zcrx_ifqs(struct io_ring_ctx *ctx)
 
 static inline u32 io_zcrx_rqring_entries(struct io_zcrx_ifq *ifq)
 {
-	u32 entries;
-
-	entries = smp_load_acquire(&ifq->rq_ring->tail) - ifq->cached_rq_head;
-	return min(entries, ifq->rq_entries);
+	return smp_load_acquire(&ifq->rq_ring->tail) - ifq->cached_rq_head;
 }
 
 static struct io_uring_zcrx_rqe *io_zcrx_get_rqe(struct io_zcrx_ifq *ifq,
@@ -738,8 +735,7 @@ static void io_zcrx_ring_refill(struct page_pool *pp,
 
 	guard(spinlock_bh)(&ifq->rq_lock);
 
-	entries = io_zcrx_rqring_entries(ifq);
-	entries = min_t(unsigned, entries, PP_ALLOC_CACHE_REFILL);
+	entries = min(PP_ALLOC_CACHE_REFILL, io_zcrx_rqring_entries(ifq));
 	if (unlikely(!entries))
 		return;
 
-- 
2.49.0


  parent reply	other threads:[~2025-08-17 22:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-17 22:43 [zcrx-next 00/10] next zcrx cleanups Pavel Begunkov
2025-08-17 22:43 ` [zcrx-next 01/10] io_uring/zcrx: replace memchar_inv with is_zero Pavel Begunkov
2025-08-17 22:43 ` [zcrx-next 02/10] io_uring/zcrx: use page_pool_unref_and_test() Pavel Begunkov
2025-08-17 22:43 ` [zcrx-next 03/10] io_uring/zcrx: remove extra io_zcrx_drop_netdev Pavel Begunkov
2025-08-17 22:43 ` [zcrx-next 04/10] io_uring/zcrx: rename dma lock Pavel Begunkov
2025-08-17 22:43 ` [zcrx-next 05/10] io_uring/zcrx: protect netdev with pp_lock Pavel Begunkov
2025-08-17 22:43 ` [zcrx-next 06/10] io_uring/zcrx: unify allocation dma sync Pavel Begunkov
2025-08-17 22:43 ` [zcrx-next 07/10] io_uring/zcrx: reduce netmem scope in refill Pavel Begunkov
2025-08-17 22:43 ` [zcrx-next 08/10] io_uring/zcrx: use guards for the refill lock Pavel Begunkov
2025-08-17 22:43 ` [zcrx-next 09/10] io_uring/zcrx: don't adjust free cache space Pavel Begunkov
2025-08-17 22:43 ` Pavel Begunkov [this message]
2025-08-20 18:20 ` [zcrx-next 00/10] next zcrx cleanups Jens Axboe

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=0c2f21938000e9d7b5ae6285cca20b787f439d06.1755467432.git.asml.silence@gmail.com \
    --to=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;
as well as URLs for NNTP newsgroup(s).