All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/page_alloc: fix counting of managed_pages
@ 2021-05-27 12:57 Liu Shixin
  2021-05-27 13:14 ` Liu Shixin
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Liu Shixin @ 2021-05-27 12:57 UTC (permalink / raw)
  To: Andrew Morton, yangerkun, Kefeng Wang; +Cc: linux-mm, linux-kernel, Liu Shixin

The commit f63661566fad (mm/page_alloc.c: clear out zone->lowmem_reserve[]
if the zone is empty) clear out zone->lowmem_reserve[] if zone is empty.
But when zone is not empty and sysctl_lowmem_reserve_ratio[i] is set to zero,
zone_managed_pages(zone) is not counted in the managed_pages either. This is
inconsistent with the description of lowmen_reserve, so fix it.

Fixes: f63661566fad ("mm/page_alloc.c: clear out zone->lowmem_reserve[] if the zone is empty")
Reported-by: yangerkun <yangerkun@huawei.com>
Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 mm/page_alloc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index aaa1655cf682..49a2efce5a84 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -8061,14 +8061,14 @@ static void setup_per_zone_lowmem_reserve(void)
 			unsigned long managed_pages = 0;
 
 			for (j = i + 1; j < MAX_NR_ZONES; j++) {
-				if (clear) {
-					zone->lowmem_reserve[j] = 0;
-				} else {
-					struct zone *upper_zone = &pgdat->node_zones[j];
+				struct zone *upper_zone = &pgdat->node_zones[j];
+
+				managed_pages += zone_managed_pages(upper_zone);
 
-					managed_pages += zone_managed_pages(upper_zone);
+				if (clear)
+					zone->lowmem_reserve[j] = 0;
+				else
 					zone->lowmem_reserve[j] = managed_pages / ratio;
-				}
 			}
 		}
 	}
-- 
2.18.0.huawei.25


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

* Re: [PATCH] mm/page_alloc: fix counting of managed_pages
  2021-05-27 12:57 [PATCH] mm/page_alloc: fix counting of managed_pages Liu Shixin
@ 2021-05-27 13:14 ` Liu Shixin
  2021-05-27 23:47 ` Baoquan He
  2021-06-09 10:29 ` David Hildenbrand
  2 siblings, 0 replies; 5+ messages in thread
From: Liu Shixin @ 2021-05-27 13:14 UTC (permalink / raw)
  To: Andrew Morton, yangerkun, Kefeng Wang, Baoquan He; +Cc: linux-mm, linux-kernel

+ Baoquan


On 2021/5/27 20:57, Liu Shixin wrote:
> The commit f63661566fad (mm/page_alloc.c: clear out zone->lowmem_reserve[]
> if the zone is empty) clear out zone->lowmem_reserve[] if zone is empty.
> But when zone is not empty and sysctl_lowmem_reserve_ratio[i] is set to zero,
> zone_managed_pages(zone) is not counted in the managed_pages either. This is
> inconsistent with the description of lowmen_reserve, so fix it.
>
> Fixes: f63661566fad ("mm/page_alloc.c: clear out zone->lowmem_reserve[] if the zone is empty")
> Reported-by: yangerkun <yangerkun@huawei.com>
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
> ---
>  mm/page_alloc.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index aaa1655cf682..49a2efce5a84 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -8061,14 +8061,14 @@ static void setup_per_zone_lowmem_reserve(void)
>  			unsigned long managed_pages = 0;
>  
>  			for (j = i + 1; j < MAX_NR_ZONES; j++) {
> -				if (clear) {
> -					zone->lowmem_reserve[j] = 0;
> -				} else {
> -					struct zone *upper_zone = &pgdat->node_zones[j];
> +				struct zone *upper_zone = &pgdat->node_zones[j];
> +
> +				managed_pages += zone_managed_pages(upper_zone);
>  
> -					managed_pages += zone_managed_pages(upper_zone);
> +				if (clear)
> +					zone->lowmem_reserve[j] = 0;
> +				else
>  					zone->lowmem_reserve[j] = managed_pages / ratio;
> -				}
>  			}
>  		}
>  	}


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

