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

From: Dev Jain

Date: Mon Oct 19 2026 - 05:44:24 EST




On 01/10/26 5:44 am, Bo Zhang wrote:
> 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.

I think this is a reasonable compromise for now.

>
> 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 al