alloc_pages_nolock(9)
β¨ NAME β¨
okay so bestie, this is alloc_pages_nolock(9) from the Kernel API Manual β the icon of opportunistic, reentrant page allocation from literally any context π
β¨
πΈ SYNOPSIS πΈ
struct page * alloc_pages_nolock (gfp_t gfp_flags , int nid , unsigned
int order );
π ARGUMENTS π
gfp_flagsβ the GFP flags, babes. The only one you're allowed to pass is__GFP_ACCOUNT, plus some flags that get set internally no matter what (peepgfp_nolockfor that) πnidβ the node to allocate from πΊοΈorderβ the allocation order size π
π¦ DESCRIPTION π¦
So it allocates pages of a given order from the given node, periodt. This is safe to call from any context where RCU is watching β from atomic, from NMI, and also in the reentrant allocator -> tracepoint -> alloc_pages_nolock_noprof pipeline πβ¨
The allocation is best effort, and you should genuinely expect it to fail easily, so nobody should rely on the success. Failures are not reported via warn_alloc. And the original literally says: βSee always fail conditions below.β That's the vibe π«Ά
π RETURN π
It gives you the allocated page, or NULL on failure π
NULLdoes not meanEBUSYorEAGAIN. It meansENOMEM. There is no reason to call it again and expect!NULLβ like, none, bestie π
π SEE ALSO π
Kernel file ./mm/page_alloc.c, plus all these lovely little references:
__get_pfnblock_flags_mask(9), get_pfnblock_bit(9), get_pfnblock_migratetype(9), __set_pfnblock_flags_mask(9), set_pfnblock_bit(9), clear_pfnblock_bit(9), set_pageblock_migratetype(9), __move_freepages_block_isolate(9), __putback_isolated_page(9), __free_pages(9), free_pages(9), alloc_pages_exact(9), alloc_pages_exact_nid(9), free_pages_exact(9), nr_free_zone_pages(9), nr_free_buffer_pages(9), find_next_best_node(9), free_reserved_pages(9), setup_per_zone_wmarks(9), __free_contig_range(9), alloc_contig_frozen_range(9), alloc_contig_range(9), alloc_contig_frozen_pages(9), alloc_contig_pages(9), free_contig_frozen_range(9), free_contig_range(9)
mwah π this lil page came from ./mm and is dated October 2026 β slay, go read the source, ily π«Άπ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms