From patchwork Tue Sep 15 11:05:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 7183881 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F158CBEEC1 for ; Tue, 15 Sep 2015 11:07:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 12B5E206F8 for ; Tue, 15 Sep 2015 11:07:51 +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 35ED0206EB for ; Tue, 15 Sep 2015 11:07:49 +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 1Zbo3l-0003bD-I9; Tue, 15 Sep 2015 11:06:01 +0000 Received: from mail-wi0-f172.google.com ([209.85.212.172]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zbo3h-0003Co-U2 for linux-arm-kernel@lists.infradead.org; Tue, 15 Sep 2015 11:05:59 +0000 Received: by wiclk2 with SMTP id lk2so21951638wic.1 for ; Tue, 15 Sep 2015 04:05:33 -0700 (PDT) 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:in-reply-to :references; bh=F66wKI1fInRtNbMEq5h/3zL9crH+n6+BAKStBsK0Q/I=; b=aoqZdah6j60/QTyBC/ePIQmty1viC6KBRXM9LP67lFivuC1tgELTGn7fP87O69RfVk bae8aJft/OH5x6VVxo7CM/fb5QgO1egvSjiDYXk/4QeQhQxb25jmA8DP15IEcTWmjRGU Opmm0wfVj9SQEmL0Q9Jk+ovLDe72DOHz40woIdFc9/IM0bLMUwfGGPgG83/mWKwMpeiT tHYnV5yyFoSCW3bXyj0io+yJJ2PDsEbeCKGZMHD7H6crleAzhODt2B4pEOBKTR5PWrGX B6zx4mxveaFc6IsSjj4E9agJUBykktvn526hWrgJ8fqENu+N2vPEEvwUnzwMc+OpJW5q 9rQQ== X-Gm-Message-State: ALoCoQnOGKvOGrXpxYDk5S1p3x3DKsr7V9JHdrulnguBmfJuxT33oKPVa1YKy7f4DuM1/YhZJiCV X-Received: by 10.194.238.202 with SMTP id vm10mr39867378wjc.96.1442315133551; Tue, 15 Sep 2015 04:05:33 -0700 (PDT) Received: from wychelm.lan (cpc4-aztw19-0-0-cust71.18-1.cable.virginm.net. [82.33.25.72]) by smtp.gmail.com with ESMTPSA id oh5sm8055915wic.11.2015.09.15.04.05.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2015 04:05:32 -0700 (PDT) From: Daniel Thompson To: Russell King Subject: [PATCH v2] arm: Fix backtrace generation when IPI is masked Date: Tue, 15 Sep 2015 12:05:12 +0100 Message-Id: <1442315112-14039-1-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1442222294-2756-1-git-send-email-daniel.thompson@linaro.org> References: <1442222294-2756-1-git-send-email-daniel.thompson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150915_040558_160127_8C00EF50 X-CRM114-Status: GOOD ( 15.57 ) X-Spam-Score: -2.6 (--) 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: Daniel Thompson , linaro-kernel@lists.linaro.org, patches@linaro.org, Hillf Danton , linux-kernel@vger.kernel.org, Thomas Gleixner , 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Currently on ARM when is triggered from an interrupt handler (e.g. a SysRq issued using UART or kbd) the main CPU will wedge for ten seconds with interrupts masked before issuing a backtrace for every CPU except itself. The new backtrace code introduced by commit 96f0e00378d4 ("ARM: add basic support for on-demand backtrace of other CPUs") does not work correctly when run from an interrupt handler because IPI_CPU_BACKTRACE is used to generate the backtrace on all CPUs but cannot preempt the current calling context. This can be fixed by detecting that the calling context cannot be preempted and issuing the backtrace directly in this case. Issuing directly leaves us without any pt_regs to pass to nmi_cpu_backtrace() so we also modify the generic code to call dump_stack() when its argument is NULL. Signed-off-by: Daniel Thompson --- Notes: Changes in v2: * Improved commit message to better describe the changes to the generic code (Hillf Danton). arch/arm/kernel/smp.c | 7 +++++++ lib/nmi_backtrace.c | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) -- 2.4.3 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 48185a773852..4d8a80328c74 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -748,6 +748,13 @@ core_initcall(register_cpufreq_notifier); static void raise_nmi(cpumask_t *mask) { + /* + * Generate the backtrace directly if we are running in a + * calling context that is not preemptible by the backtrace IPI. + */ + if (cpumask_test_cpu(smp_processor_id(), mask) && irqs_disabled()) + nmi_cpu_backtrace(NULL); + smp_cross_call(mask, IPI_CPU_BACKTRACE); } diff --git a/lib/nmi_backtrace.c b/lib/nmi_backtrace.c index 88d3d32e5923..be0466a80d0b 100644 --- a/lib/nmi_backtrace.c +++ b/lib/nmi_backtrace.c @@ -149,7 +149,10 @@ bool nmi_cpu_backtrace(struct pt_regs *regs) /* Replace printk to write into the NMI seq */ this_cpu_write(printk_func, nmi_vprintk); pr_warn("NMI backtrace for cpu %d\n", cpu); - show_regs(regs); + if (regs) + show_regs(regs); + else + dump_stack(); this_cpu_write(printk_func, printk_func_save); cpumask_clear_cpu(cpu, to_cpumask(backtrace_mask));