linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Cleanup for vmstat
@ 2021-07-15 12:29 Miaohe Lin
  2021-07-15 12:29 ` [PATCH 1/3] mm/vmstat: correct some wrong comments Miaohe Lin
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Miaohe Lin @ 2021-07-15 12:29 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, linmiaohe

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

-- 
2.23.0


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

* [PATCH 1/3] mm/vmstat: correct some wrong comments
  2021-07-15 12:29 [PATCH 0/3] Cleanup for vmstat Miaohe Lin
@ 2021-07-15 12:29 ` Miaohe Lin
  2021-07-15 12:29 ` [PATCH 2/3] mm/vmstat: simplify the array size calculation Miaohe Lin
  2021-07-15 12:29 ` [PATCH 3/3] mm/vmstat: remove unneeded return value Miaohe Lin
  2 siblings, 0 replies; 7+ messages in thread
From: Miaohe Lin @ 2021-07-15 12:29 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, linmiaohe

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

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/vmstat.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/mm/vmstat.c b/mm/vmstat.c
index b0534e068166..57e8e7fda7aa 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -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.
-- 
2.23.0


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

* [PATCH 2/3] mm/vmstat: simplify the array size calculation
  2021-07-15 12:29 [PATCH 0/3] Cleanup for vmstat Miaohe Lin
  2021-07-15 12:29 ` [PATCH 1/3] mm/vmstat: correct some wrong comments Miaohe Lin
@ 2021-07-15 12:29 ` Miaohe Lin
  2021-07-16 12:58   ` David Hildenbrand
  2021-07-15 12:29 ` [PATCH 3/3] mm/vmstat: remove unneeded return value Miaohe Lin
  2 siblings, 1 reply; 7+ messages in thread
From: Miaohe Lin @ 2021-07-15 12:29 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, linmiaohe

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

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/vmstat.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/mm/vmstat.c b/mm/vmstat.c
index 57e8e7fda7aa..76aef9510f6d 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -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;
 }
-- 
2.23.0


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

* [PATCH 3/3] mm/vmstat: remove unneeded return value
  2021-07-15 12:29 [PATCH 0/3] Cleanup for vmstat Miaohe Lin
  2021-07-15 12:29 ` [PATCH 1/3] mm/vmstat: correct some wrong comments Miaohe Lin
  2021-07-15 12:29 ` [PATCH 2/3] mm/vmstat: simplify the array size calculation Miaohe Lin
@ 2021-07-15 12:29 ` Miaohe Lin
  2021-07-16 12:59   ` David Hildenbrand
  2 siblings, 1 reply; 7+ messages in thread
From: Miaohe Lin @ 2021-07-15 12:29 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, linmiaohe

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

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/vmstat.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/mm/vmstat.c b/mm/vmstat.c
index 76aef9510f6d..6246bab9fae2 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -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;
 }
 
 /*
-- 
2.23.0


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

* Re: [PATCH 2/3] mm/vmstat: simplify the array size calculation
  2021-07-15 12:29 ` [PATCH 2/3] mm/vmstat: simplify the array size calculation Miaohe Lin
@ 2021-07-16 12:58   ` David Hildenbrand
  2021-07-17  1:54     ` Miaohe Lin
  0 siblings, 1 reply; 7+ messages in thread
From: David Hildenbrand @ 2021-07-16 12:58 UTC (permalink / raw)
  To: Miaohe Lin, akpm; +Cc: linux-mm, linux-kernel

On 15.07.21 14:29, Miaohe Lin wrote:
> 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

Reviewed-by: David Hildenbrand <david@redhat.com>

> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>   mm/vmstat.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index 57e8e7fda7aa..76aef9510f6d 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -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;
>   }
> 


-- 
Thanks,

David / dhildenb


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

* Re: [PATCH 3/3] mm/vmstat: remove unneeded return value
  2021-07-15 12:29 ` [PATCH 3/3] mm/vmstat: remove unneeded return value Miaohe Lin
@ 2021-07-16 12:59   ` David Hildenbrand
  0 siblings, 0 replies; 7+ messages in thread
From: David Hildenbrand @ 2021-07-16 12:59 UTC (permalink / raw)
  To: Miaohe Lin, akpm; +Cc: linux-mm, linux-kernel

On 15.07.21 14:29, Miaohe Lin wrote:
> The return value of pagetypeinfo_showfree and pagetypeinfo_showblockcount
> are unused now. Remove them.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>   mm/vmstat.c | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index 76aef9510f6d..6246bab9fae2 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -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;
>   }
>   
>   /*
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb


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

* Re: [PATCH 2/3] mm/vmstat: simplify the array size calculation
  2021-07-16 12:58   ` David Hildenbrand
@ 2021-07-17  1:54     ` Miaohe Lin
  0 siblings, 0 replies; 7+ messages in thread
From: Miaohe Lin @ 2021-07-17  1:54 UTC (permalink / raw)
  To: David Hildenbrand; +Cc: linux-mm, linux-kernel, Andrew Morton

On 2021/7/16 20:58, David Hildenbrand wrote:
> On 15.07.21 14:29, Miaohe Lin wrote:
>> 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.

> LGTM
> 
> Reviewed-by: David Hildenbrand <david@redhat.com>

Many thanks for your review and reply!

> 
>>
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>>   mm/vmstat.c | 8 +++-----
>>   1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/mm/vmstat.c b/mm/vmstat.c
>> index 57e8e7fda7aa..76aef9510f6d 100644
>> --- a/mm/vmstat.c
>> +++ b/mm/vmstat.c
>> @@ -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;
>>   }
>>
> 
> 


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

end of thread, other threads:[~2021-07-17  1:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15 12:29 [PATCH 0/3] Cleanup for vmstat Miaohe Lin
2021-07-15 12:29 ` [PATCH 1/3] mm/vmstat: correct some wrong comments Miaohe Lin
2021-07-15 12:29 ` [PATCH 2/3] mm/vmstat: simplify the array size calculation Miaohe Lin
2021-07-16 12:58   ` David Hildenbrand
2021-07-17  1:54     ` Miaohe Lin
2021-07-15 12:29 ` [PATCH 3/3] mm/vmstat: remove unneeded return value Miaohe Lin
2021-07-16 12:59   ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).