Add a macro LOCK_TYPE_NEST for nest lock type and mark the nested lock in check_deadlock_current(). Unlike the other LOCK_TYPE_* enums, this lock type is used only in lockdep.
No functional change. Signed-off-by: Yuyang Du <duyuy...@gmail.com> --- kernel/locking/lockdep.c | 7 +++++-- kernel/locking/lockdep_internals.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index c94c105..417b23d 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -2523,6 +2523,7 @@ static inline void inc_chains(void) * 0: on deadlock detected; * 1: on OK; * 2: LOCK_TYPE_RECURSIVE on recursive read + * 3: LOCK_TYPE_NEST on nest lock */ static int check_deadlock_current(struct task_struct *curr, struct held_lock *next) @@ -2552,7 +2553,7 @@ static inline void inc_chains(void) * nesting behaviour. */ if (nest) - return LOCK_TYPE_RECURSIVE; + return LOCK_TYPE_NEST; print_deadlock_bug(curr, prev, next); return 0; @@ -3127,11 +3128,13 @@ static int validate_chain(struct task_struct *curr, if (!ret) return 0; + /* * Add dependency only if this lock is not the head * of the chain, and if it's not a secondary read-lock: */ - if (!chain_head && ret != LOCK_TYPE_RECURSIVE) { + if (!chain_head && ret != LOCK_TYPE_RECURSIVE && + ret != LOCK_TYPE_NEST) { if (!check_prevs_add(curr, hlock)) return 0; } diff --git a/kernel/locking/lockdep_internals.h b/kernel/locking/lockdep_internals.h index c287bcb..b06c405 100644 --- a/kernel/locking/lockdep_internals.h +++ b/kernel/locking/lockdep_internals.h @@ -28,6 +28,7 @@ enum lock_usage_bit { #define LOCK_TYPE_BITS 16 #define LOCK_TYPE_MASK 0xFFFF +#define LOCK_TYPE_NEST 3 /* * Usage-state bitmasks: -- 1.8.3.1