alloc_pages(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 🧚


Catch you in the ./mm source tree β€” October 2026 edition, mwah πŸ’‹

πŸ“¦ where this page comes from