From: Boqun Feng <boqun@kernel.org>
To: Vlad Poenaru <vlad.wing@gmail.com>
Cc: Bart Van Assche <bvanassche@acm.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Waiman Long <longman@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Eric Dumazet <edumazet@kernel.org>,
Davide Caratti <dcaratti@redhat.com>,
Breno Leitao <leitao@debian.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] lockdep: Keep dynamic key hash nodes in lockdep-owned storage
Date: Mon, 26 Oct 2026 07:07:39 -0700 [thread overview]
Message-ID: <at9eq_3YUIL1ACEK@tardis.local> (raw)
In-Reply-To: <20261023121946.2260882-1-vlad.wing@gmail.com>
On Fri, Oct 23, 2026 at 05:19:46AM -0700, Vlad Poenaru wrote:
> On 10/21/26 8:01 PM, Bart Van Assche wrote:
> > This patch introduces a new hard upper limit on the number of dynamic
> > lockdep keys. That's unfortunate but I assume it's not possible to
> > eliminate this hard upper bound if the key storage is owned by
> > lockdep?
>
> It isn't inherent; it comes from preallocating the nodes the way lockdep
> does for its other tables. Two ways to lift it:
>
> 1. Fall back to the embedded node when the pool is full. Keys
> registered after that are linked through their own hash_entry, as
> today, and only those wait for a grace period when they are
> unregistered. The key stays at 16 bytes and there is a second lookup
> path, but running out becomes a slowdown instead of lockdep turning
> itself off.
>
This gives me feeling that we did something for nothing, because in a
system where there are a plenty of dynamic keys, we back to the current
status after we introduce another hashlist.
> 2. Grow the pool in chunks allocated outside the graph lock in
> lockdep_register_key(). That removes the bound without a fallback,
> but it is the allocation Boqun preferred to avoid.
>
> For what it's worth, keys whose locks are ever taken already count
> against MAX_LOCKDEP_KEYS (8K classes), and the default pool is 16K, so
> what the cap adds is a limit on keys that never get a class.
>
Yeah, I think if everyone call lockdep_init_map_type() right after
lockdep_register_key(), MAX_LOCKDEP_KEYS will be reached to the limit
before MAX_LOCKDEP_DYNAMIC_KEYS. So technically it's not a new
limitation. Honestly you can just make MAX_LOCKDEP_DYNAMIC_KEYS = 2 *
MAX_LOCKDEP_KEYS (i.e. without introducing a Kconfig), "2 *" is needed
because a key can be in-between lockdep_register_key() and
lockdep_init_map_type() and pending_free can be delayed, so "2 *"
provides a buffer for when active key numbers > class numbers.
It might be worth checking whether a lockdep_register_key() is always
followed by a some sort of lockdep_init_map_type() in the kernel code
base.
Regards,
Boqun
> Boqun, would you prefer (1), so that the cap can never turn lockdep off?
>
> Thanks,
> Vlad
prev parent reply other threads:[~2026-10-26 14:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 11:56 Vlad Poenaru
2026-10-22 3:01 ` Bart Van Assche
2026-10-23 12:19 ` Vlad Poenaru
2026-10-26 14:07 ` Boqun Feng [this message]
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=at9eq_3YUIL1ACEK@tardis.local \
--to=boqun@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=bvanassche@acm.org \
--cc=dcaratti@redhat.com \
--cc=edumazet@kernel.org \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=vlad.wing@gmail.com \
--cc=will@kernel.org \
/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
all inboxes | Powered by JetHome®