From mboxrd@z Thu Jan 1 00:00:00 1970 From: yang.shi@linaro.org (Yang Shi) Date: Tue, 9 Feb 2016 13:26:22 -0800 Subject: [PATCH] arm64: use raw_smp_processor_id in stack backtrace dump Message-ID: <1455053182-31404-1-git-send-email-yang.shi@linaro.org> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org dump_backtrace may be called in kthread context, which is not bound to a single cpu, i.e. khungtaskd, then calling smp_processor_id may trigger the below bug report: BUG: using smp_processor_id() in preemptible [00000000] code: khungtaskd/71 caller is debug_smp_processor_id+0x1c/0x28 CPU: 3 PID: 71 Comm: khungtaskd Not tainted 4.5.0-rc1 #144 Hardware name: Freescale Layerscape 2085a RDB Board (DT) Call trace: [] dump_backtrace+0x0/0x290 [] show_stack+0x24/0x30 [] dump_stack+0x8c/0xd8 [] check_preemption_disabled+0x184/0x188 [] debug_smp_processor_id+0x1c/0x28 [] dump_backtrace+0x84/0x290 [] show_stack+0x24/0x30 [] sched_show_task+0x16c/0x280 [] watchdog+0x560/0x708 [] kthread+0x1b0/0x1d0 [] ret_from_fork+0x10/0x40 Replace it to raw version to prevent from the race condition. Signed-off-by: Yang Shi --- arch/arm64/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index cbedd72..9abe236 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -146,7 +146,7 @@ static void dump_instr(const char *lvl, struct pt_regs *regs) static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) { struct stackframe frame; - unsigned long irq_stack_ptr = IRQ_STACK_PTR(smp_processor_id()); + unsigned long irq_stack_ptr = IRQ_STACK_PTR(raw_smp_processor_id()); int skip; pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk); -- 2.0.2