Re: [PATCH] locking: lockdep: Decrease nr_unused_locks if lock unused in zap_class()
From: Ingo Molnar
Date: Thu Mar 27 2025 - 03:24:43 EST
* Boqun Feng <boqun.feng@xxxxxxxxx> wrote:
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index b15757e63626..686546d52337 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -6264,6 +6264,9 @@ static void zap_class(struct pending_free *pf, struct lock_class *class)
> hlist_del_rcu(&class->hash_entry);
> WRITE_ONCE(class->key, NULL);
> WRITE_ONCE(class->name, NULL);
> + /* class allocated but not used, -1 in nr_unused_locks */
> + if (class->usage_mask == 0)
> + debug_atomic_dec(nr_unused_locks);
Nit: capitalization in comments should follow the style of the
surrounding code - ie. I did the change below.
Thanks,
Ingo
======================>
kernel/locking/lockdep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 686546d52337..58d78a33ac65 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -6264,7 +6264,7 @@ static void zap_class(struct pending_free *pf, struct lock_class *class)
hlist_del_rcu(&class->hash_entry);
WRITE_ONCE(class->key, NULL);
WRITE_ONCE(class->name, NULL);
- /* class allocated but not used, -1 in nr_unused_locks */
+ /* Class allocated but not used, -1 in nr_unused_locks */
if (class->usage_mask == 0)
debug_atomic_dec(nr_unused_locks);
nr_lock_classes--;