From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com
Subject: [PATCH v3 1/6] io_uring/zcrx: always pass page to io_zcrx_copy_chunk
Date: Wed, 2 Jul 2025 15:03:21 +0100 [thread overview]
Message-ID: <b8f9f4bac027f5f44a9ccf85350912d1db41ceb8.1751464343.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1751464343.git.asml.silence@gmail.com>
io_zcrx_copy_chunk() currently takes either a page or virtual address.
Unify the parameters, make it take pages and resolve the linear part
into a page the same way general networking code does that.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/zcrx.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 797247a34cb7..99a253c1c6c5 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -943,8 +943,8 @@ static struct net_iov *io_zcrx_alloc_fallback(struct io_zcrx_area *area)
}
static ssize_t io_zcrx_copy_chunk(struct io_kiocb *req, struct io_zcrx_ifq *ifq,
- void *src_base, struct page *src_page,
- unsigned int src_offset, size_t len)
+ struct page *src_page, unsigned int src_offset,
+ size_t len)
{
struct io_zcrx_area *area = ifq->area;
size_t copied = 0;
@@ -958,7 +958,7 @@ static ssize_t io_zcrx_copy_chunk(struct io_kiocb *req, struct io_zcrx_ifq *ifq,
const int dst_off = 0;
struct net_iov *niov;
struct page *dst_page;
- void *dst_addr;
+ void *dst_addr, *src_addr;
niov = io_zcrx_alloc_fallback(area);
if (!niov) {
@@ -968,13 +968,11 @@ static ssize_t io_zcrx_copy_chunk(struct io_kiocb *req, struct io_zcrx_ifq *ifq,
dst_page = io_zcrx_iov_page(niov);
dst_addr = kmap_local_page(dst_page);
- if (src_page)
- src_base = kmap_local_page(src_page);
+ src_addr = kmap_local_page(src_page);
- memcpy(dst_addr, src_base + src_offset, copy_size);
+ memcpy(dst_addr, src_addr + src_offset, copy_size);
- if (src_page)
- kunmap_local(src_base);
+ kunmap_local(src_addr);
kunmap_local(dst_addr);
if (!io_zcrx_queue_cqe(req, niov, ifq, dst_off, copy_size)) {
@@ -1003,7 +1001,7 @@ static int io_zcrx_copy_frag(struct io_kiocb *req, struct io_zcrx_ifq *ifq,
skb_frag_foreach_page(frag, off, len,
page, p_off, p_len, t) {
- ret = io_zcrx_copy_chunk(req, ifq, NULL, page, p_off, p_len);
+ ret = io_zcrx_copy_chunk(req, ifq, page, p_off, p_len);
if (ret < 0)
return copied ? copied : ret;
copied += ret;
@@ -1065,8 +1063,9 @@ io_zcrx_recv_skb(read_descriptor_t *desc, struct sk_buff *skb,
size_t to_copy;
to_copy = min_t(size_t, skb_headlen(skb) - offset, len);
- copied = io_zcrx_copy_chunk(req, ifq, skb->data, NULL,
- offset, to_copy);
+ copied = io_zcrx_copy_chunk(req, ifq, virt_to_page(skb->data),
+ offset_in_page(skb->data) + offset,
+ to_copy);
if (copied < 0) {
ret = copied;
goto out;
--
2.49.0
next prev parent reply other threads:[~2025-07-02 14:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-02 14:03 [PATCH v3 0/6] zcrx huge pages support Vol 1 Pavel Begunkov
2025-07-02 14:03 ` Pavel Begunkov [this message]
2025-07-02 14:03 ` [PATCH v3 2/6] io_uring/zcrx: return error from io_zcrx_map_area_* Pavel Begunkov
2025-07-02 14:03 ` [PATCH v3 3/6] io_uring/zcrx: introduce io_populate_area_dma Pavel Begunkov
2025-07-02 14:03 ` [PATCH v3 4/6] io_uring/zcrx: allocate sgtable for umem areas Pavel Begunkov
2025-07-02 14:03 ` [PATCH v3 5/6] io_uring/zcrx: assert area type in io_zcrx_iov_page Pavel Begunkov
2025-07-02 14:03 ` [PATCH v3 6/6] io_uring/zcrx: prepare fallback for larger pages 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=b8f9f4bac027f5f44a9ccf85350912d1db41ceb8.1751464343.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