The i variable is used to count the number of stack frames printed, but it is initialized to 0 only at the beginning of the loop, and is not increased later in the loop. Therefore, the value of i is always 0, resulting in the condition if (i > 40) never being true. To ensure that i counts correctly, you need to increase the value of i each time the stack frame is successfully printed. Signed-off-by: liujing <liujing@xxxxxxxxxxxxxxxxxxxx> diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c index 6afae65e9a8b..65c44756f949 100644 --- a/arch/alpha/kernel/traps.c +++ b/arch/alpha/kernel/traps.c @@ -100,6 +100,7 @@ dik_show_trace(unsigned long *sp, const char *loglvl) if (!is_kernel_text(tmp)) continue; printk("%s[<%lx>] %pSR\n", loglvl, tmp, (void *)tmp); + i++; if (i > 40) { printk("%s ...", loglvl); break; -- 2.27.0