Messages in this thread Patch in this message | | | From | Yuyang Du <> | Subject | [PATCH v4 09/30] locking/lockdep: Remove chain_head argument in validate_chain() | Date | Thu, 29 Aug 2019 16:31:11 +0800 |
| |
This argument says whether the chain is a head, meaning having just one lock, which can actually be tested by lock_chain->depth. So there is no need to explicitly make this argument, so remove it.
No functional change.
Signed-off-by: Yuyang Du <duyuyang@gmail.com> --- kernel/locking/lockdep.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index de088da..e8ebb64 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -2880,9 +2880,8 @@ static inline struct lock_chain *lookup_chain_cache(u64 chain_key) return add_chain_cache(curr, hlock, chain_key); } -static int validate_chain(struct task_struct *curr, - struct held_lock *hlock, - int chain_head, u64 chain_key) +static int validate_chain(struct task_struct *curr, struct held_lock *hlock, + u64 chain_key) { struct lock_chain *chain; /* @@ -2930,7 +2929,7 @@ static int validate_chain(struct task_struct *curr, * 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 != 2) { + if (chain->depth > 1 && ret != 2) { if (!check_prevs_add(curr, hlock, chain)) return 0; } @@ -2947,7 +2946,7 @@ static int validate_chain(struct task_struct *curr, #else static inline int validate_chain(struct task_struct *curr, struct held_lock *hlock, - int chain_head, u64 chain_key) + u64 chain_key) { return 1; } @@ -3781,7 +3780,6 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, struct lock_class *class = NULL; struct held_lock *hlock; unsigned int depth; - int chain_head = 0; int class_idx; u64 chain_key; @@ -3895,14 +3893,12 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, */ if (DEBUG_LOCKS_WARN_ON(chain_key != INITIAL_CHAIN_KEY)) return 0; - chain_head = 1; } hlock->prev_chain_key = chain_key; - if (separate_irq_context(curr, hlock)) { + if (separate_irq_context(curr, hlock)) chain_key = INITIAL_CHAIN_KEY; - chain_head = 1; - } + chain_key = iterate_chain_key(chain_key, class_idx); if (nest_lock && !__lock_is_held(nest_lock, -1)) { @@ -3915,7 +3911,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, WARN_ON_ONCE(!hlock_class(hlock)->key); } - if (!validate_chain(curr, hlock, chain_head, chain_key)) + if (!validate_chain(curr, hlock, chain_key)) return 0; curr->curr_chain_key = chain_key; -- 1.8.3.1
| |