Skip to contentSkip to conversation

Cleanup for vmstat

PATCH Applied Miaohe Lin 2 participants 7 messages Jul 15, 2021 – Jul 17, 2021

Subsystems (2)
lore
Share & tools
lore

Miaohe Lin

author
#0 lore raw

cover Cleanup for vmstat

Hi all,
This series contains cleanups to remove unneeded return value, correct wrong comment and simplify the array size calculation. More details can be found in the respective changelogs. Thanks!

Miaohe Lin (3):
mm/vmstat: correct some wrong comments
mm/vmstat: simplify the array size calculation
mm/vmstat: remove unneeded return value

 mm/vmstat.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)
Signature · 1 line
2.23.0
author
#1 lore raw

PATCH 1/3 mm/vmstat: correct some wrong comments

Correct wrong fls(mem+1) to fls(mem)+1 and remove the duplicated comment with quiet_vmstat().

---
 mm/vmstat.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
mm/vmstat.c +1 -6
index b0534e068166..57e8e7fda7aa 100644
@@ -204,7 +204,7 @@ int calculate_normal_threshold(struct zone *zone)
 	 *
 	 * Some sample thresholds:
 	 *
-	 * Threshold	Processors	(fls)	Zonesize	fls(mem+1)
+	 * Threshold	Processors	(fls)	Zonesize	fls(mem)+1
 	 * ------------------------------------------------------------------
 	 * 8		1		1	0.9-1 GB	4
 	 * 16		2		2	0.9-1 GB	4
@@ -1873,11 +1873,6 @@ static void vmstat_update(struct work_struct *w)
 	}
 }
 
-/*
- * Switch off vmstat processing and then fold all the remaining differentials
- * until the diffs stay at zero. The function is used by NOHZ and can only be
- * invoked when tick processing is not active.
- */
 /*
  * Check if the diffs for a certain cpu indicate that
  * an update is needed.
Signature · 1 line
2.23.0
author
#2 lore raw

PATCH 2/3 mm/vmstat: simplify the array size calculation

In reply to Miaohe Lin

We can replace the array_num * sizeof(array[0]) with sizeof(array) to simplify the code.

---
 mm/vmstat.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
mm/vmstat.c +3 -5
index 57e8e7fda7aa..76aef9510f6d 100644
@@ -1889,17 +1889,15 @@ static bool need_update(int cpu)
 		/*
 		 * The fast way of checking if there are any vmstat diffs.
 		 */
-		if (memchr_inv(pzstats->vm_stat_diff, 0, NR_VM_ZONE_STAT_ITEMS *
-			       sizeof(pzstats->vm_stat_diff[0])))
+		if (memchr_inv(pzstats->vm_stat_diff, 0, sizeof(pzstats->vm_stat_diff)))
 			return true;
 
 		if (last_pgdat == zone->zone_pgdat)
 			continue;
 		last_pgdat = zone->zone_pgdat;
 		n = per_cpu_ptr(zone->zone_pgdat->per_cpu_nodestats, cpu);
-		if (memchr_inv(n->vm_node_stat_diff, 0, NR_VM_NODE_STAT_ITEMS *
-			       sizeof(n->vm_node_stat_diff[0])))
-		    return true;
+		if (memchr_inv(n->vm_node_stat_diff, 0, sizeof(n->vm_node_stat_diff)))
+			return true;
 	}
 	return false;
 }
Signature · 1 line
2.23.0
Reviewed-by on v1 2/3
#3 lore raw

Re: [PATCH 2/3] mm/vmstat: simplify the array size calculation

Quoted 2 lines · Miaohe Lin

We can replace the array_num * sizeof(array[0]) with sizeof(array) to simplify the code.

Could have mentioned taht your fixing indentation of one "return true;"

LGTM

Quoted 32 lines
---
  mm/vmstat.c | 8 +++-----
  1 file changed, 3 insertions(+), 5 deletions(-)
mm/vmstat.c +3 -5
index 57e8e7fda7aa..76aef9510f6d 100644
@@ -1889,17 +1889,15 @@ static bool need_update(int cpu)
  		/*
  		 * The fast way of checking if there are any vmstat diffs.
  		 */
-		if (memchr_inv(pzstats->vm_stat_diff, 0, NR_VM_ZONE_STAT_ITEMS *
-			       sizeof(pzstats->vm_stat_diff[0])))
+		if (memchr_inv(pzstats->vm_stat_diff, 0, sizeof(pzstats->vm_stat_diff)))
  			return true;
 
  		if (last_pgdat == zone->zone_pgdat)
  			continue;
  		last_pgdat = zone->zone_pgdat;
  		n = per_cpu_ptr(zone->zone_pgdat->per_cpu_nodestats, cpu);
-		if (memchr_inv(n->vm_node_stat_diff, 0, NR_VM_NODE_STAT_ITEMS *
-			       sizeof(n->vm_node_stat_diff[0])))
-		    return true;
+		if (memchr_inv(n->vm_node_stat_diff, 0, sizeof(n->vm_node_stat_diff)))
+			return true;
  	}
  	return false;
  }
Signature · 3 lines
Thanks,

David / dhildenb
author
#4 lore raw

Re: [PATCH 2/3] mm/vmstat: simplify the array size calculation

Quoted 6 lines · David Hildenbrand
Quoted 2 lines · Miaohe Lin

We can replace the array_num * sizeof(array[0]) with sizeof(array) to simplify the code.

Could have mentioned taht your fixing indentation of one "return true;"

Yes, but I thought that's too trivial to mention... I would pay attention to it later.

Quoted 3 lines

LGTM

