alloc_contig_frozen_pages(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– alloc_contig_frozen_pages(9) β€” a Kernel API Manual moment πŸ’–

okay so bestie, welcome to the alloc_contig_frozen_pages page β€” this is a Kernel API Manual entry and it's lowkey one of those "you need a big chunk of memory and the normal way isn't giving" situations. grab a strawberry πŸ“ and let's get into it.


✨ NAME ✨

alloc_contig_frozen_pages β€” tries to find and allocate a contiguous range of frozen pages. that's it, that's the vibe. πŸ’…


🌸 SYNOPSIS 🌸

struct page * alloc_contig_frozen_pages (unsigned long nr_pages , gfp_t gfp_mask , int nid , nodemask_t *nodemask );

πŸŽ€ ARGUMENTS πŸŽ€

  • nr_pages β€” how many contiguous pages you want. the whole point, honestly. πŸ‘‘
  • gfp_mask β€” the GFP mask. the node/zone/placement hints in here limit the search; only some action and reclaim modifiers are supported. the reclaim modifiers are the ones that control allocation behavior during compaction/migration/reclaim. so yeah, not every flag is welcome at this party 🫢
  • nid β€” target node. where you'd like it to live.
  • nodemask β€” mask for other possible nodes. the "backup plan" list, basically.

πŸ¦‹ DESCRIPTION πŸ¦‹

so this routine is literally just a wrapper around alloc_contig_frozen_range. that's the whole personality. πŸ’€

what it does: it scans over zones on an applicable zonelist to find a contiguous pfn range which can then be tried for allocation with alloc_contig_frozen_range. think of it as doing the searching so the real allocator can do the taking.

this routine is intended for allocation requests which can not be fulfilled with the buddy allocator. so if buddy already said no, this is your girl. πŸ”₯

now the alignment tea β˜• β€” the allocated memory is always aligned to a page boundary. and if nr_pages is a power of two, then the allocated range is also guaranteed to be aligned to that same nr_pages (e.g. a 1GB request would be aligned to 1GB). iconic behavior, honestly. ✨

⚠️ bestie the cleanup is not optional!! allocated frozen pages need be freed with free_contig_frozen_range, or by manually calling free_frozen_pages on each allocated frozen non-compound page β€” for compound frozen pages, they could be freed with free_frozen_pages directly. don't leave these hanging, it's giving memory leak 😭

πŸ’œ RETURN πŸ’œ

pointer to contiguous frozen pages on success πŸŽ‰, or NULL if not successful πŸ™ˆ.


🌈 SEE ALSO 🌈

buckle up, this list is long and honestly kind of iconic. it's all from the kernel file ./mm/page_alloc.c:

go read those next, iykyk πŸ“š


and that's the page!! this one came from ./mm, dated October 2026, in the Kernel API Manual β€” slay, go allocate something big, and remember to free it πŸ§šπŸ’– periodt.

πŸ“¦ where this page comes from