for_each_mem_range(9)
π for_each_mem_range(9) π
okay so real quick β this is a page from the Kernel API Manual, and honestly? it's a little guy but it does things. stay with me bestie π«Ά
β¨ NAME β¨
for_each_mem_range β iterate through memory areas. that's it, that's the whole vibe. it walks you through the memory regions one at a time like a little tour guide π§
πΈ SYNOPSIS πΈ
for_each_mem_range (i , p_start , p_end );
no cap, that's the whole call. short and iconic π
π ARGUMENTS π
iβ au64used as the loop variable. yeah. it's the counter, the main character of the loop, the little number that keeps going π₯p_startβ a ptr tophys_addr_tfor the start address of the range. it can beNULLβ like, no pressure, it's flexible πΈp_endβ a ptr tophys_addr_tfor the end address of the range. also can beNULL. both of them are allowed to ghost you, lowkey π
π¦ SEE ALSO π¦
so the whole friend group lives in the kernel file ./include/linux/memblock.h, and honestly the squad is deep. here's everyone:
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_rev(9)for_each_reserved_mem_range(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 way that list just keeps going π go read them, iykyk β
that's the whole page bestie, short, sweet, and absolutely serving kernel documentation energy π
sign-off szn: this one's sourced from ./include/linux, dated October 2026, and it's the for_each_mem_range(9) page β periodt π
π¦ 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