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 3CEEA3F1653 for ; Wed, 20 May 2026 15:00:49 +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=1779289258; cv=none; b=JPW7o6yNmiBmJ/g8+UXJhIU0+Ej5AwH2zLHgj4OUaHBBiKkaHha1kWIWW/ixodG6W0GVrzB8rMCe+tupqp5HWlJ4QHOgYMobwigiaapmbS8m1R/oDZKDmDvBi62+XP2bWjlDAWwiTxVVWHtQsu+3rLNihhEyULW8UgZD4PyVS+0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779289258; c=relaxed/simple; bh=PYSlL1i606gycxUg6rXIwlBsnRTwz3am9HkNgCkSRCc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T97bqAWQxC7rrpIGTq7ckNp5hf0jTyr762YRp99H13WBME7kJKGTJ1n43O5y8VmuuiOfWWXEC8MFJUfRNWGzXeaXwq4I0IoGp45QTEOF5vjc0H2IWbFU24zW7AOaG1wLlD6HencoVzfNrT8pVbSTKl0fefrozx0kV4GYYk3f0Bc= 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=aCNhk919; 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="aCNhk919" 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=SZrOQk0GM156TvBoVM+zLzXRO2Iy08Gh16ie8a5/0l4=; b=aCNhk9191WRg6r+R2XCSmJGb9N XWpYCBqFGqjSuPZAdPk6o4CKReJBXt0pyJ0YNYvbfuErrkbzrlrNhADsUtIYQS9bvj2tS5Uihh81K QVvIciHWPeHBse8536TVD6l1Sf/9I3fxdZrKloib+zUmpbYGprwmbA8gDCqriOra8R8qX7Yb8kRzl Xzxi42+yhqMJHEx6pJO6/EK/dPBEWr/r63Nget93fY9H/dQmaEgKZJw8Oa4LPzOH2oRXQrPqom484 Iyi2AOHaVQgtFtbhbHJU1NrCrAgyHdJI1BUu/gFKM38WS1t4FIIi0X7QLB2TFOtlN0jM1aJXqbVp8 XeYfTlDA==; 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-0NIZ; 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 36/40] mm: page_alloc: set ALLOC_NOFRAGMENT on alloc_frozen_pages_nolock_noprof Date: Wed, 20 May 2026 10:59:42 -0400 Message-ID: <20260520150018.2491267-37-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 The no-lock atomic page allocator (alloc_frozen_pages_nolock) bypasses __alloc_pages_slowpath() entirely and calls get_page_from_freelist() directly. The slowpath is where ALLOC_NOFRAGMENT is normally set for non-movable allocations, so the nolock path runs without the "skip clean SPBs" guard. Add ALLOC_NOFRAGMENT to the alloc_flags. The function is best-effort and callers already handle NULL. The flag steers the alloc toward tainted-SPB sub-pageblock space first; for order > 0 the existing auto-refuse in the get_page_from_freelist relax sequence returns NULL when the tainted pool can serve a smaller order, and for order = 0 the alloc falls back to claiming a clean SPB only if the tainted pool is exhausted of suitable fragments. ALLOC_NOFRAGMENT is purely a pageblock-category steering hint; it does not depend on __GFP_DIRECT_RECLAIM and does not introduce any sleeping locks, so it composes cleanly with ALLOC_TRYLOCK in NMI, hardirq, and PREEMPT_RT contexts. Signed-off-by: Rik van Riel Assisted-by: Claude:claude-opus-4.7 syzkaller --- mm/page_alloc.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2791a52b61da..4e45fac14622 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -11525,7 +11525,23 @@ struct page *alloc_frozen_pages_nolock_noprof(gfp_t gfp_flags, int nid, unsigned */ gfp_t alloc_gfp = __GFP_NOWARN | __GFP_ZERO | __GFP_NOMEMALLOC | __GFP_COMP | gfp_flags; - unsigned int alloc_flags = ALLOC_TRYLOCK; + /* + * ALLOC_NOFRAGMENT steers this best-effort no-lock allocation + * toward tainted-SPB sub-pageblock space before fragmenting any + * clean superpageblock. Without it, atomic kmalloc_nolock callers + * (e.g. BPF storage from sched_process_exec tracepoints) hit the + * fallback path on every PCP miss and convert a movable pageblock + * in a clean SPB to UNMOVABLE -- tainting a 1 GiB hugepage + * candidate for an order-0 atomic alloc. With NOFRAGMENT set: + * - order > 0: the get_page_from_freelist relax sequence + * auto-refuses to drop NOFRAGMENT when the tainted pool can + * serve a smaller order, returning NULL to the caller. + * - order = 0: prefers tainted-SPB fragments first; only falls + * back to claiming a clean-SPB pageblock if the tainted pool + * is exhausted of suitable fragments. + * Callers of alloc_pages_nolock() already handle NULL. + */ + unsigned int alloc_flags = ALLOC_TRYLOCK | ALLOC_NOFRAGMENT; struct alloc_context ac = { }; struct page *page; -- 2.54.0