From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com, netdev@vger.kernel.org
Subject: [PATCH review-only 02/17] io_uring/zcrx: move RQ head/tail to separate cache lines
Date: Sat, 11 Jul 2026 10:11:25 +0100 [thread overview]
Message-ID: <9b892fd443ac63428885d1ade94066125923a8f1.1783616211.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1783616211.git.asml.silence@gmail.com>
RQ head and tail are currently put into the same cache line, which can
cause false sharing problems when refill is run on another CPU. Put them
into separate cache lines.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/query.c | 2 +-
io_uring/zcrx.c | 8 ++++----
io_uring/zcrx.h | 7 ++++++-
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/io_uring/query.c b/io_uring/query.c
index d529d94aa8f4..2e7b893cc8f0 100644
--- a/io_uring/query.c
+++ b/io_uring/query.c
@@ -38,7 +38,7 @@ static ssize_t io_query_zcrx(union io_query_data *data)
e->register_flags = ZCRX_SUPPORTED_REG_FLAGS;
e->area_flags = IORING_ZCRX_AREA_DMABUF;
e->nr_ctrl_opcodes = __ZCRX_CTRL_LAST;
- e->rq_hdr_size = sizeof(struct io_uring);
+ e->rq_hdr_size = sizeof(struct zcrx_rq_hdr);
e->rq_hdr_alignment = L1_CACHE_BYTES;
e->features = ZCRX_FEATURES;
e->__resv2 = 0;
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 8348413d6d24..c4a9a663eba4 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -380,9 +380,9 @@ static void io_zcrx_get_niov_uref(struct net_iov *niov)
static void io_fill_zcrx_offsets(struct io_uring_zcrx_offsets *offsets)
{
- offsets->head = offsetof(struct io_uring, head);
- offsets->tail = offsetof(struct io_uring, tail);
- offsets->rqes = ALIGN(sizeof(struct io_uring), L1_CACHE_BYTES);
+ offsets->head = offsetof(struct zcrx_rq_hdr, head);
+ offsets->tail = offsetof(struct zcrx_rq_hdr, tail);
+ offsets->rqes = ALIGN(sizeof(struct zcrx_rq_hdr), L1_CACHE_BYTES);
}
static int io_allocate_rbuf_ring(struct io_ring_ctx *ctx,
@@ -410,7 +410,7 @@ static int io_allocate_rbuf_ring(struct io_ring_ctx *ctx,
return ret;
ptr = io_region_get_ptr(&ifq->rq_region);
- ifq->rq.ring = (struct io_uring *)ptr;
+ ifq->rq.ring = (struct zcrx_rq_hdr *)ptr;
ifq->rq.rqes = (struct io_uring_zcrx_rqe *)(ptr + off);
memset(ifq->rq.ring, 0, sizeof(*ifq->rq.ring));
diff --git a/io_uring/zcrx.h b/io_uring/zcrx.h
index fa00900e479e..3cdfa4415d62 100644
--- a/io_uring/zcrx.h
+++ b/io_uring/zcrx.h
@@ -43,9 +43,14 @@ struct io_zcrx_area {
struct io_zcrx_mem mem;
};
+struct zcrx_rq_hdr {
+ u32 head ____cacheline_aligned_in_smp;
+ u32 tail ____cacheline_aligned_in_smp;
+};
+
struct zcrx_rq {
spinlock_t lock;
- struct io_uring *ring;
+ struct zcrx_rq_hdr *ring;
struct io_uring_zcrx_rqe *rqes;
u32 cached_head;
u32 nr_entries;
--
2.54.0
WARNING: multiple messages have this Message-ID (diff)
From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com, netdev@vger.kernel.org
Subject: [PATCH review-only 02/17] io_uring/zcrx: move RQ head/tail to separate cache lines
Date: Sat, 11 Jul 2026 11:39:55 +0100 [thread overview]
Message-ID: <9b892fd443ac63428885d1ade94066125923a8f1.1783616211.git.asml.silence@gmail.com> (raw)
Message-ID: <20260711103955.SKEPNzpAMOsdwSorwW0MpQFCKYn3XvtfebICP3d5HnY@z> (raw)
In-Reply-To: <cover.1783616211.git.asml.silence@gmail.com>
RQ head and tail are currently put into the same cache line, which can
cause false sharing problems when refill is run on another CPU. Put them
into separate cache lines.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/query.c | 2 +-
io_uring/zcrx.c | 8 ++++----
io_uring/zcrx.h | 7 ++++++-
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/io_uring/query.c b/io_uring/query.c
index d529d94aa8f4..2e7b893cc8f0 100644
--- a/io_uring/query.c
+++ b/io_uring/query.c
@@ -38,7 +38,7 @@ static ssize_t io_query_zcrx(union io_query_data *data)
e->register_flags = ZCRX_SUPPORTED_REG_FLAGS;
e->area_flags = IORING_ZCRX_AREA_DMABUF;
e->nr_ctrl_opcodes = __ZCRX_CTRL_LAST;
- e->rq_hdr_size = sizeof(struct io_uring);
+ e->rq_hdr_size = sizeof(struct zcrx_rq_hdr);
e->rq_hdr_alignment = L1_CACHE_BYTES;
e->features = ZCRX_FEATURES;
e->__resv2 = 0;
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 8348413d6d24..c4a9a663eba4 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -380,9 +380,9 @@ static void io_zcrx_get_niov_uref(struct net_iov *niov)
static void io_fill_zcrx_offsets(struct io_uring_zcrx_offsets *offsets)
{
- offsets->head = offsetof(struct io_uring, head);
- offsets->tail = offsetof(struct io_uring, tail);
- offsets->rqes = ALIGN(sizeof(struct io_uring), L1_CACHE_BYTES);
+ offsets->head = offsetof(struct zcrx_rq_hdr, head);
+ offsets->tail = offsetof(struct zcrx_rq_hdr, tail);
+ offsets->rqes = ALIGN(sizeof(struct zcrx_rq_hdr), L1_CACHE_BYTES);
}
static int io_allocate_rbuf_ring(struct io_ring_ctx *ctx,
@@ -410,7 +410,7 @@ static int io_allocate_rbuf_ring(struct io_ring_ctx *ctx,
return ret;
ptr = io_region_get_ptr(&ifq->rq_region);
- ifq->rq.ring = (struct io_uring *)ptr;
+ ifq->rq.ring = (struct zcrx_rq_hdr *)ptr;
ifq->rq.rqes = (struct io_uring_zcrx_rqe *)(ptr + off);
memset(ifq->rq.ring, 0, sizeof(*ifq->rq.ring));
diff --git a/io_uring/zcrx.h b/io_uring/zcrx.h
index fa00900e479e..3cdfa4415d62 100644
--- a/io_uring/zcrx.h
+++ b/io_uring/zcrx.h
@@ -43,9 +43,14 @@ struct io_zcrx_area {
struct io_zcrx_mem mem;
};
+struct zcrx_rq_hdr {
+ u32 head ____cacheline_aligned_in_smp;
+ u32 tail ____cacheline_aligned_in_smp;
+};
+
struct zcrx_rq {
spinlock_t lock;
- struct io_uring *ring;
+ struct zcrx_rq_hdr *ring;
struct io_uring_zcrx_rqe *rqes;
u32 cached_head;
u32 nr_entries;
--
2.54.0
next prev parent reply other threads:[~2026-07-11 9:12 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 9:11 [PATCH review-only 00/17] zcrx RQ improvements and dynamic memory provisioning Pavel Begunkov
2026-07-11 9:11 ` [PATCH review-only 01/17] io_uring/zcrx: scale refilling with large pages Pavel Begunkov
2026-07-11 10:39 ` Pavel Begunkov
2026-07-11 9:11 ` Pavel Begunkov [this message]
2026-07-11 10:39 ` [PATCH review-only 02/17] io_uring/zcrx: move RQ head/tail to separate cache lines Pavel Begunkov
2026-07-11 9:11 ` [PATCH review-only 03/17] io_uring/zcrx: add RQ iterator Pavel Begunkov
2026-07-11 10:39 ` Pavel Begunkov
2026-07-11 9:11 ` [PATCH review-only 04/17] io_uring/zcrx: cache RQ tail Pavel Begunkov
2026-07-11 10:39 ` Pavel Begunkov
2026-07-11 9:11 ` [PATCH review-only 05/17] io_uring/zcrx: coalesce same-niov RQEs on refill Pavel Begunkov
2026-07-11 10:39 ` Pavel Begunkov
2026-07-11 9:11 ` [PATCH review-only 06/17] io_uring/zcrx: constify area_reg on import Pavel Begunkov
2026-07-11 10:39 ` Pavel Begunkov
2026-07-11 9:11 ` [PATCH review-only 07/17] io_uring/zcrx: add helper for deriving area token Pavel Begunkov
2026-07-11 10:40 ` Pavel Begunkov
2026-07-11 9:11 ` [PATCH review-only 08/17] io_uring/zcrx: don't pass ifq_reg to area creation Pavel Begunkov
2026-07-11 10:40 ` Pavel Begunkov
2026-07-11 9:11 ` [PATCH review-only 09/17] io_uring/zcrx: split dmabuf unmap and release Pavel Begunkov
2026-07-11 10:40 ` Pavel Begunkov
2026-07-11 9:11 ` [PATCH review-only 10/17] io_uring/zcrx: unmap under netdev lock Pavel Begunkov
2026-07-11 10:40 ` Pavel Begunkov
2026-07-11 9:11 ` [PATCH review-only 11/17] io_uring/zcrx: split append out of area creation Pavel Begunkov
2026-07-11 10:40 ` Pavel Begunkov
2026-07-11 9:11 ` [PATCH review-only 12/17] io_uring/zcrx: move freelist lock to struct zcrx Pavel Begunkov
2026-07-11 10:40 ` Pavel Begunkov
2026-07-11 9:11 ` [PATCH review-only 13/17] io_uring/zcrx: array of areas Pavel Begunkov
2026-07-11 10:40 ` Pavel Begunkov
2026-07-11 9:11 ` [PATCH review-only 14/17] io_uring/zcrx: pass area_id to __zcrx_create_area() Pavel Begunkov
2026-07-11 10:40 ` Pavel Begunkov
2026-07-11 9:11 ` [PATCH review-only 15/17] io_uring/zcrx: add dynamic area creation Pavel Begunkov
2026-07-11 10:40 ` Pavel Begunkov
2026-07-11 9:11 ` [PATCH review-only 16/17] io_urint/zcrx: narrow var scope in io_zcrx_recv_skb() Pavel Begunkov
2026-07-11 10:40 ` Pavel Begunkov
2026-07-11 10:39 ` [PATCH review-only 00/17] zcrx RQ improvements and dynamic memory provisioning Pavel Begunkov
2026-07-11 10:39 ` [PATCH RESEND " Pavel Begunkov
2026-07-11 10:40 ` [PATCH review-only 17/17] io_uring/zcrx: don't reload skb_shinfo 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=9b892fd443ac63428885d1ade94066125923a8f1.1783616211.git.asml.silence@gmail.com \
--to=asml.silence@gmail.com \
--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