for_each_fr...ange_reverse(9)
π for_each_fr...ange_reverse(9) π
okay so welcome to the Kernel API Manual, bestie β the for_each_fr...ange_reverse(9) page and yes the name is literally abbreviated with dots in the header, that's not a typo, that's just how the man page title renders. we move. π¦
β¨ NAME β¨
for_each_free_mem_range_reverse β rev-iterate through free memblock areas π
like, you go through them backwards, it's giving reverse chronological but for memory regions.
πΈ SYNOPSIS πΈ
for_each_free_mem_range_reverse (i , nid , flags , p_start , p_end ,
p_nid );
that's the whole call, keep the spacing exactly like that, no cap. β¨
π ARGUMENTS π
iβu64used as loop variable. it's the little counter guy that just chugs along, being a loop variable, main character energy honestly. π«Άnidβ node selector, andNUMA_NO_NODEmeans all nodes. so if you want everything everywhere, that's your girl. πflagsβ pick from blocks based on memory attributes. you're choosing which blocks qualify, based on their attributes, okurrr. πp_startβ ptr tophys_addr_tfor start address of the range, and yes it can beNULL. no pressure. πp_endβ ptr tophys_addr_tfor end address of the range, also can beNULL. equally chill. πp_nidβ ptr tointfor nid of the range, and yep, can beNULLtoo. three for three, slay. π
π¦ DESCRIPTION π¦
so what it does: it walks over free areas of memblock β and "free" here means literally memory && !reserved, iykyk, not reserved, just memory β and it does that walk in reverse order. back it up, back it up. π₯
and the cute part? it's available as soon as memblock is initialized. no waiting around, it's ready early, lowkey iconic. β
π SEE ALSO π
Kernel file ./include/linux/memblock.h, plus the whole friend group:
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_reserved_mem_range(9)for_each_mem_pfn_range(9)for_each_free_mem_range(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)
that's a lot of friends and honestly? obsessed. π
π cute little sign-off: this page lives at ./include/linux and it's dated October 2026, so yeah, timestamped and everything. go forth and rev-iterate, bestie. π§β¨
π¦ 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