lockdep: Fix nr_unused_locks accounting

Chris reported that commit 24d5a3bffef1 ("lockdep: Fix
usage_traceoverflow") breaks the nr_unused_locks validation code
triggered by /proc/lockdep_stats.

By fully splitting LOCK_USED and LOCK_USED_READ it becomes a bad
indicator for accounting nr_unused_locks; simplyfy by using any first
bit.

Fixes: 24d5a3bffef1 ("lockdep: Fix usage_traceoverflow")
Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://lkml.kernel.org/r/20201027124834.GL2628@hirez.programming.kicks-ass.net

Changed files
+4 -10
kernel
locking
+4 -10
kernel/locking/lockdep.c
··· 4396 4396 if (unlikely(hlock_class(this)->usage_mask & new_mask)) 4397 4397 goto unlock; 4398 4398 4399 + if (!hlock_class(this)->usage_mask) 4400 + debug_atomic_dec(nr_unused_locks); 4401 + 4399 4402 hlock_class(this)->usage_mask |= new_mask; 4400 4403 4401 4404 if (new_bit < LOCK_TRACE_STATES) { ··· 4406 4403 return 0; 4407 4404 } 4408 4405 4409 - switch (new_bit) { 4410 - case 0 ... LOCK_USED-1: 4406 + if (new_bit < LOCK_USED) { 4411 4407 ret = mark_lock_irq(curr, this, new_bit); 4412 4408 if (!ret) 4413 4409 return 0; 4414 - break; 4415 - 4416 - case LOCK_USED: 4417 - debug_atomic_dec(nr_unused_locks); 4418 - break; 4419 - 4420 - default: 4421 - break; 4422 4410 } 4423 4411 4424 4412 unlock: