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 8/8] io_uring/zcrx: try to coalesce area pages
Date: Tue, 17 Jun 2025 15:48:26 +0100 [thread overview]
Message-ID: <f65839d67b1074098e476302df3b1fe96264a15d.1750171297.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1750171297.git.asml.silence@gmail.com>
Try to shrink the page array into fewer larger folios if possible. This
reduces the footprint, optimises dma mappings and will be used in the
future for further huge page optimisations.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/zcrx.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 44b5f8084279..9f81682ccf0c 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -166,6 +166,7 @@ static int io_import_umem(struct io_zcrx_ifq *ifq,
struct io_uring_zcrx_area_reg *area_reg)
{
unsigned folio_shift = PAGE_SHIFT;
+ struct io_imu_folio_data data;
struct scatterlist *sgl;
struct page **pages;
int nr_pages, ret;
@@ -180,6 +181,17 @@ static int io_import_umem(struct io_zcrx_ifq *ifq,
if (IS_ERR(pages))
return PTR_ERR(pages);
+ if (nr_pages > 1 && io_check_coalesce_buffer(pages, nr_pages, &data)) {
+ /*
+ * Only coalesce folio addr-aligned pages and when we can
+ * improve the size.
+ */
+ if (data.nr_pages_mid != 1 &&
+ data.nr_pages_head == data.nr_pages_mid &&
+ io_coalesce_buffer(&pages, &nr_pages, &data))
+ folio_shift = data.folio_shift;
+ }
+
ret = sg_alloc_table(&mem->page_sg_table, nr_pages, GFP_KERNEL_ACCOUNT);
if (ret)
return ret;
--
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 ` [PATCH 5/8] io_uring/zcrx: convert io_zcrx_iov_page to use folios Pavel Begunkov
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 ` Pavel Begunkov [this message]
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=f65839d67b1074098e476302df3b1fe96264a15d.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