alloc_pages_nolock(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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 (peep gfp_nolock for 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 😭

NULL does not mean EBUSY or EAGAIN. It means ENOMEM. 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