__for_each_mem_range_rev(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… __for_each_mem_range_rev(9) ✨

okay so bestie, welcome to the Kernel API Manual 🫢 β€” this one's a macro page, and it's lowkey iconic. buckle up.


πŸŽ€ NAME πŸŽ€

__for_each_mem_range_rev β€” reverse iterate through memblock areas from type_a and not included in type_b. Or just type_a if type_b is NULL. πŸ¦‹

like... it walks backwards through your memblock areas, and it'll filter out whatever's in type_b. and if type_b is NULL? no filtering, we just vibe with type_a alone. periodt.


✨ SYNOPSIS ✨

__for_each_mem_range_rev (i , type_a , type_b , nid , flags , p_start ,
p_end , p_nid );

eight arguments, no cap. let's get into them πŸ’–


🌸 ARGUMENTS 🌸

  • i β€” a u64 used as the loop variable. it's the main character of the iteration, honestly πŸ‘‘
  • type_a β€” ptr to memblock_type to iterate. this is the one we're actually walking through πŸ’«
  • type_b β€” ptr to memblock_type which excludes from the iteration. it's giving "you're not invited to the party" energy πŸ™ˆ
  • nid β€” node selector, use NUMA_NO_NODE for all nodes. all of them, bestie, we're not picking favorites 🌈
  • flags β€” pick from blocks based on memory attributes. this is your vibe check for which blocks make the cut ✨
  • p_start β€” ptr to phys_addr_t for start address of the range, can be NULL. no pressure if you don't wanna pass it 🫢
  • p_end β€” ptr to phys_addr_t for end address of the range, can be NULL. same deal, optional and valid 😌
  • p_nid β€” ptr to int for nid of the range, can be NULL. three out of three optional pointers, we love a flexible icon πŸ’…
ngl, those last three being nullable is a whole mood β€” pass them if you want the info, skip them if you don't. the macro does not care. πŸ’€

πŸ”₯ SEE ALSO πŸ”₯

all the sibling macros and structs, fr fr β€” go read them, they're literally family:

Kernel file ./include/linux/memblock.h 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(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)

that's nineteen references, bestie. nineteen. ate and left no crumbs πŸ“


🧚 sign-off 🧚

this lil masterpiece lives in ./include/linux, dated October 2026, and it's forever known as __for_each_mem_range_rev(9). mwah πŸ’œ go iterate backwards, you've got this πŸ”₯πŸ‘‘

πŸ“¦ where this page comes from