[PATCH] lockdep: Fix inverted "on"/"last" CPU label in lockdep_print_held_locks()

From: Zhuangzhuang Wang via B4 Relay

Date: Fri Oct 30 2026 - 03:09:11 EST


From: Zhuangzhuang Wang <3050681779@xxxxxx>

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>
---
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 c3dc84a7c..fdae495bf 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++) {

---
base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e
change-id: 20261029-lockdep-fix-cpu-label-9ceb572ee274

Best regards,
--
Zhuangzhuang Wang <3050681779@xxxxxx>