All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] mm, zoneinfo: print non-populated zones
@ 2017-03-02 23:26 ` David Rientjes
  0 siblings, 0 replies; 22+ messages in thread
From: David Rientjes @ 2017-03-02 23:26 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Vlastimil Babka, Mel Gorman, Johannes Weiner, linux-kernel, linux-mm

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.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 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))
 			continue;
 
 		spin_lock_irqsave(&zone->lock, flags);
@@ -1158,7 +1162,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;
 }
 
@@ -1199,7 +1203,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;
 }
@@ -1251,7 +1255,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;
 }
@@ -1277,7 +1281,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 */
 }
 
@@ -1434,7 +1438,7 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat,
 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;
 }
 
@@ -1853,7 +1857,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;
 }
@@ -1905,7 +1909,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;
 }

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [patch] mm, zoneinfo: print non-populated zones
@ 2017-03-02 23:26 ` David Rientjes
  0 siblings, 0 replies; 22+ messages in thread
From: David Rientjes @ 2017-03-02 23:26 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Vlastimil Babka, Mel Gorman, Johannes Weiner, linux-kernel, linux-mm

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.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 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))
 			continue;
 
 		spin_lock_irqsave(&zone->lock, flags);
@@ -1158,7 +1162,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;
 }
 
@@ -1199,7 +1203,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;
 }
@@ -1251,7 +1255,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;
 }
@@ -1277,7 +1281,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 */
 }
 
@@ -1434,7 +1438,7 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat,
 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;
 }
 
@@ -1853,7 +1857,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;
 }
@@ -1905,7 +1909,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;
 }

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [patch] mm, zoneinfo: print non-populated zones
  2017-03-02 23:26 ` David Rientjes
@ 2017-03-03 13:35   ` Anshuman Khandual
  -1 siblings, 0 replies; 22+ messages in thread
From: Anshuman Khandual @ 2017-03-03 13:35 UTC (permalink / raw)
  To: David Rientjes, Andrew Morton
  Cc: Vlastimil Babka, Mel Gorman, Johannes Weiner, linux-kernel, linux-mm

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@google.com>
> ---
>  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'.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [patch] mm, zoneinfo: print non-populated zones
@ 2017-03-03 13:35   ` Anshuman Khandual
  0 siblings, 0 replies; 22+ messages in thread
From: Anshuman Khandual @ 2017-03-03 13:35 UTC (permalink / raw)
  To: David Rientjes, Andrew Morton
  Cc: Vlastimil Babka, Mel Gorman, Johannes Weiner, linux-kernel, linux-mm

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@google.com>
> ---
>  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'.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [patch] mm, zoneinfo: print non-populated zones
  2017-03-03 13:35   ` Anshuman Khandual
@ 2017-03-03 22:46     ` David Rientjes
  -1 siblings, 0 replies; 22+ messages in thread
From: David Rientjes @ 2017-03-03 22:46 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: Andrew Morton, Vlastimil Babka, Mel Gorman, Johannes Weiner,
	linux-kernel, linux-mm

On Fri, 3 Mar 2017, Anshuman Khandual wrote:

> > 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.
> 

Precisely.

> 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'.
> 

I like it, I'll send a v2.  Thanks.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [patch] mm, zoneinfo: print non-populated zones
@ 2017-03-03 22:46     ` David Rientjes
  0 siblings, 0 replies; 22+ messages in thread
From: David Rientjes @ 2017-03-03 22:46 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: Andrew Morton, Vlastimil Babka, Mel Gorman, Johannes Weiner,
	linux-kernel, linux-mm

On Fri, 3 Mar 2017, Anshuman Khandual wrote:

> > 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.
> 

Precisely.

> 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'.
> 

I like it, I'll send a v2.  Thanks.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [patch v2] mm, vmstat: print non-populated zones in zoneinfo
  2017-03-03 22:46     ` David Rientjes
@ 2017-03-03 22:53       ` David Rientjes
  -1 siblings, 0 replies; 22+ messages in thread
From: David Rientjes @ 2017-03-03 22:53 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Anshuman Khandual, Vlastimil Babka, Mel Gorman, Johannes Weiner,
	linux-kernel, linux-mm

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.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 v2: - s/bool populated/b assert_populated/ per Anshuman
     - add comment to zoneinfo_show() to describe why we care

 mm/vmstat.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 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 @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;
