Netdev List
 help / color / mirror / Atom feed
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 14/17] io_uring/zcrx: pass area_id to __zcrx_create_area()
Date: Sat, 11 Jul 2026 10:11:37 +0100	[thread overview]
Message-ID: <d40ecb7a6e912bd32ece44a9e4c001c9de05d832.1783616211.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1783616211.git.asml.silence@gmail.com>

Instead of generating an area id inside of __zcrx_create_area(), let the
caller to pass it. It needs the id to derive the user token, and we
might need to know it before creating and publishing the area.

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

diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 474ffc217b0b..3f61f942c393 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -44,6 +44,11 @@ static inline u64 zcrx_area_id_to_token(u32 area_id)
 	return (u64)area_id << IORING_ZCRX_AREA_SHIFT;
 }
 
+static inline u32 zcrx_next_area_id(struct io_zcrx_ifq *zcrx)
+{
+	return zcrx->nr_areas;
+}
+
 static inline struct io_zcrx_ifq *io_pp_to_ifq(struct page_pool *pp)
 {
 	return pp->mp_priv;
@@ -472,6 +477,8 @@ static int io_zcrx_append_area(struct io_zcrx_ifq *ifq,
 
 	if (WARN_ON_ONCE(ifq->kern_readable != kern_readable))
 		return -EINVAL;
+	if (WARN_ON_ONCE(area->area_id != zcrx_next_area_id(ifq)))
+		return -EINVAL;
 
 	old_areas = ifq->areas;
 	old_nr = ifq->nr_areas;
@@ -494,9 +501,10 @@ static int io_zcrx_append_area(struct io_zcrx_ifq *ifq,
 }
 
 static int __zcrx_create_area(struct io_zcrx_ifq *ifq,
-			       struct io_uring_zcrx_area_reg *area_reg,
+			       const struct io_uring_zcrx_area_reg *area_reg,
 			       struct io_zcrx_area **res_area,
-			       u32 rx_buf_len)
+			       u32 rx_buf_len,
+			       u32 area_id)
 {
 	int buf_size_shift = PAGE_SHIFT;
 	struct io_zcrx_area *area;
@@ -565,9 +573,7 @@ static int __zcrx_create_area(struct io_zcrx_ifq *ifq,
 	}
 
 	area->free_count = nr_iovs;
-	/* we're only supporting one area per ifq for now */
-	area->area_id = 0;
-	area_reg->rq_area_token = zcrx_area_id_to_token(area->area_id);
+	area->area_id = area_id;
 	*res_area = area;
 	return 0;
 err:
@@ -583,9 +589,12 @@ static int io_zcrx_create_area(struct io_zcrx_ifq *ifq,
 			       struct io_uring_zcrx_ifq_reg *reg)
 {
 	struct io_zcrx_area *area;
+	u32 id = zcrx_next_area_id(ifq);
 	int ret;
 
-	ret = __zcrx_create_area(ifq, area_reg, &area, reg->rx_buf_len);
+	area_reg->rq_area_token = zcrx_area_id_to_token(id);
+
+	ret = __zcrx_create_area(ifq, area_reg, &area, reg->rx_buf_len, id);
 	if (ret)
 		return ret;
 
-- 
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 14/17] io_uring/zcrx: pass area_id to __zcrx_create_area()
Date: Sat, 11 Jul 2026 11:40:07 +0100	[thread overview]
Message-ID: <d40ecb7a6e912bd32ece44a9e4c001c9de05d832.1783616211.git.asml.silence@gmail.com> (raw)
Message-ID: <20260711104007.WxqXcZhm6htBngsgBrJJTGs9ksyCOlnqWpnEklku68E@z> (raw)
In-Reply-To: <cover.1783616211.git.asml.silence@gmail.com>

Instead of generating an area id inside of __zcrx_create_area(), let the
caller to pass it. It needs the id to derive the user token, and we
might need to know it before creating and publishing the area.

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

diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 474ffc217b0b..3f61f942c393 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -44,6 +44,11 @@ static inline u64 zcrx_area_id_to_token(u32 area_id)
 	return (u64)area_id << IORING_ZCRX_AREA_SHIFT;
 }
 
+static inline u32 zcrx_next_area_id(struct io_zcrx_ifq *zcrx)
+{
+	return zcrx->nr_areas;
+}
+
 static inline struct io_zcrx_ifq *io_pp_to_ifq(struct page_pool *pp)
 {
 	return pp->mp_priv;
@@ -472,6 +477,8 @@ static int io_zcrx_append_area(struct io_zcrx_ifq *ifq,
 
 	if (WARN_ON_ONCE(ifq->kern_readable != kern_readable))
 		return -EINVAL;
+	if (WARN_ON_ONCE(area->area_id != zcrx_next_area_id(ifq)))
+		return -EINVAL;
 
 	old_areas = ifq->areas;
 	old_nr = ifq->nr_areas;
@@ -494,9 +501,10 @@ static int io_zcrx_append_area(struct io_zcrx_ifq *ifq,
 }
 
 static int __zcrx_create_area(struct io_zcrx_ifq *ifq,
-			       struct io_uring_zcrx_area_reg *area_reg,
+			       const struct io_uring_zcrx_area_reg *area_reg,
 			       struct io_zcrx_area **res_area,
-			       u32 rx_buf_len)
+			       u32 rx_buf_len,
+			       u32 area_id)
 {
 	int buf_size_shift = PAGE_SHIFT;
 	struct io_zcrx_area *area;
@@ -565,9 +573,7 @@ static int __zcrx_create_area(struct io_zcrx_ifq *ifq,
 	}
 
 	area->free_count = nr_iovs;
-	/* we're only supporting one area per ifq for now */
-	area->area_id = 0;
-	area_reg->rq_area_token = zcrx_area_id_to_token(area->area_id);
+	area->area_id = area_id;
 	*res_area = area;
 	return 0;
 err:
@@ -583,9 +589,12 @@ static int io_zcrx_create_area(struct io_zcrx_ifq *ifq,
 			       struct io_uring_zcrx_ifq_reg *reg)
 {
 	struct io_zcrx_area *area;
+	u32 id = zcrx_next_area_id(ifq);
 	int ret;
 
-	ret = __zcrx_create_area(ifq, area_reg, &area, reg->rx_buf_len);
+	area_reg->rq_area_token = zcrx_area_id_to_token(id);
+
+	ret = __zcrx_create_area(ifq, area_reg, &area, reg->rx_buf_len, id);
 	if (ret)
 		return ret;
 
-- 
2.54.0


  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 ` [PATCH review-only 02/17] io_uring/zcrx: move RQ head/tail to separate cache lines Pavel Begunkov
2026-07-11 10:39   ` 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 ` Pavel Begunkov [this message]
2026-07-11 10:40   ` [PATCH review-only 14/17] io_uring/zcrx: pass area_id to __zcrx_create_area() 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=d40ecb7a6e912bd32ece44a9e4c001c9de05d832.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