linux-kernelorg-stable/kernel/locking
Boqun Feng 95f0958240 locking/lockdep: Decrease nr_unused_locks if lock unused in zap_class()
commit 495f53d5cc upstream.

Currently, when a lock class is allocated, nr_unused_locks will be
increased by 1, until it gets used: nr_unused_locks will be decreased by
1 in mark_lock(). However, one scenario is missed: a lock class may be
zapped without even being used once. This could result into a situation
that nr_unused_locks != 0 but no unused lock class is active in the
system, and when `cat /proc/lockdep_stats`, a WARN_ON() will
be triggered in a CONFIG_DEBUG_LOCKDEP=y kernel:

  [...] DEBUG_LOCKS_WARN_ON(debug_atomic_read(nr_unused_locks) != nr_unused)
  [...] WARNING: CPU: 41 PID: 1121 at kernel/locking/lockdep_proc.c:283 lockdep_stats_show+0xba9/0xbd0

And as a result, lockdep will be disabled after this.

Therefore, nr_unused_locks needs to be accounted correctly at
zap_class() time.

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Waiman Long <longman@redhat.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250326180831.510348-1-boqun.feng@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-04-20 10:15:45 +02:00
..
Makefile
irqflag-debug.c
lock_events.c
lock_events.h
lock_events_list.h
lockdep.c locking/lockdep: Decrease nr_unused_locks if lock unused in zap_class() 2025-04-20 10:15:45 +02:00
lockdep_internals.h
lockdep_proc.c locking/lockdep: Simplify character output in seq_line() 2024-08-06 10:46:43 -07:00
lockdep_states.h
locktorture.c locktorture: Add MODULE_DESCRIPTION() 2024-05-30 15:31:45 -07:00
mcs_spinlock.h
mutex-debug.c
mutex.c
mutex.h
osq_lock.c
percpu-rwsem.c
qrwlock.c
qspinlock.c x86/xen: remove deprecated xen_nopvspin boot parameter 2024-07-11 16:33:51 +02:00
qspinlock_paravirt.h locking/pvqspinlock: Correct the type of "old" variable in pv_kick_node() 2024-07-29 12:16:21 +02:00
qspinlock_stat.h
rtmutex.c In the v6.12 scheduler development cycle we had 63 commits from 18 contributors: 2024-09-19 15:55:58 +02:00
rtmutex_api.c
rtmutex_common.h
rwbase_rt.c
rwsem.c Locking changes for v6.12: 2024-09-29 08:51:30 -07:00
semaphore.c locking/semaphore: Use wake_q to wake up processes outside lock critical section 2025-04-10 14:39:31 +02:00
spinlock.c locking/local_lock: Add local nested BH locking infrastructure. 2024-06-24 16:41:22 -07:00
spinlock_debug.c
spinlock_rt.c
test-ww_mutex.c locking/ww_mutex/test: Use swap() macro 2025-02-17 10:04:44 +01:00
ww_mutex.h sched/rt: Rename realtime_{prio, task}() to rt_or_dl_{prio, task}() 2024-08-07 18:32:38 +02:00
ww_rt_mutex.c