linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Zi Yan <ziy@nvidia.com>
To: Wei Yang <richard.weiyang@gmail.com>
Cc: Gregory Price <gourry@gourry.net>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	kernel-team@meta.com, akpm@linux-foundation.org, vbabka@suse.cz,
	surenb@google.com, mhocko@suse.com, jackmanb@google.com,
	hannes@cmpxchg.org, David Hildenbrand <david@redhat.com>
Subject: Re: [RFC PATCH v2] page_alloc: allow migration of smaller hugepages during contig_alloc.
Date: Mon, 20 Oct 2025 21:28:18 -0400	[thread overview]
Message-ID: <E787AD03-DC67-4B5C-8BF6-C79F3C583D00@nvidia.com> (raw)
In-Reply-To: <20251021012533.56rdl6v76plkw4nl@master>

On 20 Oct 2025, at 21:25, Wei Yang wrote:

> On Mon, Oct 20, 2025 at 05:08:16PM -0400, Gregory Price wrote:
>> We presently skip regions with hugepages entirely when trying to do
>> contiguous page allocation.  Instead, if hugepage migration is enabled,
>> consider regions with hugepages smaller than the requested allocation.
>>
>> Compaction `isolate_migrate_pages_block()` already expects requests
>
> isolate_migratepages_block() ?
>
>> with hugepages to originate from alloc_contig, and hugetlb code also
>> does a migratable check when isolating in `folio_isolate_hugetlb()`.
>>
>> Suggested-by: David Hildenbrand <david@redhat.com>
>> Signed-off-by: Gregory Price <gourry@gourry.net>
>> ---
>> mm/page_alloc.c | 15 +++++++++++++--
>> 1 file changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index 600d9e981c23..da2e65bf63e3 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -7048,8 +7048,19 @@ static bool pfn_range_valid_contig(struct zone *z, unsigned long start_pfn,
>> 		if (PageReserved(page))
>> 			return false;
>>
>> -		if (PageHuge(page))
>> -			return false;
>> +		if (PageHuge(page)) {
>> +			unsigned int order;
>> +
>> +			if (!IS_ENABLED(CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION))
>> +				return false;
>> +
>> +			/* Don't consider moving same size/larger pages */
>> +			page = compound_head(page);
>> +			order = compound_order(page);
>
> How about using folio_large_order(page_folio(page)) ?

See the discussion at https://lore.kernel.org/linux-mm/609E7E01-33A6-4931-AC89-1F4B2944FB64@nvidia.com/ about reading folio order without locking.

>
>> +			if ((order >= MAX_PAGE_ORDER) ||
>> +			    (nr_pages < (1 << order)))
>> +				return false;
>> +		}
>> 	}
>> 	return true;
>> }
>> -- 
>> 2.51.0
>>
>
> Generally LGTM
>
> Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
>
> -- 
> Wei Yang
> Help you, Help me


--
Best Regards,
Yan, Zi


  reply	other threads:[~2025-10-21  1:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-20 21:08 Gregory Price
2025-10-20 23:02 ` Zi Yan
2025-10-21  1:25 ` Wei Yang
2025-10-21  1:28   ` Zi Yan [this message]
2025-10-21  9:14     ` Wei Yang
2025-10-21 16:03       ` Gregory Price
2025-10-21 20:15         ` Wei Yang
2025-10-21  1:29   ` Wei Yang
2025-10-21  9:30 ` David Hildenbrand
2025-10-21 16:05   ` Gregory Price
2025-10-22  1:40 ` SeongJae Park
2025-10-22 14:53   ` Gregory Price

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=E787AD03-DC67-4B5C-8BF6-C79F3C583D00@nvidia.com \
    --to=ziy@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=gourry@gourry.net \
    --cc=hannes@cmpxchg.org \
    --cc=jackmanb@google.com \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=richard.weiyang@gmail.com \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    /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