reset_all_zones_managed_pages() iterates over the zones of every online node with a nested loop. for_each_zone() iterates over the same zones in the same order. So use for_each_zone() instead and remove reset_node_managed_pages(). Also add a for_each_zone() no-op stub to avoid breaking the memblock tests. No functional change. Signed-off-by: Sang-Heon Jeon --- Changes from v1 [1] - Add for_each_zone() no-op stub for memblock tests [1] https://lore.kernel.org/all/20260908165733.1703766-1-ekffu200098@gmail.com/ --- mm/memblock.c | 12 ++---------- tools/testing/memblock/linux/mmzone.h | 2 ++ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/mm/memblock.c b/mm/memblock.c index 31961ed628b0..6a03dc58cf2e 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -2465,22 +2465,14 @@ static unsigned long __init free_low_memory_core_early(void) return count; } -static void __init reset_node_managed_pages(pg_data_t *pgdat) +static void __init reset_all_zones_managed_pages(void) { struct zone *z; - for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++) + for_each_zone(z) atomic_long_set(&z->managed_pages, 0); } -static void __init reset_all_zones_managed_pages(void) -{ - struct pglist_data *pgdat; - - for_each_online_pgdat(pgdat) - reset_node_managed_pages(pgdat); -} - /** * memblock_free_all - release free pages to the buddy allocator */ diff --git a/tools/testing/memblock/linux/mmzone.h b/tools/testing/memblock/linux/mmzone.h index 8d934ff5b080..24c149bb708d 100644 --- a/tools/testing/memblock/linux/mmzone.h +++ b/tools/testing/memblock/linux/mmzone.h @@ -13,6 +13,8 @@ struct pglist_data *next_online_pgdat(struct pglist_data *pgdat); pgdat; \ pgdat = next_online_pgdat(pgdat)) +#define for_each_zone(zone) for (zone = NULL; zone; ) + enum zone_type { __MAX_NR_ZONES }; -- 2.43.0