for_each_mem_pfn_range(9)
π« for_each_mem_pfn_range π«
okay so bestie, welcome to the Kernel API Manual, section 9 β yes we're literally in the kernel docs and it's giving big-brain energy. this page is about for_each_mem_pfn_range, and no cap, it's a whole vibe once you get it.
β¨ NAME β¨
for_each_mem_pfn_range β early memory pfn range iterator π¦
like, it walks your early memory ranges for you so you don't have to. main character behavior fr fr.
π SYNOPSIS π
for_each_mem_pfn_range (i , nid , p_start , p_end , p_nid );
that's the whole invocation, slay. keep it exactly like that π
πΈ ARGUMENTS πΈ
iβ an integer used as loop variable. yep, your classic loop counter, iconic, does exactly what it says πnidβ node selector. passMAX_NUMNODESif you want all the nodes, no picking favorites πp_startβ ptr toulongfor start pfn of the range. and good news: it can beNULLπp_endβ ptr toulongfor end pfn of the range. also can beNULL, we love flexibility β¨p_nidβ ptr tointfor nid of the range. can beNULLtoo, all three of the ptrs are optional like that π«Ά
π₯ DESCRIPTION π₯
Walks over configured memory ranges. that's it, that's the whole thing β lowkey simple, highkey useful π
π SEE ALSO π
the kernel file is ./include/linux/memblock.h β go touch it, it's where the lore lives π and also these absolute icons:
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_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)
like, that's a whole friend group right there ππ
ngl bestie, just remember the ptrs can beNULLandMAX_NUMNODESmeans "all the nodes" β that's the whole vibe check β
and that's the page! sourced from ./include/linux, dated October 2026, and it's literally the for_each_mem_pfn_range(9) page. mwah, go iterate some pfns πππ
π¦ 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