memblock_alloc_hugetlb(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ memblock_alloc_hugetlb β€” allocate boot memory for HugeTLB pages πŸ¦‹

okay so bestie, you're in the Kernel API Manual and this one's giving "early boot, big pages, no drama." it's memblock_alloc_hugetlb(9) and honestly she's iconic in a very specific way. let's get into it ✨


✨ SYNOPSIS ✨

void * memblock_alloc_hugetlb (phys_addr_t size , int nid , bool
exact_nid );

three args, one pointer back, and yes the return type is void * β€” keep that in mind, it matters later πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • size β€” how big the memory block you want is, measured in bytes. that's it, that's the whole vibe.
  • nid β€” the nid of the free memory to find. if you're like "idk, anywhere is fine," you pass NUMA_NO_NODE and she'll take any node. queen of flexibility 🫢
  • exact_nid β€” this is the picky one. if true, it will only allocate from the specified nid, no substitutions, no plan B (main character energy fr). if false, the specified nid gets tried first and then all nodes are tried as a fallback. so like, "try my fave first but honestly whatever works" πŸ’–

🌸 DESCRIPTION 🌸

HugeTLB pages are always aligned by their size, so lowkey the alignment just matches size. no extra math needed, it's giving self-consistent πŸ’…

since this memory is for userspace, mirrored memory is not used β€” noted, important, don't come for me about it.

the memory is not zeroed. so like, don't assume it's a fresh clean slate, bestie, because it is not πŸ™ˆ

and the big one: this does not panic if the request can't be satisfied. she simply returns nothing and moves on. no dramatics, no kernel meltdown. periodt.


⭐ RETURN ⭐

  • on success β†’ the virtual address of the allocated memory block πŸŽ‰
  • on failure β†’ NULL πŸ’€ (and remember: no panic, just NULL, so pls check it, i'm begging)

🧚 SEE ALSO 🧚

the whole memblock friend group, assembled. kernel file ./mm/memblock.c, plus memblock overview(9), and then, in this exact order, no cap:


ok that's the whole page!! go forth, allocate your hugetlb boot memory, check for NULL, and remember: not zeroed, not mirrored, not panicking. slay πŸŒˆπŸ‘‘

mwah πŸ’œ β€” this cutie lives in ./mm, dated October 2026, from the memblock_alloc_hugetlb(9) era of the Kernel API Manual. bye bestie, ily, read the SEE ALSO πŸŽ€

πŸ“¦ where this page comes from