public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org
Cc: io-uring@vger.kernel.org, asml.silence@gmail.com
Subject: [RFC 7/9] io_uring/zcrx: don't lock for single producer ptr ring
Date: Sat, 11 Jul 2026 10:22:17 +0100	[thread overview]
Message-ID: <b467df7a7e4cdcbeaebb8376f6a8f02fffa76f05.1783619193.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1783619193.git.asml.silence@gmail.com>

Normally, there is just one io_uring instance using zcrx and all
receiving happens under its lock. In this case we can avoid grabbing the
ptr ring lock on the production side.

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

diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 80a26b5798d3..3d5d5c9fd9a5 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -825,6 +825,7 @@ static int zcrx_export(struct io_ring_ctx *ctx, struct io_zcrx_ifq *ifq,
 	if (!mem_is_zero(ce, sizeof(*ce)))
 		return -EINVAL;
 
+	ifq->shared = true;
 	refcount_inc(&ifq->refs);
 	refcount_inc(&ifq->user_refs);
 
@@ -1974,7 +1975,10 @@ static int __zcrx_recv_skb(read_descriptor_t *desc, struct sk_buff *skb,
 
 	if (can_steal && !__ptr_ring_full(&ifq->skb_ring) &&
 	    tcp_read_sock_steal_skb(desc, skb, args->sock->sk)) {
-		ret = ptr_ring_produce(&ifq->skb_ring, skb);
+		if (ifq->shared)
+			ret = ptr_ring_produce(&ifq->skb_ring, skb);
+		else
+			ret = __ptr_ring_produce(&ifq->skb_ring, skb);
 		if (ret) {
 			zcrx_user_ref_frags(ifq, skb, first_frag, i);
 			__kfree_skb(skb);
diff --git a/io_uring/zcrx.h b/io_uring/zcrx.h
index 7fc12e53c8a1..5ff4dabb0f68 100644
--- a/io_uring/zcrx.h
+++ b/io_uring/zcrx.h
@@ -71,6 +71,7 @@ struct io_zcrx_ifq {
 	spinlock_t			alloc_lock ____cacheline_aligned_in_smp;
 
 	struct ptr_ring			skb_ring;
+	bool				shared;
 
 	u32				if_rxq;
 	struct device			*dev;
-- 
2.54.0


  parent reply	other threads:[~2026-07-11  9:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-11  9:22 [RFC 0/9] optimise zcrx refs cache bouncing Pavel Begunkov
2026-07-11  9:22 ` [RFC 1/9] net: allow __tcp_read_sock actors to steal skbs Pavel Begunkov
2026-07-11  9:22 ` [RFC 2/9] net: add provider specific net_iov field Pavel Begunkov
2026-07-11  9:22 ` [RFC 3/9] io_uring/zcrx: don't save/restore count for frag skbs Pavel Begunkov
2026-07-11  9:22 ` [RFC 4/9] io_uring/zcrx: split frag handling loop Pavel Begunkov
2026-07-11  9:22 ` [RFC 5/9] io_uring/zcrx: split io_zcrx_recv_frag() Pavel Begunkov
2026-07-11  9:22 ` [RFC 6/9] io_uring/zcrx: implement skb stealing Pavel Begunkov
2026-07-11  9:22 ` Pavel Begunkov [this message]
2026-07-11  9:22 ` [RFC 8/9] io_uring/zcrx: steal niov refs Pavel Begunkov
2026-07-11  9:22 ` [RFC 9/9] io_uring/zcrx: add rq_lock cache of "user" " 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=b467df7a7e4cdcbeaebb8376f6a8f02fffa76f05.1783619193.git.asml.silence@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=io-uring@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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