order = page_private(page);
nr_pages = 1 << order;
- set_page_private(page, 0);
- set_page_refcounted(page);
- arch_alloc_page(page, order);
- kernel_map_pages(page, nr_pages, 1);
- kasan_alloc_pages(page, order);
-
- set_page_owner(page, order, __GFP_MOVABLE);
+ post_alloc_hook(page, order, __GFP_MOVABLE);
if (order)
split_page(page, order);
extern void __free_pages_bootmem(struct page *page, unsigned long pfn,
unsigned int order);
extern void prep_compound_page(struct page *page, unsigned int order);
+extern void post_alloc_hook(struct page *page, unsigned int order,
+ gfp_t gfp_flags);
extern int user_min_free_kbytes;
#if defined CONFIG_COMPACTION || defined CONFIG_CMA
return false;
}
+inline void post_alloc_hook(struct page *page, unsigned int order,
+ gfp_t gfp_flags)
+{
+ set_page_private(page, 0);
+ set_page_refcounted(page);
+
+ arch_alloc_page(page, order);
+ kernel_map_pages(page, 1 << order, 1);
+ kernel_poison_pages(page, 1 << order, 1);
+ kasan_alloc_pages(page, order);
+ set_page_owner(page, order, gfp_flags);
+}
+
static void prep_new_page(struct page *page, unsigned int order, gfp_t gfp_flags,
unsigned int alloc_flags)
{
poisoned &= page_is_poisoned(p);
}
- set_page_private(page, 0);
- set_page_refcounted(page);
-
- arch_alloc_page(page, order);
- kernel_map_pages(page, 1 << order, 1);
- kernel_poison_pages(page, 1 << order, 1);
- kasan_alloc_pages(page, order);
+ post_alloc_hook(page, order, gfp_flags);
if (!free_pages_prezeroed(poisoned) && (gfp_flags & __GFP_ZERO))
for (i = 0; i < (1 << order); i++)
if (order && (gfp_flags & __GFP_COMP))
prep_compound_page(page, order);
- set_page_owner(page, order, gfp_flags);
-
/*
* page is set pfmemalloc when ALLOC_NO_WATERMARKS was necessary to
* allocate the page. The expectation is that the caller is taking
out:
spin_unlock_irqrestore(&zone->lock, flags);
if (isolated_page) {
- kernel_map_pages(page, (1 << order), 1);
- set_page_refcounted(page);
- set_page_owner(page, order, __GFP_MOVABLE);
+ post_alloc_hook(page, order, __GFP_MOVABLE);
__free_pages(isolated_page, order);
}
}