@@ -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 (assert_populated && !populated_zone(zone))
 			continue;
 
 		spin_lock_irqsave(&zone->lock, flags);
@@ -1158,7 +1162,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;
 }
 
@@ -1199,7 +1203,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;
 }
@@ -1251,7 +1255,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;
 }
@@ -1277,7 +1281,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 */
 }
 
@@ -1429,12 +1433,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;
 }
 
@@ -1853,7 +1860,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;
 }
@@ -1905,7 +1912,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;
 }

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [patch v2] mm, vmstat: print non-populated zones in zoneinfo
@ 2017-03-03 22:53       ` David Rientjes
  0 siblings, 0 replies; 22+ messages in thread
From: David Rientjes @ 2017-03-03 22:53 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Anshuman Khandual, Vlastimil Babka, Mel Gorman, Johannes Weiner,
	linux-kernel, linux-mm

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.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 v2: - s/bool populated/b assert_populated/ per Anshuman
     - add comment to zoneinfo_show() to describe why we care

 mm/vmstat.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 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 @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;
@@ -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 (assert_populated && !populated_zone(zone))
 			continue;
 
 		spin_lock_irqsave(&zone->lock, flags);
@@ -1158,7 +1162,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;
 }
 
@@ -1199,7 +1203,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;
 }
@@ -1251,7 +1255,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;
 }
@@ -1277,7 +1281,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 */
 }
 
@@ -1429,12 +1433,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;
 }
 
@@ -1853,7 +1860,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;
 }
@@ -1905,7 +1912,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;
 }

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [patch v2] mm, vmstat: print non-populated zones in zoneinfo
  2017-03-03 22:53       ` David Rientjes
@ 2017-03-04  8:21         ` Anshuman Khandual
  -1 siblings, 0 replies; 22+ messages in thread
From: Anshuman Khandual @ 2017-03-04  8:21 UTC (permalink / raw)
  To: David Rientjes, Andrew Morton
  Cc: Anshuman Khandual, Vlastimil Babka, Mel Gorman, Johannes Weiner,
	linux-kernel, linux-mm

On 03/04/2017 04:23 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.
> 
> 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@google.com>

Reviewed-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [patch v2] mm, vmstat: print non-populated zones in zoneinfo
@ 2017-03-04  8:21         ` Anshuman Khandual
  0 siblings, 0 replies; 22+ messages in thread
From: Anshuman Khandual @ 2017-03-04  8:21 UTC (permalink / raw)
  To: David Rientjes, Andrew Morton
  Cc: Anshuman Khandual, Vlastimil Babka, Mel Gorman, Johannes Weiner,
	linux-kernel, linux-mm

On 03/04/2017 04:23 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.
> 
> 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@google.com>

Reviewed-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [patch -mm] mm, vmstat: suppress pcp stats for unpopulated zones in zoneinfo
  2017-03-03 22:53       ` David Rientjes
@ 2017-03-06 22:03         ` David Rientjes
  -1 siblings, 0 replies; 22+ messages in thread
From: David Rientjes @ 2017-03-06 22:03 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Anshuman Khandual, Vlastimil Babka, Mel Gorman, Johannes Weiner,
	linux-kernel, linux-mm

After "mm, vmstat: print non-populated zones in zoneinfo", /proc/zoneinfo 
will show unpopulated zones.

The per-cpu pageset statistics are not relevant for unpopulated zones and 
can be potentially lengthy, so supress them when they are not interesting.

Also moves lowmem reserve protection information above pcp stats since it 
is relevant for all zones per vm.lowmem_reserve_ratio.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 mm/vmstat.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/mm/vmstat.c b/mm/vmstat.c
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1392,18 +1392,24 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat,
 		   zone->present_pages,
 		   zone->managed_pages);
 
-	for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
-		seq_printf(m, "\n      %-12s %lu", vmstat_text[i],
-				zone_page_state(zone, i));
-
 	seq_printf(m,
 		   "\n        protection: (%ld",
 		   zone->lowmem_reserve[0]);
 	for (i = 1; i < ARRAY_SIZE(zone->lowmem_reserve); i++)
 		seq_printf(m, ", %ld", zone->lowmem_reserve[i]);
