diff mbox series

[RFC,4/6] mm: avoid show invalid zone in /proc/zoneinfo

Message ID 20230511065607.37407-5-ying.huang@intel.com (mailing list archive)
State New
Headers show
Series mm: improve page allocator scalability via splitting zones | expand

Commit Message

Huang, Ying May 11, 2023, 6:56 a.m. UTC
In the following patch of the series, one or multiple zone instances
may be created for one zone type.  So the total number of zone
instances of a node becomes dynamic based on system configurations.
So, the real zone instance number instead of static max zone number is
used to show zone information in /proc/zoneinfo.

Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: David Hildenbrand <david@redhat.com>
Cc: Johannes Weiner <jweiner@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Matthew Wilcox <willy@infradead.org>
---
 include/linux/mmzone.h | 5 +++++
 mm/vmstat.c            | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 0c569c5fa0d1..18d64cf1263c 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1809,6 +1809,11 @@  static inline int last_zone_idx(pg_data_t *pgdat, enum zone_type zt)
 	return pgdat->node_zone_types[zt].last_zone_idx;
 }
 
+static inline int last_zone_idx_pgdat(pg_data_t *pgdat)
+{
+	return last_zone_idx(pgdat, MAX_NR_ZONE_TYPES - 1);
+}
+
 #ifdef CONFIG_SPARSEMEM
 #include <asm/sparsemem.h>
 #endif
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 1ea6a5ce1c41..bade3f50d1f8 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1441,8 +1441,9 @@  static void walk_zones_in_node(struct seq_file *m, pg_data_t *pgdat,
 	struct zone *zone;
 	struct zone *node_zones = pgdat->node_zones;
 	unsigned long flags;
+	int last_zone_idx = last_zone_idx_pgdat(pgdat);
 
-	for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) {
+	for (zone = node_zones; zone - node_zones <= last_zone_idx; ++zone) {
 		if (assert_populated && !populated_zone(zone))
 			continue;