* Re: [PATCH] mm/page_alloc: fix counting of managed_pages
  2021-05-27 12:57 [PATCH] mm/page_alloc: fix counting of managed_pages Liu Shixin
  2021-05-27 13:14 ` Liu Shixin
@ 2021-05-27 23:47 ` Baoquan He
  2021-05-28  2:20   ` Liu Shixin
  2021-06-09 10:29 ` David Hildenbrand
  2 siblings, 1 reply; 5+ messages in thread
From: Baoquan He @ 2021-05-27 23:47 UTC (permalink / raw)
  To: Liu Shixin; +Cc: Andrew Morton, yangerkun, Kefeng Wang, linux-mm, linux-kernel

On 05/27/21 at 08:57pm, Liu Shixin wrote:
> The commit f63661566fad (mm/page_alloc.c: clear out zone->lowmem_reserve[]
> if the zone is empty) clear out zone->lowmem_reserve[] if zone is empty.
> But when zone is not empty and sysctl_lowmem_reserve_ratio[i] is set to zero,
> zone_managed_pages(zone) is not counted in the managed_pages either. This is
> inconsistent with the description of lowmen_reserve, so fix it.

Right, this is a good catch. Thanks for the fixing. 

Is it worth adding words in Documentation/admin-guide/sysctl/vm.rst
to notice this?

Reviewed-by: Baoquan He <bhe@redhat.com>

Thanks
Baoquan

> 
> Fixes: f63661566fad ("mm/page_alloc.c: clear out zone->lowmem_reserve[] if the zone is empty")
> Reported-by: yangerkun <yangerkun@huawei.com>
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
> ---
>  mm/page_alloc.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index aaa1655cf682..49a2efce5a84 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -8061,14 +8061,14 @@ static void setup_per_zone_lowmem_reserve(void)
>  			unsigned long managed_pages = 0;
>  
>  			for (j = i + 1; j < MAX_NR_ZONES; j++) {
> -				if (clear) {
> -					zone->lowmem_reserve[j] = 0;
> -				} else {
> -					struct zone *upper_zone = &pgdat->node_zones[j];
> +				struct zone *upper_zone = &pgdat->node_zones[j];
> +
> +				managed_pages += zone_managed_pages(upper_zone);
>  
> -					managed_pages += zone_managed_pages(upper_zone);
> +				if (clear)
> +					zone->lowmem_reserve[j] = 0;
> +				else
>  					zone->lowmem_reserve[j] = managed_pages / ratio;
> -				}
>  			}
>  		}
>  	}
> -- 
> 2.18.0.huawei.25
> 
> 


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

* Re: [PATCH] mm/page_alloc: fix counting of managed_pages
  2021-05-27 23:47 ` Baoquan He
@ 2021-05-28  2:20   ` Liu Shixin
  0 siblings, 0 replies; 5+ messages in thread
From: Liu Shixin @ 2021-05-28  2:20 UTC (permalink / raw)
  To: Baoquan He; +Cc: Andrew Morton, yangerkun, Kefeng Wang, linux-mm, linux-kernel


On 2021/5/28 7:47, Baoquan He wrote:
> On 05/27/21 at 08:57pm, Liu Shixin wrote:
>> The commit f63661566fad (mm/page_alloc.c: clear out zone->lowmem_reserve[]
>> if the zone is empty) clear out zone->lowmem_reserve[] if zone is empty.
>> But when zone is not empty and sysctl_lowmem_reserve_ratio[i] is set to zero,
>> zone_managed_pages(zone) is not counted in the managed_pages either. This is
>> inconsistent with the description of lowmen_reserve, so fix it.
> Right, this is a good catch. Thanks for the fixing. 
>
> Is it worth adding words in Documentation/admin-guide/sysctl/vm.rst
> to notice this?
>
> Reviewed-by: Baoquan He <bhe@redhat.com>
>
> Thanks
> Baoquan

