summaryrefslogtreecommitdiffstats
path: root/kernel/locking/lockdep.c
diff options
context:
space:
mode:
authorYuyang Du <duyuyang@gmail.com>2019-05-06 04:19:38 -0400
committerIngo Molnar <mingo@kernel.org>2019-06-03 05:55:52 -0400
commit4d56330df22dd9dd9a24f147014f60ee4c914fb8 (patch)
tree6352eba54513bc080ac92046dec3274d9b410f3a /kernel/locking/lockdep.c
parent091806515124b20f8cff7927b4b7ff399483b109 (diff)
locking/lockdep: Adjust new bit cases in mark_lock
The new bit can be any possible lock usage except it is garbage, so the cases in switch can be made simpler. Warn early on if wrong usage bit is passed without taking locks. No functional change. Signed-off-by: Yuyang Du <duyuyang@gmail.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: bvanassche@acm.org Cc: frederic@kernel.org Cc: ming.lei@redhat.com Cc: will.deacon@arm.com Link: https://lkml.kernel.org/r/20190506081939.74287-23-duyuyang@gmail.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/locking/lockdep.c')
-rw-r--r--kernel/locking/lockdep.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 1123e7e6c78d..9c4e2a7547d3 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -3582,6 +3582,11 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
3582{ 3582{
3583 unsigned int new_mask = 1 << new_bit, ret = 1; 3583 unsigned int new_mask = 1 << new_bit, ret = 1;
3584 3584
3585 if (new_bit >= LOCK_USAGE_STATES) {
3586 DEBUG_LOCKS_WARN_ON(1);
3587 return 0;
3588 }
3589
3585 /* 3590 /*
3586 * If already set then do not dirty the cacheline, 3591 * If already set then do not dirty the cacheline,
3587 * nor do any checks: 3592 * nor do any checks:
@@ -3605,25 +3610,13 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
3605 return 0; 3610 return 0;
3606 3611
3607 switch (new_bit) { 3612 switch (new_bit) {
3608#define LOCKDEP_STATE(__STATE) \
3609 case LOCK_USED_IN_##__STATE: \
3610 case LOCK_USED_IN_##__STATE##_READ: \
3611 case LOCK_ENABLED_##__STATE: \
3612 case LOCK_ENABLED_##__STATE##_READ:
3613#include "lockdep_states.h"
3614#undef LOCKDEP_STATE
3615 ret = mark_lock_irq(curr, this, new_bit);
3616 if (!ret)
3617 return 0;
3618 break;
3619 case LOCK_USED: 3613 case LOCK_USED:
3620 debug_atomic_dec(nr_unused_locks); 3614 debug_atomic_dec(nr_unused_locks);
3621 break; 3615 break;
3622 default: 3616 default:
3623 if (!debug_locks_off_graph_unlock()) 3617 ret = mark_lock_irq(curr, this, new_bit);
3618 if (!ret)
3624 return 0; 3619 return 0;
3625 WARN_ON(1);
3626 return 0;
3627 } 3620 }
3628 3621
3629 graph_unlock(); 3622 graph_unlock();