Skip to contentSkip to conversation

m68k: Fix backtraces for non-running tasks

PATCH In review Karl Mehltretter 2 participants 2 messages Jul 23 – Aug 10 m68k architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68k: Fix backtraces for non-running tasks

When no stack pointer is supplied, show_stack() starts at thread.esp0. This is the saved userspace register frame, not where a task was switched out. For kernel threads it points to the zeroed frame created by copy_thread(), so sched_show_task() prints no useful backtrace.

Use thread.ksp for non-current tasks. It is saved by switch_to() and is already used by __get_wchan(). For current, start at the current stack frame, as is already done when no task is supplied.

Tested on qemu-system-m68k -M virt using SysRq-t. All task dumps contained resolved frames.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Assisted-by Claude:claude-opus-4-8

---

arch/m68k/kernel/traps.c +2 -2
index d2f25e8895e5..60759ba3cbd4 100644
@@ -936,8 +936,8 @@ void show_stack(struct task_struct *task, unsigned long *stack,
 	int i;
 
 	if (!stack) {
-		if (task)
-			stack = (unsigned long *)task->thread.esp0;
+		if (task && task != current)
+			stack = (unsigned long *)task->thread.ksp;
 		else
 			stack = (unsigned long *)&stack;
 	}
maintainer Reviewed-by Tested-by on v1 1/1
#1 lore raw

Hi Karl,

Quoted 9 lines · Karl Mehltretter

When no stack pointer is supplied, show_stack() starts at thread.esp0. This is the saved userspace register frame, not where a task was switched out. For kernel threads it points to the zeroed frame created by copy_thread(), so sched_show_task() prints no useful backtrace.

Use thread.ksp for non-current tasks. It is saved by switch_to() and is already used by __get_wchan(). For current, start at the current stack frame, as is already done when no task is supplied.

Quoted 6 lines

Tested on qemu-system-m68k -M virt using SysRq-t. All task dumps contained resolved frames.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Assisted-by Claude:claude-opus-4-8

Thanks, LGTM, and does make all SysRq-t dumps look sensible, so

i.e. will queue in the m68k tree for v7.3.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds