[tip: locking/urgent] locking/lockdep: Fix inverted "on"/"last" CPU label in lockdep_print_held_locks()
From: tip-bot2 for Zhuangzhuang Wang
Date: Fri Nov 06 2026 - 05:21:31 EST
The following commit has been merged into the locking/urgent branch of tip:
Commit-ID: aa63c0df79920f6abe1b66e1f8b6443ad2d62d0e
Gitweb: https://git.kernel.org/tip/aa63c0df79920f6abe1b66e1f8b6443ad2d62d0e
Author: Zhuangzhuang Wang <3050681779@xxxxxx>
AuthorDate: Fri, 30 Oct 2026 07:07:27
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitterDate: Fri, 06 Nov 2026 11:16:04 +01:00
locking/lockdep: Fix inverted "on"/"last" CPU label in lockdep_print_held_locks()
Commit 051f5d223dfc ("lockdep: Enable the printing of held locks of
remote running tasks and print task CPU") added the task's CPU to the
"locks held by" line. As the comment above the printk() describes, a
running task should be reported as "on CPU#N" and a task that is not
running as "last CPU#N". The ternary has the two strings swapped, so
the labels are inverted.
Swap the strings so the output matches the comment.
Fixes: 051f5d223dfc ("lockdep: Enable the printing of held locks of remote running tasks and print task CPU")
Signed-off-by: Zhuangzhuang Wang <3050681779@xxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Link: https://patch.msgid.link/20261030-lockdep-fix-cpu-label-v1-1-96875c74b15b@xxxxxx
---
kernel/locking/lockdep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index c3dc84a..fdae495 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -811,7 +811,7 @@ static void lockdep_print_held_locks(struct task_struct *p)
*/
printk("locks held by %s/%d: %d, %s CPU#%d%s\n",
p->comm, task_pid_nr(p), depth,
- task_is_running(p) ? "last" : "on", task_cpu(p),
+ task_is_running(p) ? "on" : "last", task_cpu(p),
depth > 0 ? ":" : "");
for (i = 0; i < depth; i++) {