[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251021091443.5ggfmvl5jwyknjnv@master>
Date: Tue, 21 Oct 2025 09:14:43 +0000
From: Wei Yang <richard.weiyang@...il.com>
To: Zi Yan <ziy@...dia.com>
Cc: Wei Yang <richard.weiyang@...il.com>, Gregory Price <gourry@...rry.net>,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
kernel-team@...a.com, akpm@...ux-foundation.org, vbabka@...e.cz,
surenb@...gle.com, mhocko@...e.com, jackmanb@...gle.com,
hannes@...xchg.org, David Hildenbrand <david@...hat.com>
Subject: Re: [RFC PATCH v2] page_alloc: allow migration of smaller hugepages
during contig_alloc
On Mon, Oct 20, 2025 at 09:28:18PM -0400, Zi Yan wrote:
>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@...hat.com>
>>> Signed-off-by: Gregory Price <gourry@...rry.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.
>
I took another look at this.
The above code is expanded to:
page = _compound_head(page);
order = compound_order(page);
folio = page;
test_bit(PG_head, &folio->flags.f);
return folio_large_order(folio);
If we use
order = folio_order(page_folio(page))
It is expanded to:
folio = _compound_head(page);
folio_test_large(folio)
folio_test_head(folio)
test_bit(PG_head, &folio->flags.f)
return folio_large_order(folio);
These two seems expanded to the same code.
Maybe we can use folio_order() here?
>>
>>> + if ((order >= MAX_PAGE_ORDER) ||
>>> + (nr_pages < (1 << order)))
>>> + return false;
>>> + }
>>> }
>>> return true;
>>> }
>>> --
>>> 2.51.0
>>>
>>
>> Generally LGTM
>>
>> Reviewed-by: Wei Yang <richard.weiyang@...il.com>
>>
>> --
>> Wei Yang
>> Help you, Help me
>
>
>--
>Best Regards,
>Yan, Zi
--
Wei Yang
Help you, Help me
Powered by blists - more mailing lists