diff options
author | Yuyang Du <duyuyang@gmail.com> | 2019-05-06 04:19:24 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2019-06-03 05:55:43 -0400 |
commit | f6ec8829ac9d59b637366c13038f15d6f6156fe1 (patch) | |
tree | 66564bff3b185212908d1c4c164d0304af2d9f12 /kernel/locking | |
parent | e196e479a3b844da6e6e71e0d2a8694040cb4e52 (diff) |
locking/lockdep: Define INITIAL_CHAIN_KEY for chain keys to start with
Chain keys are computed using Jenkins hash function, which needs an initial
hash to start with. Dedicate a macro to make this clear and configurable. A
later patch changes this initial chain key.
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-9-duyuyang@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/locking')
-rw-r--r-- | kernel/locking/lockdep.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index b7d9c28ecf3b..9edf6f12b711 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c | |||
@@ -362,7 +362,7 @@ static inline u64 iterate_chain_key(u64 key, u32 idx) | |||
362 | void lockdep_init_task(struct task_struct *task) | 362 | void lockdep_init_task(struct task_struct *task) |
363 | { | 363 | { |
364 | task->lockdep_depth = 0; /* no locks held yet */ | 364 | task->lockdep_depth = 0; /* no locks held yet */ |
365 | task->curr_chain_key = 0; | 365 | task->curr_chain_key = INITIAL_CHAIN_KEY; |
366 | task->lockdep_recursion = 0; | 366 | task->lockdep_recursion = 0; |
367 | } | 367 | } |
368 | 368 | ||
@@ -857,7 +857,7 @@ static u16 chain_hlocks[MAX_LOCKDEP_CHAIN_HLOCKS]; | |||
857 | static bool check_lock_chain_key(struct lock_chain *chain) | 857 | static bool check_lock_chain_key(struct lock_chain *chain) |
858 | { | 858 | { |
859 | #ifdef CONFIG_PROVE_LOCKING | 859 | #ifdef CONFIG_PROVE_LOCKING |
860 | u64 chain_key = 0; | 860 | u64 chain_key = INITIAL_CHAIN_KEY; |
861 | int i; | 861 | int i; |
862 | 862 | ||
863 | for (i = chain->base; i < chain->base + chain->depth; i++) | 863 | for (i = chain->base; i < chain->base + chain->depth; i++) |
@@ -2524,7 +2524,7 @@ static void | |||
2524 | print_chain_keys_held_locks(struct task_struct *curr, struct held_lock *hlock_next) | 2524 | print_chain_keys_held_locks(struct task_struct *curr, struct held_lock *hlock_next) |
2525 | { | 2525 | { |
2526 | struct held_lock *hlock; | 2526 | struct held_lock *hlock; |
2527 | u64 chain_key = 0; | 2527 | u64 chain_key = INITIAL_CHAIN_KEY; |
2528 | int depth = curr->lockdep_depth; | 2528 | int depth = curr->lockdep_depth; |
2529 | int i = get_first_held_lock(curr, hlock_next); | 2529 | int i = get_first_held_lock(curr, hlock_next); |
2530 | 2530 | ||
@@ -2544,7 +2544,7 @@ print_chain_keys_held_locks(struct task_struct *curr, struct held_lock *hlock_ne | |||
2544 | static void print_chain_keys_chain(struct lock_chain *chain) | 2544 | static void print_chain_keys_chain(struct lock_chain *chain) |
2545 | { | 2545 | { |
2546 | int i; | 2546 | int i; |
2547 | u64 chain_key = 0; | 2547 | u64 chain_key = INITIAL_CHAIN_KEY; |
2548 | int class_id; | 2548 | int class_id; |
2549 | 2549 | ||
2550 | printk("depth: %u\n", chain->depth); | 2550 | printk("depth: %u\n", chain->depth); |
@@ -2848,7 +2848,7 @@ static void check_chain_key(struct task_struct *curr) | |||
2848 | #ifdef CONFIG_DEBUG_LOCKDEP | 2848 | #ifdef CONFIG_DEBUG_LOCKDEP |
2849 | struct held_lock *hlock, *prev_hlock = NULL; | 2849 | struct held_lock *hlock, *prev_hlock = NULL; |
2850 | unsigned int i; | 2850 | unsigned int i; |
2851 | u64 chain_key = 0; | 2851 | u64 chain_key = INITIAL_CHAIN_KEY; |
2852 | 2852 | ||
2853 | for (i = 0; i < curr->lockdep_depth; i++) { | 2853 | for (i = 0; i < curr->lockdep_depth; i++) { |
2854 | hlock = curr->held_locks + i; | 2854 | hlock = curr->held_locks + i; |
@@ -2872,7 +2872,7 @@ static void check_chain_key(struct task_struct *curr) | |||
2872 | 2872 | ||
2873 | if (prev_hlock && (prev_hlock->irq_context != | 2873 | if (prev_hlock && (prev_hlock->irq_context != |
2874 | hlock->irq_context)) | 2874 | hlock->irq_context)) |
2875 | chain_key = 0; | 2875 | chain_key = INITIAL_CHAIN_KEY; |
2876 | chain_key = iterate_chain_key(chain_key, hlock->class_idx); | 2876 | chain_key = iterate_chain_key(chain_key, hlock->class_idx); |
2877 | prev_hlock = hlock; | 2877 | prev_hlock = hlock; |
2878 | } | 2878 | } |
@@ -3787,14 +3787,14 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, | |||
3787 | /* | 3787 | /* |
3788 | * How can we have a chain hash when we ain't got no keys?! | 3788 | * How can we have a chain hash when we ain't got no keys?! |
3789 | */ | 3789 | */ |
3790 | if (DEBUG_LOCKS_WARN_ON(chain_key != 0)) | 3790 | if (DEBUG_LOCKS_WARN_ON(chain_key != INITIAL_CHAIN_KEY)) |
3791 | return 0; | 3791 | return 0; |
3792 | chain_head = 1; | 3792 | chain_head = 1; |
3793 | } | 3793 | } |
3794 | 3794 | ||
3795 | hlock->prev_chain_key = chain_key; | 3795 | hlock->prev_chain_key = chain_key; |
3796 | if (separate_irq_context(curr, hlock)) { | 3796 | if (separate_irq_context(curr, hlock)) { |
3797 | chain_key = 0; | 3797 | chain_key = INITIAL_CHAIN_KEY; |
3798 | chain_head = 1; | 3798 | chain_head = 1; |
3799 | } | 3799 | } |
3800 | chain_key = iterate_chain_key(chain_key, class_idx); | 3800 | chain_key = iterate_chain_key(chain_key, class_idx); |
@@ -4636,7 +4636,7 @@ static void remove_class_from_lock_chain(struct pending_free *pf, | |||
4636 | return; | 4636 | return; |
4637 | 4637 | ||
4638 | recalc: | 4638 | recalc: |
4639 | chain_key = 0; | 4639 | chain_key = INITIAL_CHAIN_KEY; |
4640 | for (i = chain->base; i < chain->base + chain->depth; i++) | 4640 | for (i = chain->base; i < chain->base + chain->depth; i++) |
4641 | chain_key = iterate_chain_key(chain_key, chain_hlocks[i] + 1); | 4641 | chain_key = iterate_chain_key(chain_key, chain_hlocks[i] + 1); |
4642 | if (chain->depth && chain->chain_key == chain_key) | 4642 | if (chain->depth && chain->chain_key == chain_key) |