From: "David Hildenbrand (Red Hat)" <david@kernel.org>
To: Zi Yan <ziy@nvidia.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, richard.weiyang@gmail.com
Subject: Re: [PATCH v7] page_alloc: allow migration of smaller hugepages during contig_alloc
Date: Tue, 6 Jan 2026 20:20:51 +0100 [thread overview]
Message-ID: <9e8b01f9-d1b0-44a7-86c9-97622b2baec1@kernel.org> (raw)
In-Reply-To: <36001B4C-A781-4571-AE65-4C00C9D215FC@nvidia.com>
On 1/6/26 19:56, Zi Yan wrote:
> On 6 Jan 2026, at 13:46, David Hildenbrand (Red Hat) wrote:
>
>>> - return false;
>>> + /*
>>> + * Only consider ranges containing hugepages if those pages are
>>> + * smaller than the requested contiguous region. e.g.:
>>> + * Move 2MB pages to free up a 1GB range.
>>> + * Don't move 1GB pages to free up a 2MB range.
>>> + *
>>> + * This makes contiguous allocation more reliable if multiple
>>> + * hugepage sizes are used without causing needless movement.
>>> + */
>>> + if (PageHuge(page)) {
>>> + unsigned int order;
>>> +
>>> + if (!IS_ENABLED(CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION))
>>> + return false;
>>> +
>>> + if (skip_hugetlb) {
>>> + *skipped_hugetlb = true;
>>> + return false;
>>> + }
>>> +
>>> + page = compound_head(page);
>>> + order = compound_order(page);
>>> + if ((order >= MAX_FOLIO_ORDER) ||
>>> + (nr_pages <= (1 << order)))
>>> + return false;
>>> +
>>> + /*
>>> + * Reaching this point means we've encounted a huge page
>>> + * smaller than nr_pages, skip all pfn's for that page.
>>> + *
>>> + * We can't get here from a tail-PageHuge, as it implies
>>> + * we started a scan in the middle of a hugepage larger
>>> + * than nr_pages - which the prior check filters for.
>>> + */
>>> + i += (1 << order) - 1;
>>
>> Assuming page != compound_head(page), you'd be skipping too much.
>
> It might not happen based on my reasoning[1], but feel free to punch poles. :)
:) hehe, I should just have read that comment more carefully.
Anyhow, I wonder whether removing 6 lines of comments by just doing it
properly might be better?
head = compound_head(page);
order = compound_order(head);
...
i += (1 << order) - 1 - (page - head);
In any case
Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>
--
Cheers
David
prev parent reply other threads:[~2026-01-06 19:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-21 12:46 Gregory Price
2026-01-06 14:48 ` Michal Hocko
2026-01-06 18:46 ` David Hildenbrand (Red Hat)
2026-01-06 18:56 ` Zi Yan
2026-01-06 19:20 ` David Hildenbrand (Red Hat) [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=9e8b01f9-d1b0-44a7-86c9-97622b2baec1@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--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 \
--cc=ziy@nvidia.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