@@ -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
@@ -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;
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(-)