-	seq_printf(m,
-		   ")"
-		   "\n  pagesets");
+	seq_putc(m, ')');
+
+	/* If unpopulated, no other information is useful */
+	if (!populated_zone(zone)) {
+		seq_putc(m, '\n');
+		return;
+	}
+
+	for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
+		seq_printf(m, "\n      %-12s %lu", vmstat_text[i],
+				zone_page_state(zone, i));
+
+	seq_printf(m, "\n  pagesets");
 	for_each_online_cpu(i) {
 		struct per_cpu_pageset *pageset;
 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [patch -mm] mm, vmstat: suppress pcp stats for unpopulated zones in zoneinfo
@ 2017-03-06 22:03         ` David Rientjes
  0 siblings, 0 replies; 22+ messages in thread
From: David Rientjes @ 2017-03-06 22:03 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Anshuman Khandual, Vlastimil Babka, Mel Gorman, Johannes Weiner,
	linux-kernel, linux-mm

After "mm, vmstat: print non-populated zones in zoneinfo", /proc/zoneinfo 
will show unpopulated zones.

The per-cpu pageset statistics are not relevant for unpopulated zones and 
can be potentially lengthy, so supress them when they are not interesting.

Also moves lowmem reserve protection information above pcp stats since it 
is relevant for all zones per vm.lowmem_reserve_ratio.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 mm/vmstat.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/mm/vmstat.c b/mm/vmstat.c
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1392,18 +1392,24 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat,
 		   zone->present_pages,
 		   zone->managed_pages);
 
-	for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
-		seq_printf(m, "\n      %-12s %lu", vmstat_text[i],
-				zone_page_state(zone, i));
-
 	seq_printf(m,
 		   "\n        protection: (%ld",
 		   zone->lowmem_reserve[0]);
 	for (i = 1; i < ARRAY_SIZE(zone->lowmem_reserve); i++)
 		seq_printf(m, ", %ld", zone->lowmem_reserve[i]);
-	seq_printf(m,
-		   ")"
-		   "\n  pagesets");
+	seq_putc(m, ')');
+
+	/* If unpopulated, no other information is useful */
+	if (!populated_zone(zone)) {
+		seq_putc(m, '\n');
+		return;
+	}
+
+	for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
+		seq_printf(m, "\n      %-12s %lu", vmstat_text[i],
+				zone_page_state(zone, i));
+
+	seq_printf(m, "\n  pagesets");
 	for_each_online_cpu(i) {
 		struct per_cpu_pageset *pageset;
 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [patch -mm] mm, vmstat: suppress pcp stats for unpopulated zones in zoneinfo
  2017-03-06 22:03         ` David Rientjes
@ 2017-03-06 22:11           ` Andrew Morton
  -1 siblings, 0 replies; 22+ messages in thread
From: Andrew Morton @ 2017-03-06 22:11 UTC (permalink / raw)
  To: David Rientjes
  Cc: Anshuman Khandual, Vlastimil Babka, Mel Gorman, Johannes Weiner,
	linux-kernel, linux-mm

On Mon, 6 Mar 2017 14:03:32 -0800 (PST) David Rientjes <rientjes@google.com> wrote:

> After "mm, vmstat: print non-populated zones in zoneinfo", /proc/zoneinfo 
> will show unpopulated zones.
> 
> The per-cpu pageset statistics are not relevant for unpopulated zones and 
> can be potentially lengthy, so supress them when they are not interesting.
> 
> Also moves lowmem reserve protection information above pcp stats since it 
> is relevant for all zones per vm.lowmem_reserve_ratio.

Well it's not strictly back-compatible, but /proc/zoneinfo is such a
mess that parsers will be few and hopefully smart enough to handle
this.

btw,

  pagesets
    cpu: 0
              count: 118
              high:  186
              batch: 31
  vm stats threshold: 72
    cpu: 1
              count: 53
              high:  186
              batch: 31
  vm stats threshold: 72

Should the "vm stats threshold" thing be indented further?

Do we need to print it out N times anyway?  Can different CPUs have
different values?

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [patch -mm] mm, vmstat: suppress pcp stats for unpopulated zones in zoneinfo
@ 2017-03-06 22:11           ` Andrew Morton
  0 siblings, 0 replies; 22+ messages in thread
From: Andrew Morton @ 2017-03-06 22:11 UTC (permalink / raw)
  To: David Rientjes
  Cc: Anshuman Khandual, Vlastimil Babka, Mel Gorman, Johannes Weiner,
	linux-kernel, linux-mm

On Mon, 6 Mar 2017 14:03:32 -0800 (PST) David Rientjes <rientjes@google.com> wrote:

> After "mm, vmstat: print non-populated zones in zoneinfo", /proc/zoneinfo 
> will show unpopulated zones.
> 
> The per-cpu pageset statistics are not relevant for unpopulated zones and 
> can be potentially lengthy, so supress them when they are not interesting.
> 
> Also moves lowmem reserve protection information above pcp stats since it 
> is relevant for all zones per vm.lowmem_reserve_ratio.

Well it's not strictly back-compatible, but /proc/zoneinfo is such a
mess that parsers will be few and hopefully smart enough to handle
this.

btw,

  pagesets
    cpu: 0
              count: 118
              high:  186
              batch: 31
  vm stats threshold: 72
    cpu: 1
              count: 53
              high:  186
              batch: 31
  vm stats threshold: 72

Should the "vm stats threshold" thing be indented further?

Do we need to print it out N times anyway?  Can different CPUs have
different values?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [patch v2] mm, vmstat: print non-populated zones in zoneinfo
  2017-03-03 22:53       ` David Rientjes
@ 2017-03-08 14:42         ` Michal Hocko
  -1 siblings, 0 replies; 22+ messages in thread
From: Michal Hocko @ 2017-03-08 14:42 UTC (permalink / raw)
  To: David Rientjes
  Cc: Andrew Morton, Anshuman Khandual, Vlastimil Babka, Mel Gorman,
	Johannes Weiner, linux-kernel, linux-mm

On Fri 03-03-17 14:53:07, 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.
> 
> 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.

Does it really make sense to print any counters of that zone though?
Your follow up patch just suggests that we don't want some but what
about others?

I can see how skipping empty zones completely can be clumsy but wouldn't
it be sufficient to just provide

Node $NUM, zone $NAME
(unpopulated)

instead?

> 
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
>  v2: - s/bool populated/b assert_populated/ per Anshuman
>      - add comment to zoneinfo_show() to describe why we care
> 
>  mm/vmstat.c | 27 +++++++++++++++++----------
>  1 file changed, 17 insertions(+), 10 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 @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;
> @@ -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 (assert_populated && !populated_zone(zone))
>  			continue;
>  
>  		spin_lock_irqsave(&zone->lock, flags);
> @@ -1158,7 +1162,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;
>  }
>  
> @@ -1199,7 +1203,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;
>  }
> @@ -1251,7 +1255,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;
>  }
> @@ -1277,7 +1281,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 */
>  }
>  
> @@ -1429,12 +1433,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;
>  }
>  
> @@ -1853,7 +1860,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;
>  }
> @@ -1905,7 +1912,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;
>  }
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [patch v2] mm, vmstat: print non-populated zones in zoneinfo
@ 2017-03-08 14:42         ` Michal Hocko
  0 siblings, 0 replies; 22+ messages in thread
From: Michal Hocko @ 2017-03-08 14:42 UTC (permalink / raw)
  To: David Rientjes
  Cc: Andrew Morton, Anshuman Khandual, Vlastimil Babka, Mel Gorman,
	Johannes Weiner, linux-kernel, linux-mm

On Fri 03-03-17 14:53:07, 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.
> 
> 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.

Does it really make sense to print any counters of that zone though?
Your follow up patch just suggests that we don't want some but what
about others?

I can see how skipping empty zones completely can be clumsy but wouldn't
it be sufficient to just provide

Node $NUM, zone $NAME
(unpopulated)

instead?

> 
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
>  v2: - s/bool populated/b assert_populated/ per Anshuman
>      - add comment to zoneinfo_show() to describe why we care
> 
>  mm/vmstat.c | 27 +++++++++++++++++----------
>  1 file changed, 17 insertions(+), 10 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 @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;
> @@ -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 (assert_populated && !populated_zone(zone))
>  			continue;
>  
>  		spin_lock_irqsave(&zone->lock, flags);
> @@ -1158,7 +1162,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;
>  }
>  
> @@ -1199,7 +1203,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;
>  }
> @@ -1251,7 +1255,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;
>  }
> @@ -1277,7 +1281,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 */
>  }
>  
> @@ -1429,12 +1433,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;
>  }
>  
> @@ -1853,7 +1860,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;
>  }
> @@ -1905,7 +1912,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;
>  }
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [patch v2] mm, vmstat: print non-populated zones in zoneinfo
  2017-03-08 14:42         ` Michal Hocko
