From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE6833F1662 for ; Wed, 20 May 2026 15:00:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=96.67.55.147 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779289255; cv=none; b=mVOoiLggdcYEoNZtK2up2rGFT7oz6DXM4IA4PEVzjfaIow5B2qijLmifYPUda7Nmu6aTLV5xRQkplRU77FMKiseMX5rQn/MNGKcrGd/R6vV2fG4nOEowPq+l5k3XLNExSQFWfDsZMMmrL3cP73OlHrqEzHyJNs6ee8kx+qeKvbY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779289255; c=relaxed/simple; bh=SPT4Eq7v36unK79Lqd1lxyUobeTeyxLOnxyWUwPZKLQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sUjrS/58wATaSwMyhTUtQ0OUAmzqeEk0pfipbPauRBwPQK6ivCUfSAmndeM0rQSFFQaOSJsuOEfo/LhAYlUrJbMAwzozDhoPZ19Ov+LBWk+YAZ00PD4MXxBA+WyTLYW/YSHxcQUAHJhGNIemi3dWhVJUdniTJ0pQ2WaSU3BnX+4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=surriel.com; spf=pass smtp.mailfrom=surriel.com; dkim=pass (2048-bit key) header.d=surriel.com header.i=@surriel.com header.b=ng/wS2QP; arc=none smtp.client-ip=96.67.55.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=surriel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=surriel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=surriel.com header.i=@surriel.com header.b="ng/wS2QP" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=surriel.com ; s=mail; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=uXkdeLHggCi+vFtKz5fxgfs3r4RSBpj9N/haZRnpGWk=; b=ng/wS2QPNAoNUjMcCITdZpjGyD 5FSsZe/eW2L4IzCJ4dBed+n/ZuJgwwDcK5k27IpNliI4efJ0rTMwZsxebn5ApXkaRFEKF2j2fzxXN FZGQQQ6hhFLqg6buA34BNF3c6KpNJp6rKfCpHD2+KGcG4KNWZ2kn/2hbXmaFcSEUqwdcqs6AFKe4B rML1EbV5LyxbDuBBJ+75iEnBexLzik8nkGdV+r24uNX1sut0FK3H88VCCfEwouZacXecmm48xQiZ5 1yvZak5ph2d8ppyL7MfvQZ9Ee44A+Aejdh76bUOuKfiRNK2TmJL1tl6ef5N4NlQhYUz06d3BBZBpR sXawct+A==; Received: from fangorn.home.surriel.com ([10.0.13.7]) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.97.1) (envelope-from ) id 1wPiPN-0000000024Q-0ZBm; Wed, 20 May 2026 11:00:29 -0400 From: Rik van Riel To: linux-kernel@vger.kernel.org Cc: kernel-team@meta.com, linux-mm@kvack.org, david@kernel.org, willy@infradead.org, surenb@google.com, hannes@cmpxchg.org, ljs@kernel.org, ziy@nvidia.com, usama.arif@linux.dev, fvdl@google.com, Rik van Riel Subject: [RFC PATCH 38/40] mm: compaction: skip empty tainted superpageblocks as migration source Date: Wed, 20 May 2026 10:59:44 -0400 Message-ID: <20260520150018.2491267-39-riel@surriel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520150018.2491267-1-riel@surriel.com> References: <20260520150018.2491267-1-riel@surriel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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