lkml.org 
[lkml]   [2021]   [Feb]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RFC PATCH 1/2] mm,page_alloc: Make alloc_contig_range handle in-use hugetlb pages
Date
On 08.02.21 11:38, Oscar Salvador wrote:
> alloc_contig_range is not prepared to handle hugetlb pages and will
> fail if it ever sees one, but since they can be migrated as any other
> page (LRU and Movable), it makes sense to also handle them.
>
> For now, do it only when coming from alloc_contig_range.
>
> Signed-off-by: Oscar Salvador <osalvador@suse.de>
> ---
> mm/compaction.c | 17 +++++++++++++++++
> mm/vmscan.c | 5 +++--
> 2 files changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/mm/compaction.c b/mm/compaction.c
> index e5acb9714436..89cd2e60da29 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -940,6 +940,22 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
> goto isolate_fail;
> }
>
> + /*
> + * Handle hugetlb pages only when coming from alloc_contig
> + */
> + if (PageHuge(page) && cc->alloc_contig) {
> + if (page_count(page)) {

I wonder if we should care about races here. What if someone
concurrently allocates/frees?

Note that PageHuge() succeeds on tail pages, isolate_huge_page() not, i
assume we'll have to handle that as well.

I wonder if it would make sense to move some of the magic to hugetlb
code and handle it there with less chances for races (isolate if used,
alloc-and-dissolve if not).

> + /*
> + * Hugetlb page in-use. Isolate and migrate.
> + */
> + if (isolate_huge_page(page, &cc->migratepages)) {
> + low_pfn += compound_nr(page) - 1;
> + goto isolate_success_no_list;
> + }
> + }

--
Thanks,

David / dhildenb

\
 
 \ /
  Last update: 2021-02-10 10:15    [W:0.138 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site