With this patch, It's consistent with the calculation description of zone[i]'s protection[j].

This is implicit in the description so I don't think it's necessary to notice this.

>> Fixes: f63661566fad ("mm/page_alloc.c: clear out zone->lowmem_reserve[] if the zone is empty")
>> Reported-by: yangerkun <yangerkun@huawei.com>
>> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
>> ---
>>  mm/page_alloc.c | 12 ++++++------
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index aaa1655cf682..49a2efce5a84 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -8061,14 +8061,14 @@ static void setup_per_zone_lowmem_reserve(void)
>>  			unsigned long managed_pages = 0;
>>  
>>  			for (j = i + 1; j < MAX_NR_ZONES; j++) {
>> -				if (clear) {
>> -					zone->lowmem_reserve[j] = 0;
>> -				} else {
>> -					struct zone *upper_zone = &pgdat->node_zones[j];
>> +				struct zone *upper_zone = &pgdat->node_zones[j];
>> +
>> +				managed_pages += zone_managed_pages(upper_zone);
>>  
>> -					managed_pages += zone_managed_pages(upper_zone);
>> +				if (clear)
>> +					zone->lowmem_reserve[j] = 0;
>> +				else
>>  					zone->lowmem_reserve[j] = managed_pages / ratio;
>> -				}
>>  			}
>>  		}
>>  	}
>> -- 
>> 2.18.0.huawei.25
>>
>>
> .
>


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

* Re: [PATCH] mm/page_alloc: fix counting of managed_pages
  2021-05-27 12:57 [PATCH] mm/page_alloc: fix counting of managed_pages Liu Shixin
  2021-05-27 13:14 ` Liu Shixin
  2021-05-27 23:47 ` Baoquan He
@ 2021-06-09 10:29 ` David Hildenbrand
  2 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2021-06-09 10:29 UTC (permalink / raw)
  To: Liu Shixin, Andrew Morton, yangerkun, Kefeng Wang; +Cc: linux-mm, linux-kernel

On 27.05.21 14:57, Liu Shixin wrote:
> The commit f63661566fad (mm/page_alloc.c: clear out zone->lowmem_reserve[]
> if the zone is empty) clear out zone->lowmem_reserve[] if zone is empty.
> But when zone is not empty and sysctl_lowmem_reserve_ratio[i] is set to zero,
> zone_managed_pages(zone) is not counted in the managed_pages either. This is
> inconsistent with the description of lowmen_reserve, so fix it.
> 
> Fixes: f63661566fad ("mm/page_alloc.c: clear out zone->lowmem_reserve[] if the zone is empty")
> Reported-by: yangerkun <yangerkun@huawei.com>
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
> ---
>   mm/page_alloc.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index aaa1655cf682..49a2efce5a84 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -8061,14 +8061,14 @@ static void setup_per_zone_lowmem_reserve(void)
>   			unsigned long managed_pages = 0;
>   
>   			for (j = i + 1; j < MAX_NR_ZONES; j++) {
> -				if (clear) {
> -					zone->lowmem_reserve[j] = 0;
> -				} else {
> -					struct zone *upper_zone = &pgdat->node_zones[j];
> +				struct zone *upper_zone = &pgdat->node_zones[j];
> +
> +				managed_pages += zone_managed_pages(upper_zone);
>   
> -					managed_pages += zone_managed_pages(upper_zone);
> +				if (clear)
> +					zone->lowmem_reserve[j] = 0;
> +				else
>   					zone->lowmem_reserve[j] = managed_pages / ratio;
> -				}
>   			}
>   		}
>   	}
> 

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

-- 
Thanks,

David / dhildenb


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

end of thread, other threads:[~2021-06-09 10:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27 12:57 [PATCH] mm/page_alloc: fix counting of managed_pages Liu Shixin
2021-05-27 13:14 ` Liu Shixin
2021-05-27 23:47 ` Baoquan He
2021-05-28  2:20   ` Liu Shixin
2021-06-09 10:29 ` David Hildenbrand

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.