for_each_reserved_mem_range(9)
π for_each_reserved_mem_range(9) β Kernel API Manual π
okay bestie, so we're in the Kernel API Manual today and the star of the show is for_each_reserved_mem_range β yes it's a long name, yes it ate, let's get into it β¨
πΈ NAME πΈ
for_each_reserved_mem_range β iterate over all reserved memblock areas π
Literally what it says on the tin. It loops over the reserved bits. Slay.
β¨ SYNOPSIS β¨
for_each_reserved_mem_range (i , p_start , p_end );
That's the whole vibe. Three args, no cap. π«Ά
π¦ ARGUMENTS π¦
iβ au64used as the loop variable. it's your counter bestie, it just keeps going π’p_startβ ptr tophys_addr_tfor the start address of the range, can beNULL. so like, it points at where the range begins β and if you don't care to know,NULLis totally valid, king behavior πp_endβ ptr tophys_addr_tfor the end address of the range, can beNULL. same deal, it's the end of the range, and againNULLis allowed if you're not nosy π
π DESCRIPTION π
Walks over reserved areas of memblock. Available as soon as memblock is initialized.
That's it. That's the whole thing. It's giving "small but mighty" energy β you don't need memblock to be fully grown up or anything, the second it's initialized this bad boy is ready to go π₯
no cap, this is genuinely one of the short ones. enjoy it while it lasts bestie, some of the neighbors in SEE ALSO are long π
π₯ SEE ALSO π₯
okay so this is the friend group π«Ά β the kernel file lives at ./include/linux/memblock.h, and here's everyone else:
enum memblock_flags(9)struct memblock_region(9)struct memblock_type(9)struct memblock(9)for_each_physmem_range(9)__for_each_mem_range(9)__for_each_mem_range_rev(9)for_each_mem_range(9)for_each_mem_range_rev(9)for_each_mem_pfn_range(9)for_each_free_mem_range(9)for_each_free_mem_range_reverse(9)memblock_set_current_limit(9)memblock_region_memory_base_pfn(9)memblock_region_memory_end_pfn(9)memblock_region_reserved_base_pfn(9)memblock_region_reserved_end_pfn(9)for_each_mem_region(9)for_each_reserved_mem_region(9)
the whole for_each_* cinematic universe fr fr ππ
and that's the page diva π
β sourced from ./include/linux, dated October 2026, and yes it's still called for_each_reserved_mem_range(9) because we don't do rebrands here πβ¨
π¦ 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