[RFC PATCH v2 4/4] mm: compaction: skip unmovable blocks for non-costly proactive mTHP compaction

From: Bo Zhang

Date: Wed Sep 30 2026 - 20:15:50 EST


Proactive compaction scans all pageblocks including unmovable/reclaimable
ones. For non-costly mTHP orders (<= PAGE_ALLOC_COSTLY_ORDER), those blocks
are dominated by non-migratable kernel allocations (slab, page tables) and
scanning them wastes cycles: a small order is easily satisfied from movable
blocks alone, so there is no need to scavenge the few migratable fallback
pages inside unmovable blocks.

Costly orders keep scanning all blocks: they are hard to form and benefit
from any migratable page available, including allocator fallbacks inside
unmovable blocks.

Restrict non-costly proactive compaction to movable/CMA blocks.

Signed-off-by: Bo Zhang <zhangbo56@xxxxxxxxxx>
---
mm/compaction.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/mm/compaction.c b/mm/compaction.c
index 0ff454ee5604..deddf931d0f2 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1404,10 +1404,19 @@ static bool suitable_migration_source(struct compact_control *cc,
struct page *page)
{
int block_mt;
+ unsigned int order = compact_hpage_order();
+ bool costly = order > PAGE_ALLOC_COSTLY_ORDER;

if (pageblock_skip_persistent(page))
return false;

+ if (is_via_compact_memory(cc->order) && !costly) {
+ block_mt = get_pageblock_migratetype(page);
+ if (block_mt == MIGRATE_MOVABLE || is_migrate_cma(block_mt))
+ return true;
+ return false;
+ }
+
/*
* Background compaction produces blocks for the zone at
* large, with no particular allocation context. Allow all
--
2.34.1