Re: [patch] mm, zoneinfo: print non-populated zones

From: Anshuman Khandual
Date: Fri Mar 03 2017 - 14:43:31 EST


On 03/03/2017 04:56 AM, David Rientjes wrote:
> 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.

Right, its a problem when it does not even display array elements with
an index value associated with it. But changing the array display will
break the interface where as displaying non populated zones in the
/proc/zoneinfo does not break anything.

>
> 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.
>
> Signed-off-by: David Rientjes <rientjes@xxxxxxxxxx>
> ---
> mm/vmstat.c | 22 +++++++++++++---------
> 1 file changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -1121,8 +1121,12 @@ 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 @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 populated,
> void (*print)(struct seq_file *m, pg_data_t *, struct zone *))
> {
> struct zone *zone;
> @@ -1130,7 +1134,7 @@ static void walk_zones_in_node(struct seq_file *m, pg_data_t *pgdat,
> unsigned long flags;
>
> for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) {
> - if (!populated_zone(zone))
> + if (populated && !populated_zone(zone))

The name of the Boolean "populated" is bit misleading IMHO. What I think you
want here is to invoke the callback if the zone is populated as well as this
variable is true. The variable can be named something like 'assert_populated'.