* [PATCH v3] page_alloc: allow migration of smaller hugepages during contig_alloc.
@ 2025-10-24 19:28 Gregory Price
2025-10-26 4:46 ` David Rientjes
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Gregory Price @ 2025-10-24 19:28 UTC (permalink / raw)
To: linux-mm
Cc: linux-kernel, kernel-team, akpm, vbabka, surenb, mhocko, jackmanb,
hannes, ziy, David Hildenbrand, Wei Yang
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.
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().
Suggested-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Gregory Price <gourry@gourry.net>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
---
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..23866d4c26ff 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);
+ if ((order >= MAX_FOLIO_ORDER) ||
+ (nr_pages <= (1 << order)))
+ return false;
+ }
}
return true;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3] page_alloc: allow migration of smaller hugepages during contig_alloc.
2025-10-24 19:28 [PATCH v3] page_alloc: allow migration of smaller hugepages during contig_alloc Gregory Price
@ 2025-10-26 4:46 ` David Rientjes
2025-10-27 9:55 ` Oscar Salvador
2025-10-27 15:43 ` David Hildenbrand
2 siblings, 0 replies; 5+ messages in thread
From: David Rientjes @ 2025-10-26 4:46 UTC (permalink / raw)
To: Gregory Price
Cc: linux-mm, linux-kernel, kernel-team, akpm, vbabka, surenb, mhocko,
jackmanb, hannes, ziy, David Hildenbrand, Wei Yang
On Fri, 24 Oct 2025, 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.
>
> 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().
>
> Suggested-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: Gregory Price <gourry@gourry.net>
> Reviewed-by: Zi Yan <ziy@nvidia.com>
> Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
Acked-by: David Rientjes <rientjes@google.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] page_alloc: allow migration of smaller hugepages during contig_alloc.
2025-10-24 19:28 [PATCH v3] page_alloc: allow migration of smaller hugepages during contig_alloc Gregory Price
2025-10-26 4:46 ` David Rientjes
@ 2025-10-27 9:55 ` Oscar Salvador
2025-10-27 15:43 ` David Hildenbrand
2 siblings, 0 replies; 5+ messages in thread
From: Oscar Salvador @ 2025-10-27 9:55 UTC (permalink / raw)
To: Gregory Price
Cc: linux-mm, linux-kernel, kernel-team, akpm, vbabka, surenb, mhocko,
jackmanb, hannes, ziy, David Hildenbrand, Wei Yang
On Fri, Oct 24, 2025 at 03:28:49PM -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 target contiguous
> allocation request as valid targets for allocation.
>
> 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().
>
> Suggested-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: Gregory Price <gourry@gourry.net>
> Reviewed-by: Zi Yan <ziy@nvidia.com>
> Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
--
Oscar Salvador
SUSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] page_alloc: allow migration of smaller hugepages during contig_alloc.
2025-10-24 19:28 [PATCH v3] page_alloc: allow migration of smaller hugepages during contig_alloc Gregory Price
2025-10-26 4:46 ` David Rientjes
2025-10-27 9:55 ` Oscar Salvador
@ 2025-10-27 15:43 ` David Hildenbrand
2025-11-06 16:06 ` Gregory Price
2 siblings, 1 reply; 5+ messages in thread
From: David Hildenbrand @ 2025-10-27 15:43 UTC (permalink / raw)
To: Gregory Price, linux-mm
Cc: linux-kernel, kernel-team, akpm, vbabka, surenb, mhocko, jackmanb,
hannes, ziy, Wei Yang
On 24.10.25 21:28, 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.
>
> 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().
>
> Suggested-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: Gregory Price <gourry@gourry.net>
> Reviewed-by: Zi Yan <ziy@nvidia.com>
> Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
> ---
Nit: trailing "." in subject
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers
David / dhildenb
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] page_alloc: allow migration of smaller hugepages during contig_alloc.
2025-10-27 15:43 ` David Hildenbrand
@ 2025-11-06 16:06 ` Gregory Price
0 siblings, 0 replies; 5+ messages in thread
From: Gregory Price @ 2025-11-06 16:06 UTC (permalink / raw)
To: David Hildenbrand
Cc: linux-mm, linux-kernel, kernel-team, akpm, vbabka, surenb, mhocko,
jackmanb, hannes, ziy, Wei Yang
On Mon, Oct 27, 2025 at 04:43:25PM +0100, David Hildenbrand wrote:
> On 24.10.25 21:28, 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.
> >
> > 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().
> >
> > Suggested-by: David Hildenbrand <david@redhat.com>
> > Signed-off-by: Gregory Price <gourry@gourry.net>
> > Reviewed-by: Zi Yan <ziy@nvidia.com>
> > Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
> > ---
>
> Nit: trailing "." in subject
>
> Acked-by: David Hildenbrand <david@redhat.com>
>
Hi David,
Do you think i should just staple these commits together at this point?
https://lore.kernel.org/linux-mm/20251009161515.422292-1-gourry@gourry.net/
If not i'll drop the '.' and just resubmit this with tags and just
update the commit message on movable_gigantic_pages to reference this
commit and your notes from there.
~Gregory
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-11-06 16:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-24 19:28 [PATCH v3] page_alloc: allow migration of smaller hugepages during contig_alloc Gregory Price
2025-10-26 4:46 ` David Rientjes
2025-10-27 9:55 ` Oscar Salvador
2025-10-27 15:43 ` David Hildenbrand
2025-11-06 16:06 ` Gregory Price
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).