Tainted superpageblocks with nr_movable == 0 hold only unmovable and/or reclaimable pages. None are migration candidates (compaction only moves migratable pages), so scanning them is pure overhead. Bail out at the top of isolate_migratepages_block() when the current pageblock falls inside such an SPB, returning 0 without performing any per-page scan. The caller (isolate_migratepages) then advances to the next pageblock and re-enters; each pageblock in the empty tainted SPB takes the same fast bail, so the whole SPB is effectively skipped without per-page scan work. A tainted SPB with nr_movable > 0 still gets scanned normally, preserving correctness. Signed-off-by: Rik van Riel Assisted-by: Claude:claude-opus-4.7 syzkaller --- mm/compaction.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/mm/compaction.c b/mm/compaction.c index e4ba21072435..f9de52875c88 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -873,6 +873,27 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, cc->migrate_pfn = low_pfn; + /* + * Fast-path: a tainted SPB with no movable content has nothing to + * migrate from this pageblock. Bail out immediately and let the + * caller move on to the next pageblock; the caller will re-enter + * this function for each subsequent pageblock in the SPB and bail + * the same way, so the whole SPB is effectively skipped without + * any per-page scan work. + */ + if (cc->zone->nr_superpageblocks) { + struct superpageblock *sb = + pfn_to_superpageblock(cc->zone, low_pfn); + + if (sb && spb_get_category(sb) == SB_TAINTED && + sb->nr_movable == 0) { + unsigned long sb_end = + ALIGN(low_pfn + 1, SUPERPAGEBLOCK_NR_PAGES); + cc->migrate_pfn = min(sb_end, end_pfn); + return 0; + } + } + /* * Ensure that there are not too many pages isolated from the LRU * list by either parallel reclaimers or compaction. If there are, -- 2.54.0