@ 2017-03-17  8:57           ` Michal Hocko
  -1 siblings, 0 replies; 22+ messages in thread
From: Michal Hocko @ 2017-03-17  8:57 UTC (permalink / raw)
  To: David Rientjes
  Cc: Andrew Morton, Anshuman Khandual, Vlastimil Babka, Mel Gorman,
	Johannes Weiner, linux-kernel, linux-mm

On Wed 08-03-17 15:41:59, Michal Hocko wrote:
> On Fri 03-03-17 14:53:07, 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.
> > 
> > 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.
> 
> Does it really make sense to print any counters of that zone though?
> Your follow up patch just suggests that we don't want some but what
> about others?
> 
> I can see how skipping empty zones completely can be clumsy but wouldn't
> it be sufficient to just provide
> 
> Node $NUM, zone $NAME
> (unpopulated)
> 
> instead?

ping
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [patch v2] mm, vmstat: print non-populated zones in zoneinfo
@ 2017-03-17  8:57           ` Michal Hocko
  0 siblings, 0 replies; 22+ messages in thread
From: Michal Hocko @ 2017-03-17  8:57 UTC (permalink / raw)
  To: David Rientjes
  Cc: Andrew Morton, Anshuman Khandual, Vlastimil Babka, Mel Gorman,
	Johannes Weiner, linux-kernel, linux-mm

On Wed 08-03-17 15:41:59, Michal Hocko wrote:
> On Fri 03-03-17 14:53:07, 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.
> > 
> > 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.
> 
> Does it really make sense to print any counters of that zone though?
> Your follow up patch just suggests that we don't want some but what
> about others?
> 
> I can see how skipping empty zones completely can be clumsy but wouldn't
> it be sufficient to just provide
> 
> Node $NUM, zone $NAME
> (unpopulated)
> 
> instead?

ping
-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [patch v2] mm, vmstat: print non-populated zones in zoneinfo
  2017-03-17  8:57           ` Michal Hocko
@ 2017-03-17 21:21             ` David Rientjes
  -1 siblings, 0 replies; 22+ messages in thread
From: David Rientjes @ 2017-03-17 21:21 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Andrew Morton, Anshuman Khandual, Vlastimil Babka, Mel Gorman,
	Johannes Weiner, linux-kernel, linux-mm

On Fri, 17 Mar 2017, Michal Hocko wrote:

> > Does it really make sense to print any counters of that zone though?
> > Your follow up patch just suggests that we don't want some but what
> > about others?
> > 

Managed and present pages needs to be emitted for userspace parsing of 
memory hotplug, I chose not to suppress the five or six other members 
since the risk of breaking existing parsers far outweighs any savings from 
not emitting these lines.  There is already plenty of opportunities to 
clean /proc/zoneinfo up as described by Andrew that may be possible but 
care needs to taken to ensure we don't break existing readers.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [patch v2] mm, vmstat: print non-populated zones in zoneinfo
@ 2017-03-17 21:21             ` David Rientjes
  0 siblings, 0 replies; 22+ messages in thread
From: David Rientjes @ 2017-03-17 21:21 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Andrew Morton, Anshuman Khandual, Vlastimil Babka, Mel Gorman,
	Johannes Weiner, linux-kernel, linux-mm

On Fri, 17 Mar 2017, Michal Hocko wrote:

> > Does it really make sense to print any counters of that zone though?
> > Your follow up patch just suggests that we don't want some but what
> > about others?
> > 

Managed and present pages needs to be emitted for userspace parsing of 
memory hotplug, I chose not to suppress the five or six other members 
since the risk of breaking existing parsers far outweighs any savings from 
not emitting these lines.  There is already plenty of opportunities to 
clean /proc/zoneinfo up as described by Andrew that may be possible but 
care needs to taken to ensure we don't break existing readers.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH] mm, vmstat: Remove spurious WARN() during zoneinfo print
  2017-03-03 22:53       ` David Rientjes
