[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251015172555.2797238-1-csander@purestorage.com>
Date: Wed, 15 Oct 2025 11:25:54 -0600
From: Caleb Sander Mateos <csander@...estorage.com>
To: Jens Axboe <axboe@...nel.dk>
Cc: Caleb Sander Mateos <csander@...estorage.com>,
io-uring@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] io_uring/memmap: return bool from io_mem_alloc_compound()
io_mem_alloc_compound() returns either ERR_PTR(-ENOMEM) or a virtual
address for the allocated memory, but its caller just checks whether the
result is an error. Return a bool success value instead.
Signed-off-by: Caleb Sander Mateos <csander@...estorage.com>
---
io_uring/memmap.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/io_uring/memmap.c b/io_uring/memmap.c
index 2e99dffddfc5..b53733a54074 100644
--- a/io_uring/memmap.c
+++ b/io_uring/memmap.c
@@ -13,30 +13,30 @@
#include "memmap.h"
#include "kbuf.h"
#include "rsrc.h"
#include "zcrx.h"
-static void *io_mem_alloc_compound(struct page **pages, int nr_pages,
- size_t size, gfp_t gfp)
+static bool io_mem_alloc_compound(struct page **pages, int nr_pages,
+ size_t size, gfp_t gfp)
{
struct page *page;
int i, order;
order = get_order(size);
if (order > MAX_PAGE_ORDER)
- return ERR_PTR(-ENOMEM);
+ return false;
else if (order)
gfp |= __GFP_COMP;
page = alloc_pages(gfp, order);
if (!page)
- return ERR_PTR(-ENOMEM);
+ return false;
for (i = 0; i < nr_pages; i++)
pages[i] = page + i;
- return page_address(page);
+ return true;
}
struct page **io_pin_pages(unsigned long uaddr, unsigned long len, int *npages)
{
unsigned long start, end, nr_pages;
@@ -157,18 +157,16 @@ static int io_region_allocate_pages(struct io_ring_ctx *ctx,
{
gfp_t gfp = GFP_KERNEL_ACCOUNT | __GFP_ZERO | __GFP_NOWARN;
size_t size = (size_t) mr->nr_pages << PAGE_SHIFT;
unsigned long nr_allocated;
struct page **pages;
- void *p;
pages = kvmalloc_array(mr->nr_pages, sizeof(*pages), gfp);
if (!pages)
return -ENOMEM;
- p = io_mem_alloc_compound(pages, mr->nr_pages, size, gfp);
- if (!IS_ERR(p)) {
+ if (io_mem_alloc_compound(pages, mr->nr_pages, size, gfp)) {
mr->flags |= IO_REGION_F_SINGLE_REF;
goto done;
}
nr_allocated = alloc_pages_bulk_node(gfp, NUMA_NO_NODE,
--
2.45.2
Powered by blists - more mailing lists