[PATCH v3 0/8] locking/lockdep: Reuse zapped chain_hlocks entries

From: Waiman Long
Date: Wed Jan 15 2020 - 16:43:37 EST


v3:
- Move the bug fix patches to the beginning of the series.
- Include a number of changes as suggested by PeterZ.
- Increase MAX_CHAIN_BUCKETS from 8 to 10 to reduce the chance of using
the unsized list.
- Add patch 7 to add a lockdep_early_init() call.
- Add patch 8 to allocate chain hlocks by splitting large chain block
as a last resort.

v2:
- Revamp the chain_hlocks reuse patch to store the freed chain_hlocks
information in the chain_hlocks entries themselves avoiding the
need of a separate set of tracking structures. This, however,
requires a minimum allocation size of at least 2. Thanks to PeterZ
for his review and inspiring this change.
- Remove the leakage counter as it is no longer applicable.
- Add patch 6 to make the output of /proc/lockdep_chains more readable.

It was found that when running a workload that kept on adding lock
classes and then zapping them repetitively, the system will eventually
run out of chain_hlocks[] entries even though there were still plenty
of other lockdep data buffers available.

[ 4318.443670] BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!
[ 4318.444809] turning off the locking correctness validator.

In order to fix this problem, we have to make chain_hlocks[] entries
reusable just like other lockdep arrays. Besides that, the patchset
also adds some zapped class and chain_hlocks counters to be tracked by
/proc/lockdep_stats. It also fixes leakage in the irq context counters
and makes the output of /proc/lockdep_chains more readable.

Waiman Long (8):
locking/lockdep: Decrement irq context counters when removing lock
chain
locking/lockdep: Display irq_context names in /proc/lockdep_chains
locking/lockdep: Track number of zapped classes
locking/lockdep: Throw away all lock chains with zapped class
locking/lockdep: Track number of zapped lock chains
locking/lockdep: Reuse freed chain_hlocks entries
locking/lockdep: Add lockdep_early_init() before any lock is taken
locking/lockdep: Enable chain block splitting as last resort

include/linux/lockdep.h | 2 +
init/main.c | 1 +
kernel/locking/lockdep.c | 373 ++++++++++++++++++++++++-----
kernel/locking/lockdep_internals.h | 15 +-
kernel/locking/lockdep_proc.c | 25 +-
5 files changed, 351 insertions(+), 65 deletions(-)

--
2.18.1