linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: Michal Hocko <mhocko@kernel.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Wei Yang <richard.weiyang@gmail.com>,
	akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: use managed_zone() for more exact check in zone iteration
Date: Wed, 21 Nov 2018 03:05:04 +0000	[thread overview]
Message-ID: <20181121030504.ucclpgl62es7lnwf@master> (raw)
In-Reply-To: <20181116102405.GF14706@dhcp22.suse.cz>

On Fri, Nov 16, 2018 at 11:24:05AM +0100, Michal Hocko wrote:
>On Thu 15-11-18 07:50:40, Wei Yang wrote:
>[...]
>> @@ -1193,8 +1196,8 @@ static unsigned int count_free_highmem_pages(void)
>>  	struct zone *zone;
>>  	unsigned int cnt = 0;
>>  
>> -	for_each_populated_zone(zone)
>> -		if (is_highmem(zone))
>> +	for_each_zone(zone)
>> +		if (populated_zone(zone) && is_highmem(zone))
>>  			cnt += zone_page_state(zone, NR_FREE_PAGES);
>
>this should be for_each_managed_zone because we only care about highmem
>zones which have pages in the allocator (NR_FREE_PAGES).
>
>>  
>>  	return cnt;
>> @@ -1239,10 +1242,10 @@ static unsigned int count_highmem_pages(void)
>>  	struct zone *zone;
>>  	unsigned int n = 0;
>>  
>> -	for_each_populated_zone(zone) {
>> +	for_each_zone(zone) {
>>  		unsigned long pfn, max_zone_pfn;
>>  
>> -		if (!is_highmem(zone))
>> +		if (!populated_zone(zone) || !is_highmem(zone))
>>  			continue;
>>  
>>  		mark_free_pages(zone);
>
>I am not familiar with this code much but I strongly suspect that we do
>want for_each_managed_zone here because saveable_highmem_page skips over
>all reserved pages which rules out the bootmem. But this should be
>double checked with Rafael (Cc-ed).
>
>Rafael, does this loop care about pages which are not managed by the
>page allocator?
>

Hi, Rafael

Your opinion on this change and the following one is appreciated :-)

>> @@ -1305,8 +1308,8 @@ static unsigned int count_data_pages(void)
>>  	unsigned long pfn, max_zone_pfn;
>>  	unsigned int n = 0;
>>  
>> -	for_each_populated_zone(zone) {
>> -		if (is_highmem(zone))
>> +	for_each_zone(zone) {
>> +		if (!populated_zone(zone) || is_highmem(zone))
>>  			continue;
>>  
>>  		mark_free_pages(zone);
>> @@ -1399,9 +1402,12 @@ static void copy_data_pages(struct memory_bitmap *copy_bm,
>>  	struct zone *zone;
>>  	unsigned long pfn;
>>  
>> -	for_each_populated_zone(zone) {
>> +	for_each_zone(zone) {
>>  		unsigned long max_zone_pfn;
>>  
>> +		if (!populated_zone(zone))
>> +			continue;
>> +
>>  		mark_free_pages(zone);
>>  		max_zone_pfn = zone_end_pfn(zone);
>>  		for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
>> @@ -1717,7 +1723,10 @@ int hibernate_preallocate_memory(void)
>>  	saveable += save_highmem;
>>  	highmem = save_highmem;
>>  	size = 0;
>> -	for_each_populated_zone(zone) {
>> +	for_each_zone(zone) {
>> +		if (!populated_zone(zone))
>> +			continue;
>> +
>>  		size += snapshot_additional_pages(zone);
>>  		if (is_highmem(zone))
>>  			highmem += zone_page_state(zone, NR_FREE_PAGES);
>
>ditto for the above.
>
>
>> @@ -1863,8 +1872,8 @@ static int enough_free_mem(unsigned int nr_pages, unsigned int nr_highmem)
>>  	struct zone *zone;
>>  	unsigned int free = alloc_normal;
>>  
>> -	for_each_populated_zone(zone)
>> -		if (!is_highmem(zone))
>> +	for_each_zone(zone)
>> +		if (populated_zone(zone) && !is_highmem(zone))
>>  			free += zone_page_state(zone, NR_FREE_PAGES);
>>  
>>  	nr_pages += count_pages_for_highmem(nr_highmem);
>
>This one should be for_each_managed_zone (NR_FREE_PAGES)
>
>The rest looks good to me.
>-- 
>Michal Hocko
>SUSE Labs

-- 
Wei Yang
Help you, Help me

      reply	other threads:[~2018-11-21  3:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-14 23:50 [PATCH] mm: use managed_zone() for more exact check in zone iteration Wei Yang
2018-11-15 21:37 ` Andrew Morton
2018-11-16  4:41   ` Wei Yang
2018-11-16  9:57   ` Michal Hocko
2018-11-16 11:05     ` osalvador
2018-11-16 11:26       ` Michal Hocko
2018-11-16 15:58         ` Wei Yang
2018-11-16 17:07           ` Michal Hocko
2018-11-16 10:24 ` Michal Hocko
2018-11-21  3:05   ` Wei Yang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181121030504.ucclpgl62es7lnwf@master \
    --to=richard.weiyang@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=rjw@rjwysocki.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).