alloc_pages(9)
π alloc_pages π
okay so this is the Kernel API Manual, and todayβs main character is alloc_pages β yes, the page-allocating bestie. letβs get into it. β¨
πΈ NAME πΈ
alloc_pages β Allocate pages. Thatβs the whole name, no cap. π
π¦ SYNOPSIS π¦
struct page * alloc_pages (gfp_t gfp , unsigned int order );
π ARGUMENTS π
gfpβ GFP flags. bring the right flags, bestie. π«Άorderβ Power of two of number of pages to allocate. like, the exponent energy for how many pages you want. π₯
β¨ DESCRIPTION β¨
okay so alloc_pages allocates 1 << order contiguous pages β yes, contiguous, we love a clean block. π
The physical address of the first page is naturally aligned (eg an order-3 allocation will be aligned to a multiple of 8 * PAGE_SIZE bytes). iconic alignment behaviour, honestly. π
The NUMA policy of the current process is honoured when in process context. periodt. π
π CONTEXT π
Can be called from any context, providing the appropriate GFP flags are used. thatβs the rule, bestie β any context, appropriate GFP flags, okay? β
β RETURN β
The page on success or NULL if allocation fails. if it fails itβs NULL, not a vibe. π
π§ SEE ALSO π§
- Kernel file
./mm/mempolicy.c numa_nearest_node(9)nearest_node_nodemask(9)folio_can_map_prot_numa(9)alloc_pages_mpol(9)vma_alloc_folio(9)mpol_misplaced(9)mpol_shared_policy_init(9)mpol_parse_str(9)mpol_to_str(9)
Catch you in the ./mm source tree β October 2026 edition, mwah π
π¦ 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