linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v2] page_alloc: allow migration of smaller hugepages during contig_alloc.
@ 2025-10-20 21:08 Gregory Price
  2025-10-20 23:02 ` Zi Yan
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Gregory Price @ 2025-10-20 21:08 UTC (permalink / raw)
  To: linux-mm
  Cc: linux-kernel, kernel-team, akpm, vbabka, surenb, mhocko, jackmanb,
	hannes, ziy, David Hildenbrand

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
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);
+			if ((order >= MAX_PAGE_ORDER) ||
+			    (nr_pages < (1 << order)))
+				return false;
+		}
 	}
 	return true;
 }
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-10-22 14:53 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-20 21:08 [RFC PATCH v2] page_alloc: allow migration of smaller hugepages during contig_alloc Gregory Price
2025-10-20 23:02 ` Zi Yan
2025-10-21  1:25 ` Wei Yang
2025-10-21  1:28   ` Zi Yan
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

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).