linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Muchun Song <songmuchun@bytedance.com>, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/page_alloc: Do not isolate redundant pageblock
Date: Fri, 27 Nov 2020 17:56:18 +0100	[thread overview]
Message-ID: <f1e13f66-26f8-a7be-a99d-662ef1adfb04@redhat.com> (raw)
In-Reply-To: <54061152-2a1b-694f-8d45-d1333bc4a3fb@redhat.com>

On 27.11.20 17:54, David Hildenbrand wrote:
> On 27.11.20 15:19, Muchun Song wrote:
>> Current pageblock isolation logic could isolate each pageblock individually
>> since commit d9dddbf55667 ("mm/page_alloc: prevent merging between isolated
>> and other pageblocks"). So we not need to concern about page allocator
>> merges buddies from different pageblocks and changes MIGRATE_ISOLATE to
>> some other migration type.
>>
>> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
>> ---
>>  mm/page_alloc.c | 26 ++++++++------------------
>>  1 file changed, 8 insertions(+), 18 deletions(-)
>>
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index cefbef32bf4a..608a2c2b8ab7 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -8313,16 +8313,14 @@ struct page *has_unmovable_pages(struct zone *zone, struct page *page,
>>  }
>>  
>>  #ifdef CONFIG_CONTIG_ALLOC
>> -static unsigned long pfn_max_align_down(unsigned long pfn)
>> +static unsigned long pfn_align_down(unsigned long pfn)
>>  {
>> -	return pfn & ~(max_t(unsigned long, MAX_ORDER_NR_PAGES,
>> -			     pageblock_nr_pages) - 1);
>> +	return pfn & ~(pageblock_nr_pages - 1);
>>  }
>>  
>> -static unsigned long pfn_max_align_up(unsigned long pfn)
>> +static unsigned long pfn_align_up(unsigned long pfn)
>>  {
>> -	return ALIGN(pfn, max_t(unsigned long, MAX_ORDER_NR_PAGES,
>> -				pageblock_nr_pages));
>> +	return ALIGN(pfn, pageblock_nr_pages);
>>  }
>>  
>>  /* [start, end) must belong to a single zone. */
>> @@ -8415,14 +8413,6 @@ int alloc_contig_range(unsigned long start, unsigned long end,
>>  	INIT_LIST_HEAD(&cc.migratepages);
>>  
>>  	/*
>> -	 * What we do here is we mark all pageblocks in range as
>> -	 * MIGRATE_ISOLATE.  Because pageblock and max order pages may
>> -	 * have different sizes, and due to the way page allocator
>> -	 * work, we align the range to biggest of the two pages so
>> -	 * that page allocator won't try to merge buddies from
>> -	 * different pageblocks and change MIGRATE_ISOLATE to some
>> -	 * other migration type.
>> -	 *
>>  	 * Once the pageblocks are marked as MIGRATE_ISOLATE, we
>>  	 * migrate the pages from an unaligned range (ie. pages that
>>  	 * we are interested in).  This will put all the pages in
>> @@ -8438,8 +8428,8 @@ int alloc_contig_range(unsigned long start, unsigned long end,
>>  	 * put back to page allocator so that buddy can use them.
>>  	 */
>>  
>> -	ret = start_isolate_page_range(pfn_max_align_down(start),
>> -				       pfn_max_align_up(end), migratetype, 0);
>> +	ret = start_isolate_page_range(pfn_align_down(start), pfn_align_up(end),
>> +				       migratetype, 0);
>>  	if (ret)
>>  		return ret;
>>  
>> @@ -8522,8 +8512,8 @@ int alloc_contig_range(unsigned long start, unsigned long end,
>>  		free_contig_range(end, outer_end - end);
>>  
>>  done:
>> -	undo_isolate_page_range(pfn_max_align_down(start),
>> -				pfn_max_align_up(end), migratetype);
>> +	undo_isolate_page_range(pfn_align_down(start), pfn_align_up(end),
>> +				migratetype);
>>  	return ret;
>>  }
>>  EXPORT_SYMBOL(alloc_contig_range);
>>
> 
> Last time I checked, set_migratetype_isolate()->has_unmovable_pages()
> was not prepared for that in case of !CMA and !ZONE_MOVABLE.
> 
> Assume you have an unmovable MAX_ORDER - 1 page that spans two
> pageblocks (e.g., x86-64). Assume you try to isolate the second
> pageblock. IIRC, you would answer "yes", as the refcount of all involved
> pages is 0.
> 
> 
> How did you test this works as expected?
> 

And I forgot to mention, in case it's a movable MAX_ORDER - 1 page (or
simply free), would __alloc_contig_migrate_range() do the right thing
and migrate the whole page?

-- 
Thanks,

David / dhildenb



      reply	other threads:[~2020-11-27 16:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-27 14:19 [PATCH] mm/page_alloc: Do not isolate redundant pageblock Muchun Song
2020-11-27 15:17 ` Vlastimil Babka
2020-11-27 15:43   ` [External] " Muchun Song
2020-11-27 16:54 ` David Hildenbrand
2020-11-27 16:56   ` David Hildenbrand [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=f1e13f66-26f8-a7be-a99d-662ef1adfb04@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=songmuchun@bytedance.com \
    /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).