From patchwork Tue Feb 9 21:26:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 61596 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp2292523lbl; Tue, 9 Feb 2016 13:49:01 -0800 (PST) X-Received: by 10.67.6.1 with SMTP id cq1mr52923409pad.78.1455054541775; Tue, 09 Feb 2016 13:49:01 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c15si16589pfd.225.2016.02.09.13.49.01; Tue, 09 Feb 2016 13:49:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933066AbcBIVs7 (ORCPT + 30 others); Tue, 9 Feb 2016 16:48:59 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:35933 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755214AbcBIVs6 (ORCPT ); Tue, 9 Feb 2016 16:48:58 -0500 Received: by mail-pa0-f46.google.com with SMTP id yy13so279846pab.3 for ; Tue, 09 Feb 2016 13:48:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=B4YxvPLzLlXcHdiDRviCEjEh//nt8/zYVwE+NbcB/3c=; b=FIazFyttDJzMTHKDU7lOulaMKzeoLd+au8RNMqVpyDCKafaF93ErPmhNcqIbiSbzsK gEg/+RMnxr6JRjv0BSoMfZCXAgzVpafPKdDI911J23wxnFu8X30BHW6jd83PrCcbnFwb dZGhBR3C7JPp/EMpprN+G2Z9bL3Nkgaw11vZ8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=B4YxvPLzLlXcHdiDRviCEjEh//nt8/zYVwE+NbcB/3c=; b=nJrwA8oyYJLHKfZceEO8LucAO64PvWrX1caiMi8zuISCOKk96ek84Ah2bQNS4WEwTo 1OmiSf7+iSwB3s+FVAkGwso4sfp1zKZKphiEglMQ+Gjxd6XZQEoQwibjjX08/MbQPVL3 P7gJJPjf1/4EedupxEV48HBy+q4rA6P/BEfSvlufcUqJJej3+wXhHNXF1N4ehAO1VsCj /WpUe47v8M1zgJ9DgPF94kB/MZ6dUW59o1pqPbTke0hiUWrRLntlP44PasvgTfIKrNMa bEq4AxKkDR2bHXHTBbCh6el/SjEqjW+vpCGPzyGkZLEqZo3lebnLA55m8ETfVIvtbUj6 WPzQ== X-Gm-Message-State: AG10YORb8yvsz/4nSeHzp6nqFrOhvrOlp2W6mnSfYKep/qBP10Wtu9l4g7jwqr0g73aJD/W/ X-Received: by 10.67.14.234 with SMTP id fj10mr53190470pad.149.1455054537867; Tue, 09 Feb 2016 13:48:57 -0800 (PST) Received: from yshi-Precision-T5600.corp.ad.wrs.com (unknown-216-82.windriver.com. [147.11.216.82]) by smtp.gmail.com with ESMTPSA id w12sm8731pfa.79.2016.02.09.13.48.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Feb 2016 13:48:56 -0800 (PST) From: Yang Shi To: will.deacon@arm.com, catalin.marinas@arm.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, yang.shi@linaro.org Subject: [PATCH] arm64: use raw_smp_processor_id in stack backtrace dump Date: Tue, 9 Feb 2016 13:26:22 -0800 Message-Id: <1455053182-31404-1-git-send-email-yang.shi@linaro.org> X-Mailer: git-send-email 2.0.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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(-) -- 2.0.2 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);