From: David Hildenbrand <david@redhat.com>
To: Gregory Price <gourry@gourry.net>, linux-mm@kvack.org
Cc: 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,
ziy@nvidia.com
Subject: Re: [RFC PATCH] page_alloc: allow migration of smaller hugepages during contig_alloc.
Date: Mon, 20 Oct 2025 19:24:04 +0200 [thread overview]
Message-ID: <487730c6-423a-4a03-a668-9b9ff92a5cfb@redhat.com> (raw)
In-Reply-To: <20251020170615.1000819-1-gourry@gourry.net>
On 20.10.25 19:06, 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 target contiguous
> allocation request as valid targets for allocation.
>
> Compaction `isolate_migrate_pages_block()` already expects requests
> with hugepages to originate from alloc_contig, and hugetlb code also
> does a migratable check when isolating in `folio_isolate_hugetlb()`.
>
> We add the migration check here to avoid calling compaction on a
> region if we know migration is not possible at all.
>
> Suggested-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: Gregory Price <gourry@gourry.net>
> ---
> mm/page_alloc.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 600d9e981c23..e0760eafe032 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -7048,8 +7048,14 @@ 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)) {
> + struct folio *folio = page_folio(page);
> +
> + /* Don't consider moving same size/larger pages */
> + if (!folio_test_hugetlb_migratable(folio) ||
> + (1 << folio_order(folio) >= nr_pages))
We have folio_nr_pages().
Do we really need the folio_hugetlb_migratable() check?
> + return false;
This code is completely racy. folio_nr_pages() should be fine AFAIKT (no
VM_WARN_ON() etc), not sure about folio_test_hugetlb_migratable().
If it becomes a problem we could do a snapshot_page() to take a snapshot
we can query.
--
Cheers
David / dhildenb
next prev parent reply other threads:[~2025-10-20 17:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-20 17:06 Gregory Price
2025-10-20 17:24 ` David Hildenbrand [this message]
2025-10-20 17:41 ` Gregory Price
2025-10-20 19:15 ` Zi Yan
2025-10-20 19:18 ` David Hildenbrand
2025-10-20 19:40 ` Gregory Price
2025-10-20 19:46 ` David Hildenbrand
2025-10-20 19:58 ` Gregory Price
2025-10-20 20:17 ` David Hildenbrand
2025-10-20 20:27 ` Gregory Price
2025-10-20 20:38 ` David Hildenbrand
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=487730c6-423a-4a03-a668-9b9ff92a5cfb@redhat.com \
--to=david@redhat.com \
--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=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