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.
This commit is contained in:
Josef Söntgen 2024-05-22 13:57:01 +02:00 committed by Norman Feske
parent 191306531c
commit 9eeeb4e36c

View File

@ -19,29 +19,6 @@
#include <lx_emul/debug.h>
#include <lx_emul/page_virt.h>
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.
*/