@ 2017-05-03 23:41         ` Reza Arbab
  -1 siblings, 0 replies; 22+ messages in thread
From: Reza Arbab @ 2017-05-03 23:41 UTC (permalink / raw)
  To: Andrew Morton
  Cc: David Rientjes, Anshuman Khandual, Vlastimil Babka, Mel Gorman,
	Johannes Weiner, linux-kernel, linux-mm

After "mm, vmstat: print non-populated zones in zoneinfo",
/proc/zoneinfo will show unpopulated zones.

A memoryless node, having no populated zones at all, was previously
ignored, but will now trigger the WARN() in is_zone_first_populated().

Remove this warning, as its only purpose was to warn of a situation that
has since been enabled.

Signed-off-by: Reza Arbab <arbab@linux.vnet.ibm.com>
---

Aside: The "per-node stats" are still printed under the first populated
zone, but that's not necessarily the first stanza any more. I'm not sure
which criteria is more important with regard to not breaking parsers, but 
it looks a little weird to the eye.

 mm/vmstat.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/mm/vmstat.c b/mm/vmstat.c
index f5fa1bd..76f7367 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1359,8 +1359,6 @@ static bool is_zone_first_populated(pg_data_t *pgdat, struct zone *zone)
 			return zone == compare;
 	}
 
-	/* The zone must be somewhere! */
-	WARN_ON_ONCE(1);
 	return false;
 }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH] mm, vmstat: Remove spurious WARN() during zoneinfo print
@ 2017-05-03 23:41         ` Reza Arbab
  0 siblings, 0 replies; 22+ messages in thread
From: Reza Arbab @ 2017-05-03 23:41 UTC (permalink / raw)
  To: Andrew Morton
  Cc: David Rientjes, Anshuman Khandual, Vlastimil Babka, Mel Gorman,
	Johannes Weiner, linux-kernel, linux-mm

After "mm, vmstat: print non-populated zones in zoneinfo",
/proc/zoneinfo will show unpopulated zones.

A memoryless node, having no populated zones at all, was previously
ignored, but will now trigger the WARN() in is_zone_first_populated().

Remove this warning, as its only purpose was to warn of a situation that
has since been enabled.

Signed-off-by: Reza Arbab <arbab@linux.vnet.ibm.com>
---

Aside: The "per-node stats" are still printed under the first populated
zone, but that's not necessarily the first stanza any more. I'm not sure
which criteria is more important with regard to not breaking parsers, but 
it looks a little weird to the eye.

 mm/vmstat.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/mm/vmstat.c b/mm/vmstat.c
index f5fa1bd..76f7367 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1359,8 +1359,6 @@ static bool is_zone_first_populated(pg_data_t *pgdat, struct zone *zone)
 			return zone == compare;
 	}
 
-	/* The zone must be somewhere! */
-	WARN_ON_ONCE(1);
 	return false;
 }
 
-- 
1.8.3.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2017-05-03 23:41 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-02 23:26 [patch] mm, zoneinfo: print non-populated zones David Rientjes
2017-03-02 23:26 ` David Rientjes
2017-03-03 13:35 ` Anshuman Khandual
2017-03-03 13:35   ` Anshuman Khandual
2017-03-03 22:46   ` David Rientjes
2017-03-03 22:46     ` David Rientjes
2017-03-03 22:53     ` [patch v2] mm, vmstat: print non-populated zones in zoneinfo David Rientjes
2017-03-03 22:53       ` David Rientjes
2017-03-04  8:21       ` Anshuman Khandual
2017-03-04  8:21         ` Anshuman Khandual
2017-03-06 22:03       ` [patch -mm] mm, vmstat: suppress pcp stats for unpopulated " David Rientjes
2017-03-06 22:03         ` David Rientjes
2017-03-06 22:11         ` Andrew Morton
2017-03-06 22:11           ` Andrew Morton
2017-03-08 14:42       ` [patch v2] mm, vmstat: print non-populated " Michal Hocko
2017-03-08 14:42         ` Michal Hocko
2017-03-17  8:57         ` Michal Hocko
2017-03-17  8:57           ` Michal Hocko
2017-03-17 21:21           ` David Rientjes
2017-03-17 21:21             ` David Rientjes
2017-05-03 23:41       ` [PATCH] mm, vmstat: Remove spurious WARN() during zoneinfo print Reza Arbab
2017-05-03 23:41         ` Reza Arbab

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.