Many thanks for your review and reply!

Quoted 34 lines
Quoted 32 lines

---
  mm/vmstat.c | 8 +++-----

  1 file changed, 3 insertions(+), 5 deletions(-)
mm/vmstat.c +3 -5
index 57e8e7fda7aa..76aef9510f6d 100644
@@ -1889,17 +1889,15 @@ static bool need_update(int cpu)
           /*
            * The fast way of checking if there are any vmstat diffs.
            */
-        if (memchr_inv(pzstats->vm_stat_diff, 0, NR_VM_ZONE_STAT_ITEMS *
-                   sizeof(pzstats->vm_stat_diff[0])))
+        if (memchr_inv(pzstats->vm_stat_diff, 0, sizeof(pzstats->vm_stat_diff)))
               return true;
             if (last_pgdat == zone->zone_pgdat)
               continue;
           last_pgdat = zone->zone_pgdat;
           n = per_cpu_ptr(zone->zone_pgdat->per_cpu_nodestats, cpu);
-        if (memchr_inv(n->vm_node_stat_diff, 0, NR_VM_NODE_STAT_ITEMS *
-                   sizeof(n->vm_node_stat_diff[0])))
-            return true;
+        if (memchr_inv(n->vm_node_stat_diff, 0, sizeof(n->vm_node_stat_diff)))
+            return true;
       }
       return false;
   }
 
author
#5 lore raw

PATCH 3/3 mm/vmstat: remove unneeded return value

In reply to Miaohe Lin

The return value of pagetypeinfo_showfree and pagetypeinfo_showblockcount are unused now. Remove them.

---
 mm/vmstat.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
mm/vmstat.c +2 -6
index 76aef9510f6d..6246bab9fae2 100644
@@ -1452,7 +1452,7 @@ static void pagetypeinfo_showfree_print(struct seq_file *m,
 }
 
 /* Print out the free pages at each order for each migatetype */
-static int pagetypeinfo_showfree(struct seq_file *m, void *arg)
+static void pagetypeinfo_showfree(struct seq_file *m, void *arg)
 {
 	int order;
 	pg_data_t *pgdat = (pg_data_t *)arg;
@@ -1464,8 +1464,6 @@ static int pagetypeinfo_showfree(struct seq_file *m, void *arg)
 	seq_putc(m, '\n');
 
 	walk_zones_in_node(m, pgdat, true, false, pagetypeinfo_showfree_print);
-
-	return 0;
 }
 
 static void pagetypeinfo_showblockcount_print(struct seq_file *m,
@@ -1501,7 +1499,7 @@ static void pagetypeinfo_showblockcount_print(struct seq_file *m,
 }
 
 /* Print out the number of pageblocks for each migratetype */
-static int pagetypeinfo_showblockcount(struct seq_file *m, void *arg)
+static void pagetypeinfo_showblockcount(struct seq_file *m, void *arg)
 {
 	int mtype;
 	pg_data_t *pgdat = (pg_data_t *)arg;
@@ -1512,8 +1510,6 @@ static int pagetypeinfo_showblockcount(struct seq_file *m, void *arg)
 	seq_putc(m, '\n');
 	walk_zones_in_node(m, pgdat, true, false,
 		pagetypeinfo_showblockcount_print);
-
-	return 0;
 }
 
 /*
Signature · 1 line
2.23.0
Reviewed-by on v1 3/3
#6 lore raw

Re: [PATCH 3/3] mm/vmstat: remove unneeded return value

Quoted 41 lines · Miaohe Lin

The return value of pagetypeinfo_showfree and pagetypeinfo_showblockcount are unused now. Remove them.

---
  mm/vmstat.c | 8 ++------
  1 file changed, 2 insertions(+), 6 deletions(-)
mm/vmstat.c +2 -4
index 76aef9510f6d..6246bab9fae2 100644
@@ -1452,7 +1452,7 @@ static void pagetypeinfo_showfree_print(struct seq_file *m,
  }
 
  /* Print out the free pages at each order for each migatetype */
-static int pagetypeinfo_showfree(struct seq_file *m, void *arg)
+static void pagetypeinfo_showfree(struct seq_file *m, void *arg)
  {
  	int order;
  	pg_data_t *pgdat = (pg_data_t *)arg;
@@ -1464,8 +1464,6 @@ static int pagetypeinfo_showfree(struct seq_file *m, void *arg)
  	seq_putc(m, '\n');
 
  	walk_zones_in_node(m, pgdat, true, false, pagetypeinfo_showfree_print);
-
-	return 0;
  }
 
  static void pagetypeinfo_showblockcount_print(struct seq_file *m,
@@ -1501,7 +1499,7 @@ static void pagetypeinfo_showblockcount_print(struct seq_file *m,
  }
 
  /* Print out the number of pageblocks for each migratetype */
-static int pagetypeinfo_showblockcount(struct seq_file *m, void *arg)
+static void pagetypeinfo_showblockcount(struct seq_file *m, void *arg)
  {
  	int mtype;
  	pg_data_t *pgdat = (pg_data_t *)arg;

mm/vmstat.c static int pagetypeinfo_showblockcount(struct seq_file *m, void *arg) · line 1515

Quoted 8 lines
mm/vmstat.c +0 -2
@@ -1512,8 +1510,6 @@ static int pagetypeinfo_showblockcount(struct seq_file *m, void *arg)
  	seq_putc(m, '\n');
  	walk_zones_in_node(m, pgdat, true, false,
  		pagetypeinfo_showblockcount_print);
-
-	return 0;
  }
 
  /*
Signature · 3 lines
Thanks,

David / dhildenb