From: Jim Cromie via B4 Relay <devnull+jim.cromie.gmail.com@kernel.org>
To: "Andrew Morton" <akpm@linux-foundation.org>,
"Pablo Neira Ayuso" <pablo@netfilter.org>,
"Florian Westphal" <fw@strlen.de>, "Phil Sutter" <phil@nwl.cc>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"Matthew Brost" <matthew.brost@intel.com>,
"Boris Brezillon" <boris.brezillon@collabora.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Ingo Molnar" <mingo@redhat.com>, "Will Deacon" <will@kernel.org>,
"Waiman Long" <longman@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Simon Horman" <horms@kernel.org>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"John Fastabend" <john.fastabend@gmail.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Boqun Feng" <boqun@kernel.org>, "Boqun Feng" <boqun@kernel.org>
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 <jim.cromie@gmail.com>
Subject: [PATCH 8/9] locking/lockdep: Shrink static list_entries array to early bootstrap buffer
Date: Mon, 17 Aug 2026 11:22:22 -0600 [thread overview]
Message-ID: <20260817-folio-pool-v1-v1-8-0c1d230aa3af@gmail.com> (raw)
In-Reply-To: <20260817-folio-pool-v1-v1-0-0c1d230aa3af@gmail.com>
From: Jim Cromie <jim.cromie@gmail.com>
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 <jim.cromie@gmail.com>
---
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
next prev parent reply other threads:[~2026-08-17 17:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 17:22 [PATCH 0/9] lib/folio_pool: Direct-Map Large Folio Pool & Scratchpad bump allocators Jim Cromie via B4 Relay
2026-08-17 17:22 ` [PATCH 1/9] lib/folio_pool: Introduce " Jim Cromie via B4 Relay
2026-08-17 17:22 ` [PATCH 2/9] netfilter/nf_tables: Add folio_scratchpad collector to struct nftables_pernet Jim Cromie via B4 Relay
2026-08-17 17:22 ` [PATCH 3/9] bpf/verifier: Route verifier stack state node allocations to folio_pool Jim Cromie via B4 Relay
2026-08-17 17:22 ` [PATCH 4/9] drm/gpuvm: Route gpuva_op allocations to folio_scratchpad Jim Cromie via B4 Relay
2026-08-17 17:22 ` [PATCH 5/9] bpf/syscall: Route generic_map_update_batch key/value " Jim Cromie via B4 Relay
2026-08-17 17:22 ` [PATCH 6/9] locking/lockdep: Fallback to folio_pool in alloc_list_entry when static pool is full Jim Cromie via B4 Relay
2026-08-17 21:01 ` Peter Zijlstra
2026-08-17 17:22 ` [PATCH 7/9] locking/lockdep: Traverse adjacency lists directly in zap_class() Jim Cromie via B4 Relay
2026-08-17 17:22 ` Jim Cromie via B4 Relay [this message]
2026-08-17 17:22 ` [PATCH 9/9] locking/lockdep: Migrate and compact boot-time dependency graph from __initdata Jim Cromie via B4 Relay
2026-08-17 18:17 ` [PATCH 0/9] lib/folio_pool: Direct-Map Large Folio Pool & Scratchpad bump allocators David Hildenbrand (Arm)
2026-08-17 18:34 ` Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260817-folio-pool-v1-v1-8-0c1d230aa3af@gmail.com \
--to=devnull+jim.cromie.gmail.com@kernel.org \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=aliceryhl@google.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=boqun@kernel.org \
--cc=boris.brezillon@collabora.com \
--cc=bpf@vger.kernel.org \
--cc=coreteam@netfilter.org \
--cc=dakr@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=eddyz87@gmail.com \
--cc=edumazet@google.com \
--cc=emil@etsalapatis.com \
--cc=fw@strlen.de \
--cc=horms@kernel.org \
--cc=jim.cromie@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=longman@redhat.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=martin.lau@linux.dev \
--cc=matthew.brost@intel.com \
--cc=memxor@gmail.com \
--cc=mingo@redhat.com \
--cc=mripard@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=peterz@infradead.org \
--cc=phil@nwl.cc \
--cc=simona@ffwll.ch \
--cc=song@kernel.org \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tzimmermann@suse.de \
--cc=will@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox