[PATCH v3 04/30] locking/lockdep: Pass lock chain from validate_chain() to check_prev_add()

From: Yuyang Du
Date: Fri Jun 28 2019 - 05:16:04 EST


The pointer of lock chains is passed all the way from validate_chain()
to check_prev_add(). This is aimed for a later effort to associate lock
chains to lock dependencies.

No functional change.

Signed-off-by: Yuyang Du <duyuyang@xxxxxxxxx>
---
kernel/locking/lockdep.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index d545b6c..f171c6e 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -2370,7 +2370,8 @@ static inline void inc_chains(void)
*/
static int
check_prev_add(struct task_struct *curr, struct held_lock *prev,
- struct held_lock *next, int distance, struct lock_trace *trace)
+ struct held_lock *next, int distance, struct lock_trace *trace,
+ struct lock_chain *chain)
{
struct lock_list *entry;
int ret;
@@ -2475,7 +2476,8 @@ static inline void inc_chains(void)
* the end of this context's lock-chain - whichever comes first.
*/
static int
-check_prevs_add(struct task_struct *curr, struct held_lock *next)
+check_prevs_add(struct task_struct *curr, struct held_lock *next,
+ struct lock_chain *chain)
{
struct lock_trace trace = { .nr_entries = 0 };
int depth = curr->lockdep_depth;
@@ -2506,7 +2508,7 @@ static inline void inc_chains(void)
*/
if (hlock->read != 2 && hlock->check) {
int ret = check_prev_add(curr, hlock, next, distance,
- &trace);
+ &trace, chain);
if (!ret)
return 0;

@@ -2846,6 +2848,7 @@ static int validate_chain(struct task_struct *curr,
struct held_lock *hlock,
int chain_head, u64 chain_key)
{
+ struct lock_chain *chain;
/*
* Trylock needs to maintain the stack of held locks, but it
* does not add new dependencies, because trylock can be done
@@ -2857,7 +2860,7 @@ static int validate_chain(struct task_struct *curr,
* graph_lock for us)
*/
if (!hlock->trylock && hlock->check &&
- lookup_chain_cache_add(curr, hlock, chain_key)) {
+ (chain = lookup_chain_cache_add(curr, hlock, chain_key))) {
/*
* Check whether last held lock:
*
@@ -2892,7 +2895,7 @@ static int validate_chain(struct task_struct *curr,
* of the chain, and if it's not a secondary read-lock:
*/
if (!chain_head && ret != 2) {
- if (!check_prevs_add(curr, hlock))
+ if (!check_prevs_add(curr, hlock, chain))
return 0;
}

--
1.8.3.1