From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com, David Wei <dw@davidwei.uk>
Subject: [PATCH 5/8] io_uring/zcrx: convert io_zcrx_iov_page to use folios
Date: Tue, 17 Jun 2025 15:48:23 +0100 [thread overview]
Message-ID: <257d703425d454ce1154c73ed998c758e9b01a07.1750171297.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1750171297.git.asml.silence@gmail.com>
Modernise io_zcrx_iov_page() and make it return folios + offset. That
will be used for the next patches implementing area's page coalescing.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/zcrx.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index a2493798e6f8..a83b80c16491 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -40,13 +40,17 @@ static inline struct io_zcrx_area *io_zcrx_iov_to_area(const struct net_iov *nio
return container_of(owner, struct io_zcrx_area, nia);
}
-static inline struct page *io_zcrx_iov_page(const struct net_iov *niov)
+static inline struct folio *io_niov_folio(const struct net_iov *niov,
+ unsigned long *off)
{
struct io_zcrx_area *area = io_zcrx_iov_to_area(niov);
+ struct page *page;
lockdep_assert(!area->mem.is_dmabuf);
- return area->mem.pages[net_iov_idx(niov)];
+ page = area->mem.pages[net_iov_idx(niov)];
+ *off = (page - compound_head(page)) << PAGE_SHIFT;
+ return page_folio(page);
}
static int io_populate_area_dma(struct io_zcrx_ifq *ifq,
@@ -944,7 +948,8 @@ static ssize_t io_zcrx_copy_chunk(struct io_kiocb *req, struct io_zcrx_ifq *ifq,
size_t copy_size = min_t(size_t, PAGE_SIZE, len);
const int dst_off = 0;
struct net_iov *niov;
- struct page *dst_page;
+ struct folio *dst_folio;
+ unsigned long dst_folio_off;
void *dst_addr;
niov = io_zcrx_alloc_fallback(area);
@@ -953,8 +958,8 @@ static ssize_t io_zcrx_copy_chunk(struct io_kiocb *req, struct io_zcrx_ifq *ifq,
break;
}
- dst_page = io_zcrx_iov_page(niov);
- dst_addr = kmap_local_page(dst_page);
+ dst_folio = io_niov_folio(niov, &dst_folio_off);
+ dst_addr = kmap_local_folio(dst_folio, dst_folio_off);
if (src_page)
src_base = kmap_local_page(src_page);
--
2.49.0
next prev parent reply other threads:[~2025-06-17 14:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-17 14:48 [PATCH 0/8] zcrx huge pages support Vol 1 Pavel Begunkov
2025-06-17 14:48 ` [PATCH 1/8] io_uring/zcrx: return error from io_zcrx_map_area_* Pavel Begunkov
2025-06-17 14:48 ` [PATCH 2/8] io_uring/zcrx: introduce io_populate_area_dma Pavel Begunkov
2025-06-17 14:48 ` [PATCH 3/8] io_uring/zcrx: allocate sgtable for umem areas Pavel Begunkov
2025-06-17 14:48 ` [PATCH 4/8] io_uring/zcrx: assert area type in io_zcrx_iov_page Pavel Begunkov
2025-06-17 14:48 ` Pavel Begunkov [this message]
2025-06-17 14:48 ` [PATCH 6/8] io_uring/zcrx: add infra for large pages Pavel Begunkov
2025-06-17 14:48 ` [PATCH 7/8] io_uring: export io_coalesce_buffer() Pavel Begunkov
2025-06-17 14:48 ` [PATCH 8/8] io_uring/zcrx: try to coalesce area pages Pavel Begunkov
2025-06-30 17:12 ` [PATCH 0/8] zcrx huge pages support Vol 1 Pavel Begunkov
2025-06-30 17:31 ` Jens Axboe
2025-06-30 17:44 ` 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=257d703425d454ce1154c73ed998c758e9b01a07.1750171297.git.asml.silence@gmail.com \
--to=asml.silence@gmail.com \
--cc=dw@davidwei.uk \
--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