From 9eeeb4e36ceed730621a114607802ebafb76e962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Wed, 22 May 2024 13:57:01 +0200 Subject: [PATCH] lx_emul: align __alloc_pages_bulk implementation The upstream implementation is used to allocate order-0 pages in a batch and users, e.g. page-pool allocator, may rely on that behaviour and thus it is implemented with this commit. --- .../src/lib/lx_emul/shadow/mm/page_alloc.c | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/repos/dde_linux/src/lib/lx_emul/shadow/mm/page_alloc.c b/repos/dde_linux/src/lib/lx_emul/shadow/mm/page_alloc.c index f18846dc70..53aab8cb41 100644 --- a/repos/dde_linux/src/lib/lx_emul/shadow/mm/page_alloc.c +++ b/repos/dde_linux/src/lib/lx_emul/shadow/mm/page_alloc.c @@ -19,29 +19,6 @@ #include #include -unsigned long __alloc_pages_bulk(gfp_t gfp,int preferred_nid, - nodemask_t * nodemask, int nr_pages, - struct list_head * page_list, struct page ** page_array) -{ - if (page_list) - lx_emul_trace_and_stop("__alloc_pages_bulk unsupported argument"); - - { - void const *ptr = lx_emul_mem_alloc_aligned(PAGE_SIZE*nr_pages, PAGE_SIZE); - struct page *page = lx_emul_virt_to_page(ptr); - int i; - - for (i = 0; i < nr_pages; i++) { - - if (page_array[i]) - lx_emul_trace_and_stop("__alloc_pages_bulk: page_array entry not null"); - - page_array[i] = page + i; - } - } - - return nr_pages; -} static void lx_free_pages(struct page *page, bool force) { @@ -80,6 +57,33 @@ static struct page * lx_alloc_pages(unsigned const nr_pages) } +unsigned long __alloc_pages_bulk(gfp_t gfp,int preferred_nid, + nodemask_t * nodemask, int nr_pages, + struct list_head * page_list, struct page ** page_array) +{ + unsigned long allocated_pages = 0; + int i; + + if (page_list) + lx_emul_trace_and_stop("__alloc_pages_bulk unsupported argument"); + + for (i = 0; i < nr_pages; i++) { + + if (page_array[i]) + lx_emul_trace_and_stop("__alloc_pages_bulk: page_array entry not null"); + + page_array[i] = lx_alloc_pages(1); + + if (!page_array[i]) + break; + + ++allocated_pages; + } + + return allocated_pages; +} + + /* * In earlier kernel versions, '__alloc_pages' was an inline function. */