alloc_pages_exact_nid(9)
β¨ alloc_pages_exact_nid(9) β¨
okay bestie, welcome to the Kernel API Manual π this one's a little kernel function that's lowkey obsessed with one specific node. let's get into it π
πΈ NAME πΈ
alloc_pages_exact_nid β allocate an exact number of physically-contiguous pages on a node. no cap, that's literally the whole vibe β¨
π¦ SYNOPSIS π¦
void * alloc_pages_exact_nid (int nid , size_t size , gfp_t gfp_mask );
like... it takes three things and gives you a pointer, slay π
π ARGUMENTS π
nidβ the preferred node ID where memory should be allocated π it's giving "i have a favourite and it's this node"sizeβ the number of bytes to allocate π exact bytes, we don't do vibes-based sizing heregfp_maskβ GFP flags for the allocation, and bestie listen to me: must not contain__GFP_COMPπ« like, hard no, do not pass that
π DESCRIPTION π
so it's like alloc_pages_exact, but it tries to allocate on node nid first before falling back. that's it, that's the whole plot π«Ά highkey simple, highkey iconic.
π RETURN π
pointer to the allocated area, or NULL in case of error π so yeah, always check your pointer, fr fr.
β SEE ALSO β
the whole kernel crew, assembled π§ and yeah, kernel file ./mm/page_alloc.c is where the magic lives:
__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)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)alloc_pages_nolock(9)
like... a whole friend group π love that for them π
π reminder bestie:gfp_maskmust not contain__GFP_COMP. i'm not gonna say it a third time... okay maybe i will. don't do it π
π sign-off π
that's the page!! it lives in ./mm π and this cutie was dated October 2026 β see you in the next manpage, 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