Re: [PATCH 2/4] mm: compaction: support non-movable compaction for pageblock requests
From: Johannes Weiner
Date: Thu Jul 09 2026 - 13:46:15 EST
On Thu, Jul 02, 2026 at 11:28:47AM +0200, Vlastimil Babka (SUSE) wrote:
> On 7/1/26 23:11, Johannes Weiner wrote:
> > On Wed, Jul 01, 2026 at 08:14:05PM +0200, Vlastimil Babka (SUSE) wrote:
> >>
> >> > This made the migratetype filtering about preventing block
> >> > pollution. The patch quotes reduced extfrag numbers.
> >> >
> >> > So now we have a block pollution guard that we apply only if... the
> >> > scanner is latency sensitive? :) Is this actually desired behavior?
> >>
> >> Yeah indeed I was wondering in this direction.
> >>
> >> > Another way of looking at it would be this:
> >> >
> >> > /*
> >> > * Allocation fallbacks can spread migratable pages
> >> > * into non-movable blocks.
> >>
> >> But also vice versa, non-movable pages into movable blocks? (without
> >> defrag_mode?).
> >
> > Uhm but those aren't compactable anymore then, right?
>
> Yeah.
>
> > There is a flipside, but it isn't quite symmetrical. Movable requests
> > are allowed to look for movables in unmovable blocks once they become
> > sync (high-effort, low-result). Non-movable requests are finally
> > allowed to empty movable blocks once they become sync; they *start*
> > with the high-effort, low-result mode to avoid block contamination but
> > are allowed to escalate when that doesn't produce results.
>
> Hm, true!
>
> I was also thinking, if defrag mode doesn't allow that escalation ever
> (IIRC?), should it be reflected here as well even with sync compaction?
Ok I made a clarification regarding defrag_mode in the other comment.
How about this?
diff --git a/mm/compaction.c b/mm/compaction.c
index 7df3a85d43af..a12a49eefe85 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1399,13 +1399,24 @@ static bool suitable_migration_source(struct compact_control *cc,
if (is_migrate_cma(block_mt) && !(cc->alloc_flags & ALLOC_CMA))
return false;
+ /*
+ * Per default, scans are restricted to blocks compatible with
+ * the request, to prevent cross-contamination. Once
+ * compaction priority escalates to synchronous scans, though,
+ * scan all blocks to try to make forward progress. For
+ * movable request, this likely helps little: there shouldn't
+ * be many migratable pages inside non-movable blocks besides
+ * allocator fallbacks. For non-movable requests, this helps a
+ * lot, as they can finally scan movable blocks.
+ */
if (cc->mode != MIGRATE_ASYNC)
return true;
/*
* Prevent small unmovable/reclaimable requests from polluting
- * movable blocks through fallbacks. Whole-block production is
- * exempt as the allocator claims and converts these.
+ * movable blocks through fallbacks. Whole-block production
+ * (directly requested, or defrag_mode) is exempt as the
+ * allocator claims and converts these.
*/
if (cc->migratetype == MIGRATE_MOVABLE || cc->order >= pageblock_order)
return is_migrate_movable(block_mt);