From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6B5A246D2CE; Mon, 17 Aug 2026 17:22:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786987352; cv=none; b=sBDOx69hWrUPLupU/Vo+oWOyuMJKnBF9zmTMKHXQ0r+qPDiM76IdGNwLKXfzQxUxn4t7QuRNFdbV2fxw5hoXDwoWF2DIXpuSTxd1DOGQt0qRHfqSA4BUwHxyUI0NhubSOYHiH3SHA6YWjE/2GLZtuQckrSQCp8xwPOupC0N0eRc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786987352; c=relaxed/simple; bh=oTzXI58WXBQ7S7irZsNVmatUb+eJJWJo5/oxSAo9JLY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f/pDrOVqVZ4kDdeBH3+h6V03w2k/ehGsbALa2cBX9QRCLk64VET6Q1w52RYxUGyUIS1rb2ZcUvH18WAg+jNeg6Ka4jO30TSIq+CB40M5es5wYrkMOME7WOfgHDu05rltDqhyGdUnNCenEmKItu9DXqduC4Nwe4raUCbWMpbIEHA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Rf+B59Ae; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Rf+B59Ae" Received: by smtp.kernel.org (Postfix) with ESMTPS id E416BC2BCFC; Mon, 17 Aug 2026 17:22:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1786987352; bh=oTzXI58WXBQ7S7irZsNVmatUb+eJJWJo5/oxSAo9JLY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Rf+B59Ae4GVvYCAuSdGJn/7wuVLJPyQfkIeq2IrGp4Oi1Y0FDTJARPAlCZGux/hRV EnHm707HtVzIWJhfchdkYCcZK3InK/37Js2oPwisawCdw1BcJdC/3yj/v397wBkHGT FAsRIeaELJkdOYpHYn7WaD3ncOIhmx2B+XzifJMEaAtMXEdyMEY0DT631e/mmO7yKE Rf5obpA0+YBfjyf+mABOFOFC1LxbYs0nQpqP96VxYqYzEizKhxLPRN0aPENmGO+ssH /GIEWN4hEJ8hwrK4cgoKmFdsQqIpzpfZ9IesGZtDkmZuieAYVx3N9SPJ8HMk3BMFf2 4BHyswX9oGmAQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C151FC5DF66; Mon, 17 Aug 2026 17:22:31 +0000 (UTC) From: Jim Cromie via B4 Relay Date: Mon, 17 Aug 2026 11:22:22 -0600 Subject: [PATCH 8/9] locking/lockdep: Shrink static list_entries array to early bootstrap buffer Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260817-folio-pool-v1-v1-8-0c1d230aa3af@gmail.com> References: <20260817-folio-pool-v1-v1-0-0c1d230aa3af@gmail.com> In-Reply-To: <20260817-folio-pool-v1-v1-0-0c1d230aa3af@gmail.com> To: Andrew Morton , Pablo Neira Ayuso , Florian Westphal , Phil Sutter , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Danilo Krummrich , Matthew Brost , Boris Brezillon , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , John Fastabend , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Alice Ryhl , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Boqun Feng , Boqun Feng Cc: netfilter-devel@vger.kernel.org, bpf@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, coreteam@netfilter.org, netdev@vger.kernel.org, Jim Cromie X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1786987349; l=4389; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=ZoAPPwe75kYWQBnnaiZlpzm8KKVLAq8UQwudQC9NlbE=; b=KNAOo/eQMuy5erfpSMg/oT8JjN3sqRwBgko6OmdykAuJj2sOkIfPf1RxIxulBDQLthiMvgmmd NmWIc7T/EjfBohB3EMTwfUSxsxhPMAP5h7s7rWhuP12qQAR2uE+yRiK X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= X-Endpoint-Received: by B4 Relay for jim.cromie@gmail.com/20260203 with auth_id=958 X-Original-From: Jim Cromie Reply-To: jim.cromie@gmail.com From: Jim Cromie Shrink the static compile-time list_entries[] array and its tracking bitmap from MAX_LOCKDEP_ENTRIES (32,768 entries, ~1.31 MB BSS) down to a 4096-entry early boot bootstrap buffer (~160 KB BSS). During early boot before mem_init(), lockdep records initial spinlock dependencies in the static bootstrap buffer. Once the buddy page allocator is online, alloc_list_entry() seamlessly spills all subsequent lock dependency allocations directly into lockdep_pool in 64KB direct-map folios. Adds a core_initcall telemetry hook (lockdep_boot_report) to log the exact count of bootstrap entries consumed prior to buddy initialization. Empirical boot telemetry confirms zero regressions and validates the two-tier spillway on x86 SMP: - Pre-buddy watermark: 668/4096 bootstrap entries consumed (16.3%). - Post-buddy scaling: 5,058 total direct dependencies and 22,577 indirect paths validated, with 962 entries operating dynamically inside lockdep_pool direct-map folios. Reclaims ~1.15 MB of static unswappable kernel .bss memory (88% reduction) while enabling unbounded lockdep scaling on dense NUMA/container workloads. Signed-off-by: Jim Cromie --- kernel/locking/lockdep.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index c8975c9282bb..5968a976bf8e 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -229,9 +229,11 @@ static inline int debug_locks_off_graph_unlock(void) return ret; } +#define BOOTSTRAP_LOCKDEP_ENTRIES 4096UL + unsigned long nr_list_entries; -static struct lock_list list_entries[MAX_LOCKDEP_ENTRIES]; -static DECLARE_BITMAP(list_entries_in_use, MAX_LOCKDEP_ENTRIES); +static struct lock_list list_entries[BOOTSTRAP_LOCKDEP_ENTRIES]; +static DECLARE_BITMAP(list_entries_in_use, BOOTSTRAP_LOCKDEP_ENTRIES); /* * All data structures here are protected by the global debug_lock. @@ -6271,6 +6273,12 @@ static void remove_class_from_lock_chains(struct pending_free *pf, } } +static inline bool is_bootstrap_entry(const struct lock_list *entry) +{ + return entry >= list_entries && + entry < list_entries + ARRAY_SIZE(list_entries); +} + /* * Remove all references to a lock class. The caller must hold the graph lock. */ @@ -6287,26 +6295,30 @@ static void zap_class(struct pending_free *pf, struct lock_class *class) list_for_each_entry_safe(entry, tmp, &class->locks_after, entry) { list_for_each_entry_safe(other, other_tmp, &entry->links_to->locks_before, entry) { if (other->links_to == class) { - __clear_bit(other - list_entries, list_entries_in_use); + if (is_bootstrap_entry(other)) + __clear_bit(other - list_entries, list_entries_in_use); nr_list_entries--; list_del_rcu(&other->entry); break; } } - __clear_bit(entry - list_entries, list_entries_in_use); + if (is_bootstrap_entry(entry)) + __clear_bit(entry - list_entries, list_entries_in_use); nr_list_entries--; list_del_rcu(&entry->entry); } list_for_each_entry_safe(entry, tmp, &class->locks_before, entry) { list_for_each_entry_safe(other, other_tmp, &entry->links_to->locks_after, entry) { if (other->links_to == class) { - __clear_bit(other - list_entries, list_entries_in_use); + if (is_bootstrap_entry(other)) + __clear_bit(other - list_entries, list_entries_in_use); nr_list_entries--; list_del_rcu(&other->entry); break; } } - __clear_bit(entry - list_entries, list_entries_in_use); + if (is_bootstrap_entry(entry)) + __clear_bit(entry - list_entries, list_entries_in_use); nr_list_entries--; list_del_rcu(&entry->entry); } @@ -6718,6 +6730,15 @@ void __init lockdep_init(void) sizeof(((struct task_struct *)NULL)->held_locks)); } +static int __init lockdep_boot_report(void) +{ + pr_info("lockdep: %lu/%lu bootstrap entries used before buddy init, folio_pool active\n", + min_t(unsigned long, nr_list_entries, ARRAY_SIZE(list_entries)), + ARRAY_SIZE(list_entries)); + return 0; +} +core_initcall(lockdep_boot_report); + static void print_freed_lock_bug(struct task_struct *curr, const void *mem_from, const void *mem_to, struct held_lock *hlock) -- 2.55.0