memblock_alloc_hugetlb(9)
π¦ 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 passNUMA_NO_NODEand she'll take any node. queen of flexibility π«Άexact_nidβ this is the picky one. iftrue, it will only allocate from the specified nid, no substitutions, no plan B (main character energy fr). iffalse, 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, justNULL, 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:
__memblock_find_range_bottom_up(9)__memblock_find_range_top_down(9)memblock_find_in_range_node(9)memblock_find_in_range(9)memblock_discard(9)memblock_double_array(9)memblock_merge_regions(9)memblock_insert_region(9)memblock_add_range(9)memblock_add_node(9)memblock_add(9)memblock_validate_numa_coverage(9)memblock_isolate_range(9)memblock_free(9)memblock_phys_free(9)memblock_setclr_flag(9)memblock_mark_hotplug(9)memblock_clear_hotplug(9)memblock_mark_mirror(9)memblock_mark_nomap(9)memblock_clear_nomap(9)memblock_reserved_mark_noinit(9)memblock_reserved_mark_kern(9)memblock_mark_kho_scratch(9)memblock_clear_kho_scratch(9)__next_mem_range(9)__next_mem_range_rev(9)memblock_set_node(9)memblock_alloc_range_nid(9)memblock_phys_alloc_range(9)memblock_phys_alloc_try_nid(9)memblock_alloc_internal(9)memblock_alloc_exact_nid_raw(9)memblock_alloc_try_nid_raw(9)memblock_alloc_try_nid(9)__memblock_alloc_or_panic(9)memblock_estimated_nr_free_pages(9)memblock_is_region_memory(9)memblock_is_region_reserved(9)memblock_free_all(9)reserve_mem_find_by_name(9)reserve_mem_release_by_name(9)
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
- 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