From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com
Subject: [PATCH 1/4] io_uring: add helper calculating region byte size
Date: Mon, 10 Nov 2025 13:04:49 +0000 [thread overview]
Message-ID: <e42e7f3fa3b43a8b8af896f7edc251b113ad7b77.1762701490.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1762701490.git.asml.silence@gmail.com>
There has been type related issues with region size calculation, add an
utility helper function that returns the size and handles type
conversions right.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/memmap.c | 4 ++--
io_uring/memmap.h | 5 +++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/io_uring/memmap.c b/io_uring/memmap.c
index 24da17a5f08f..dc4bfc5b6fb8 100644
--- a/io_uring/memmap.c
+++ b/io_uring/memmap.c
@@ -134,7 +134,7 @@ static int io_region_init_ptr(struct io_mapped_region *mr)
static int io_region_pin_pages(struct io_mapped_region *mr,
struct io_uring_region_desc *reg)
{
- unsigned long size = mr->nr_pages << PAGE_SHIFT;
+ size_t size = io_region_size(mr);
struct page **pages;
int nr_pages;
@@ -154,7 +154,7 @@ static int io_region_allocate_pages(struct io_mapped_region *mr,
unsigned long mmap_offset)
{
gfp_t gfp = GFP_KERNEL_ACCOUNT | __GFP_ZERO | __GFP_NOWARN;
- size_t size = (size_t) mr->nr_pages << PAGE_SHIFT;
+ size_t size = io_region_size(mr);
unsigned long nr_allocated;
struct page **pages;
diff --git a/io_uring/memmap.h b/io_uring/memmap.h
index a6c63ca2c6f1..d2a940682d19 100644
--- a/io_uring/memmap.h
+++ b/io_uring/memmap.h
@@ -43,4 +43,9 @@ static inline void io_region_publish(struct io_ring_ctx *ctx,
*dst_region = *src_region;
}
+static inline size_t io_region_size(struct io_mapped_region *mr)
+{
+ return (size_t)mr->nr_pages << PAGE_SHIFT;
+}
+
#endif
--
2.49.0
next prev parent reply other threads:[~2025-11-10 13:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 13:04 [PATCH 0/4] random setup cleanups Pavel Begunkov
2025-11-10 13:04 ` Pavel Begunkov [this message]
2025-11-10 13:04 ` [PATCH 2/4] io_uring: pass sq entires in the params struct Pavel Begunkov
2025-11-10 13:04 ` [PATCH 3/4] io_uring: use mem_is_zero to check ring params Pavel Begunkov
2025-11-10 13:04 ` [PATCH 4/4] io_uring: move flags check to io_uring_sanitise_params Pavel Begunkov
2025-11-10 22:02 ` [PATCH 0/4] random setup cleanups Jens Axboe
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=e42e7f3fa3b43a8b8af896f7edc251b113ad7b77.1762701490.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