Commit 1a393408 authored by Peter Zijlstra's avatar Peter Zijlstra

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: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: https://lkml.kernel.org/r/20201027124834.GL2628@hirez.programming.kicks-ass.net
parent d48e3850
...@@ -4396,6 +4396,9 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this, ...@@ -4396,6 +4396,9 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
if (unlikely(hlock_class(this)->usage_mask & new_mask)) if (unlikely(hlock_class(this)->usage_mask & new_mask))
goto unlock; goto unlock;
if (!hlock_class(this)->usage_mask)
debug_atomic_dec(nr_unused_locks);
hlock_class(this)->usage_mask |= new_mask; hlock_class(this)->usage_mask |= new_mask;
if (new_bit < LOCK_TRACE_STATES) { if (new_bit < LOCK_TRACE_STATES) {
...@@ -4403,19 +4406,10 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this, ...@@ -4403,19 +4406,10 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
return 0; return 0;
} }
switch (new_bit) { if (new_bit < LOCK_USED) {
case 0 ... LOCK_USED-1:
ret = mark_lock_irq(curr, this, new_bit); ret = mark_lock_irq(curr, this, new_bit);
if (!ret) if (!ret)
return 0; return 0;
break;
case LOCK_USED:
debug_atomic_dec(nr_unused_locks);
break;
default:
break;
} }
unlock: unlock:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment