Skip to contentSkip to conversation

memblock: use for_each_zone() in reset_all_zones_managed_pages()

PATCH New Sang-Heon Jeon 1 participant 1 message Sep 15

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 memblock: use for_each_zone() in reset_all_zones_managed_pages()

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.

---
Changes from v1 [1]
- Add for_each_zone() no-op stub for memblock tests

[1] https://lore.kernel.org/all/[email protected]/

---
 mm/memblock.c                         | 12 ++----------
 tools/testing/memblock/linux/mmzone.h |  2 ++
 2 files changed, 4 insertions(+), 10 deletions(-)
mm/memblock.c +2 -10
index 31961ed628b0..6a03dc58cf2e 100644
@@ -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
  */
tools/testing/memblock/linux/mmzone.h +2 -0
index 8d934ff5b080..24c149bb708d 100644
@@ -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
 };
Signature · 1 line
2.43.0