Skip to content

Commit

Permalink
mm, vmstat: print non-populated zones in zoneinfo
Browse files Browse the repository at this point in the history
Initscripts can use the information (protection levels) from
/proc/zoneinfo to configure vm.lowmem_reserve_ratio at boot.

vm.lowmem_reserve_ratio is an array of ratios for each configured zone
on the system.  If a zone is not populated on an arch, /proc/zoneinfo
suppresses its output.

This results in there not being a 1:1 mapping between the set of zones
emitted by /proc/zoneinfo and the zones configured by
vm.lowmem_reserve_ratio.

This patch shows statistics for non-populated zones in /proc/zoneinfo.
The zones exist and hold a spot in the vm.lowmem_reserve_ratio array.
Without this patch, it is not possible to determine which index in the
array controls which zone if one or more zones on the system are not
populated.

Remaining users of walk_zones_in_node() are unchanged.  Files such as
/proc/pagetypeinfo require certain zone data to be initialized properly
for display, which is not done for unpopulated zones.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: David Rientjes <[email protected]>
Reviewed-by: Anshuman Khandual <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Michal Hocko <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
rientjes authored and torvalds committed May 3, 2017
1 parent bbf9ce9 commit b2bd859
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions mm/vmstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1124,16 +1124,20 @@ static void frag_stop(struct seq_file *m, void *arg)
{
}

/* Walk all the zones in a node and print using a callback */
/*
* Walk zones in a node and print using a callback.
* If @assert_populated is true, only use callback for zones that are populated.
*/
static void walk_zones_in_node(struct seq_file *m, pg_data_t *pgdat,
bool assert_populated,
void (*print)(struct seq_file *m, pg_data_t *, struct zone *))
{
struct zone *zone;
struct zone *node_zones = pgdat->node_zones;
unsigned long flags;

for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) {
if (!populated_zone(zone))
if (assert_populated && !populated_zone(zone))
continue;

spin_lock_irqsave(&zone->lock, flags);
Expand Down Expand Up @@ -1161,7 +1165,7 @@ static void frag_show_print(struct seq_file *m, pg_data_t *pgdat,
static int frag_show(struct seq_file *m, void *arg)
{
pg_data_t *pgdat = (pg_data_t *)arg;
walk_zones_in_node(m, pgdat, frag_show_print);
walk_zones_in_node(m, pgdat, true, frag_show_print);
return 0;
}

Expand Down Expand Up @@ -1202,7 +1206,7 @@ static int pagetypeinfo_showfree(struct seq_file *m, void *arg)
seq_printf(m, "%6d ", order);
seq_putc(m, '\n');

walk_zones_in_node(m, pgdat, pagetypeinfo_showfree_print);
walk_zones_in_node(m, pgdat, true, pagetypeinfo_showfree_print);

return 0;
}
Expand Down Expand Up @@ -1254,7 +1258,7 @@ static int pagetypeinfo_showblockcount(struct seq_file *m, void *arg)
for (mtype = 0; mtype < MIGRATE_TYPES; mtype++)
seq_printf(m, "%12s ", migratetype_names[mtype]);
seq_putc(m, '\n');
walk_zones_in_node(m, pgdat, pagetypeinfo_showblockcount_print);
walk_zones_in_node(m, pgdat, true, pagetypeinfo_showblockcount_print);

return 0;
}
Expand All @@ -1280,7 +1284,7 @@ static void pagetypeinfo_showmixedcount(struct seq_file *m, pg_data_t *pgdat)
seq_printf(m, "%12s ", migratetype_names[mtype]);
seq_putc(m, '\n');

walk_zones_in_node(m, pgdat, pagetypeinfo_showmixedcount_print);
walk_zones_in_node(m, pgdat, true, pagetypeinfo_showmixedcount_print);
#endif /* CONFIG_PAGE_OWNER */
}

Expand Down Expand Up @@ -1430,12 +1434,15 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat,
}

/*
* Output information about zones in @pgdat.
* Output information about zones in @pgdat. All zones are printed regardless
* of whether they are populated or not: lowmem_reserve_ratio operates on the
* set of all zones and userspace would not be aware of such zones if they are
* suppressed here (zoneinfo displays the effect of lowmem_reserve_ratio).
*/
static int zoneinfo_show(struct seq_file *m, void *arg)
{
pg_data_t *pgdat = (pg_data_t *)arg;
walk_zones_in_node(m, pgdat, zoneinfo_show_print);
walk_zones_in_node(m, pgdat, false, zoneinfo_show_print);
return 0;
}

Expand Down Expand Up @@ -1841,7 +1848,7 @@ static int unusable_show(struct seq_file *m, void *arg)
if (!node_state(pgdat->node_id, N_MEMORY))
return 0;

walk_zones_in_node(m, pgdat, unusable_show_print);
walk_zones_in_node(m, pgdat, true, unusable_show_print);

return 0;
}
Expand Down Expand Up @@ -1893,7 +1900,7 @@ static int extfrag_show(struct seq_file *m, void *arg)
{
pg_data_t *pgdat = (pg_data_t *)arg;

walk_zones_in_node(m, pgdat, extfrag_show_print);
walk_zones_in_node(m, pgdat, true, extfrag_show_print);

return 0;
}
Expand Down

0 comments on commit b2bd859

Please sign in to comment.