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 1A0213F44F5 for ; Wed, 20 May 2026 15:00:50 +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=1779289259; cv=none; b=C2/iPSTMI9ovt9ANZEYWLe0M6qmPEmvoMoXGILP5LUvNYum5MAef5X5WUuKoF7nvR5o3F1bW1dLDi/6Vo6Q4UJ167ASUJOCDR+EykpR9oxTN+g4lqguXf7ZKbAKfmg2yJgS69zA9zw5cz0QVq/H1hRRLAArYIT/NXKsvZvh3008= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779289259; c=relaxed/simple; bh=x9eQDprk9ZUCDTUcWiYjtCD1ExQMSHG5JPhC9QQ07dg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FGSGLYg3Ons3bMpE7PyPVELSDuCVSOW/vUNfh0gDp0XxkWj3RUVOqJlgTMWQ8zf2wGQXb3DcpPygyMQRv684Rb9q+NshEzcinpzta6ECD03YXM1z0pp8c3jrr7JCtmrblJ8ko4yAQv0xgerCjWaQYMUthqGaQswsvLUU0airAss= 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=lQTEdoYg; 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="lQTEdoYg" 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=jtZKbuOjheumhRbPauF+MORFobu5zhRF12dkuYJiXIw=; b=lQTEdoYgv1COf2hRyTnyxUch/k KGfNdIHjMbmbk2ikfos0xrzFi/X+hIGzQcgqiZJ6zh0XJWWfTrYnybAz+S3K9OJjVAcwhf9pJN+IJ dIfaTEmk8ghXLoYH0SZEtJtZD2CfEmdWTb31M2rxxQxM6tirwnjvEwy9Y/TbxhcoXiF8WCpb1/SDQ QgugPCGH7bKSsL/q7ax8ujNPcGrw8jZpqg8vCnEKSlzhi9A1fUOky9MHc88+YnHVZiDATVGaxX2Rt dSDFARfZtDYatuEE4vC0CTQSr0w2j1j7loXjTRv4Y/TdhHTQR8ztvTNFzSHjdUCyykp5jGrb/9+pe WhcP0Hfg==; 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-0eoY; 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 39/40] mm: compaction: respect tainted SPB reserve in destination selection Date: Wed, 20 May 2026 10:59:45 -0400 Message-ID: <20260520150018.2491267-40-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 SPBs reserve headroom (per spb_tainted_reserve()) so the allocator can satisfy non-movable allocations without tainting fresh clean SPBs. Compaction's free-page scanner can erode that reserve by picking destination pages from tainted-SPB free lists -- exactly the headroom we need for unmovable demand. Refuse tainted-SPB pageblocks as compaction destinations once nr_free is at or below spb_tainted_reserve(sb). Clean SPBs (no reserve) stay fully eligible. This naturally biases compaction toward producing free pageblocks inside clean SPBs, where they're useful for hugepage allocation. Combined with the source-side skip and the kcompactd wake fix, this is sufficient for kcompactd to handle clean-SPB consolidation alone. Signed-off-by: Rik van Riel Assisted-by: Claude:claude-opus-4.7 syzkaller --- mm/compaction.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mm/compaction.c b/mm/compaction.c index f9de52875c88..3d1015dffa82 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1503,6 +1503,21 @@ static bool suitable_migration_target(struct compact_control *cc, if (cc->ignore_block_suitable) return true; + /* + * Tainted superpageblocks reserve some headroom for non-movable + * allocations. Don't spill compaction migration into that reserve -- + * doing so erodes the headroom the allocator was holding to avoid + * tainting fresh clean SPBs. Clean SPBs (no reserve) stay eligible. + */ + if (cc->zone->nr_superpageblocks) { + struct superpageblock *sb = + pfn_to_superpageblock(cc->zone, page_to_pfn(page)); + + if (sb && spb_get_category(sb) == SB_TAINTED && + sb->nr_free <= spb_tainted_reserve(sb)) + return false; + } + /* If the block is MIGRATE_MOVABLE or MIGRATE_CMA, allow migration */ if (is_migrate_movable(get_pageblock_migratetype(page))) return true; -- 2.54.0