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: 8265861 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 360699F6DA for ; Tue, 9 Feb 2016 21:51:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 574742022A for ; Tue, 9 Feb 2016 21:51:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 776A72020F for ; Tue, 9 Feb 2016 21:51:18 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aTG9x-0008PU-Qj; Tue, 09 Feb 2016 21:49:21 +0000 Received: from mail-pa0-x236.google.com ([2607:f8b0:400e:c03::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aTG9u-0008NS-ME for linux-arm-kernel@lists.infradead.org; Tue, 09 Feb 2016 21:49:19 +0000 Received: by mail-pa0-x236.google.com with SMTP id kp3so328200pab.1 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=lgYwmf4Kgng5Zw4j8JOxtAsEX7bAMMYdKmxSyUyMlyxCWd/hd7gDM2p/yGrp2/8ntk bEkdG0OUKtfc7TOAllqUH2D6lhNYnm60mH1c2zO+FIBUMQVfGM48TlMqz9yS1nwUnQSl DE6YZbay2JSnPNVnZzbaEUUAFoRSsuDIbkECQWDUotHsTOt1iGdbGws+IKYEbYfYEl8U wwKGIIa6XgJWIuv11bEAGtdlSl5KO19t/wOSXGjLcCRxIOKAva4aeDJTxUTxBwq9+QJT W0avFNVajAGR8qi6Mpo/eseGtGIKZSbpEDDlqIOsY+L8EpxXQ7fxUIk22O7UtlINthKg ULtQ== X-Gm-Message-State: AG10YOQInQ6gP2dDjvfxBFoFbNKqoJ/vVdJ4LkrGnPERIdT1MCYkE/drTAUauWSu3WBj9zAh 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160209_134918_864019_A41EB3F4 X-CRM114-Status: GOOD ( 11.03 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yang.shi@linaro.org, linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);