Skip to contentSkip to conversation

lockdep: pass curr_inner to print_lock_invalid_wait_context

PATCH In review Chen Jun 2 participants 3 messages Jun 16, 2022 – Jun 20, 2022 Locking primitives

lore
Share & tools
lore

Chen Jun

author
#0 lore raw

PATCH 1/1 lockdep: pass curr_inner to print_lock_invalid_wait_context

Same information (task_wait_context(curr)) is printed twice. curr_inner in check_wait_context is what we need.

---
 kernel/locking/lockdep.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
kernel/locking/lockdep.c +3 -7
index 81e87280513e..2eb9802df7b9 100644
@@ -4676,10 +4676,8 @@ static inline short task_wait_context(struct task_struct *curr)
 
 static int
 print_lock_invalid_wait_context(struct task_struct *curr,
-				struct held_lock *hlock)
+				struct held_lock *hlock, short curr_inner)
 {
-	short curr_inner;
-
 	if (!debug_locks_off())
 		return 0;
 	if (debug_locks_silent)
@@ -4695,9 +4693,7 @@ print_lock_invalid_wait_context(struct task_struct *curr,
 	print_lock(hlock);
 
 	pr_warn("other info that might help us debug this:\n");
-
-	curr_inner = task_wait_context(curr);
-	pr_warn("context-{%d:%d}\n", curr_inner, curr_inner);
+	pr_warn("context-{%d:%d}\n", curr_inner, task_wait_context(curr));
 
 	lockdep_print_held_locks(curr);
 
@@ -4763,7 +4759,7 @@ static int check_wait_context(struct task_struct *curr, struct held_lock *next)
 	}
 
 	if (next_outer > curr_inner)
-		return print_lock_invalid_wait_context(curr, next);
+		return print_lock_invalid_wait_context(curr, next, curr_inner);
 
 	return 0;
 }
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 1 line · Chen Jun

Same information (task_wait_context(curr)) is printed twice.

Yes, because at that point the inner and outer context are the same.

Quoted 1 line

curr_inner in check_wait_context is what we need.

IIRC it simply prints the task_wait_context as a starting point, the lockdep_print_held_locks() should include the contexts for each of those, after which you can compute the resulting value.

IOW, the information is complete.

#2 lore raw
Quoted 5 lines · Peter Zijlstra
Quoted 1 line · Chen Jun

Same information (task_wait_context(curr)) is printed twice.

Yes, because at that point the inner and outer context are the same.

Quoted 10 lines
Quoted 1 line

curr_inner in check_wait_context is what we need.

IIRC it simply prints the task_wait_context as a starting point, the lockdep_print_held_locks() should include the contexts for each of those, after which you can compute the resulting value.

IOW, the information is complete.

Thanks for pointing this out.

Signature · 2 lines
Regards
Chen Jun