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 4/4] io_uring/zcrx: coalesce areas with huge pages
Date: Tue, 22 Apr 2025 15:44:44 +0100 [thread overview]
Message-ID: <fc1d31b8927631319a29f2c20c2f6c11726136aa.1745328503.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1745328503.git.asml.silence@gmail.com>
Try to shrink the page array into fewer larger folios if possible. This
reduces the footprint for the array and prepares us for future huge page
optimisations.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/zcrx.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 784c4ed6c780..fd0d97830854 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -219,6 +219,8 @@ static int io_import_area_memory(struct io_zcrx_ifq *ifq,
struct io_zcrx_area *area,
struct io_uring_zcrx_area_reg *area_reg)
{
+ struct io_imu_folio_data data;
+ bool coalesced = false;
struct iovec iov;
int nr_pages;
int ret;
@@ -239,6 +241,21 @@ static int io_import_area_memory(struct io_zcrx_ifq *ifq,
area->nr_folios = nr_pages;
area->folio_shift = PAGE_SHIFT;
area->chunk_id_offset = 0;
+
+ if (nr_pages > 1 && io_check_coalesce_buffer(area->pages, nr_pages, &data)) {
+ if (data.nr_pages_mid != 1)
+ coalesced = io_coalesce_buffer(&area->pages, &nr_pages, &data);
+ }
+
+ if (coalesced) {
+ size_t folio_size = 1UL << data.folio_shift;
+ size_t offset = folio_size - (data.nr_pages_head << PAGE_SHIFT);
+
+ area->nr_folios = nr_pages;
+ area->folio_shift = data.folio_shift;
+ area->chunk_id_offset = offset >> PAGE_SHIFT;
+ }
+
return 0;
}
--
2.48.1
next prev parent reply other threads:[~2025-04-22 14:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-22 14:44 [PATCH 0/4] preparation for zcrx with huge pages Pavel Begunkov
2025-04-22 14:44 ` [PATCH 1/4] io_uring/zcrx: add helper for importing user memory Pavel Begunkov
2025-04-22 14:44 ` [PATCH 2/4] io_uring/zcrx: add initial infra for large pages Pavel Begunkov
2025-04-22 14:44 ` [PATCH 3/4] io_uring: export io_coalesce_buffer() Pavel Begunkov
2025-04-22 14:44 ` Pavel Begunkov [this message]
2025-04-25 14:01 ` [PATCH 0/4] preparation for zcrx with huge pages Pavel Begunkov
2025-04-25 15:42 ` David Wei
2025-04-26 0:01 ` 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=fc1d31b8927631319a29f2c20c2f6c11726136aa.1745328503.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