From patchwork Mon Sep 14 09:18:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 7174121 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 7D3E89F380 for ; Mon, 14 Sep 2015 09:21:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A322120602 for ; Mon, 14 Sep 2015 09:21:57 +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 7B575205FD for ; Mon, 14 Sep 2015 09:21:56 +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 1ZbPuf-0004h5-Mb; Mon, 14 Sep 2015 09:19:01 +0000 Received: from mail-wi0-f181.google.com ([209.85.212.181]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZbPud-0004d5-B3 for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2015 09:19:00 +0000 Received: by wicfx3 with SMTP id fx3so123900935wic.0 for ; Mon, 14 Sep 2015 02:18:37 -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; bh=C+mYpgQfkaxPemHI28SQQYyipW3hqQL3zYJ3Ab04ewk=; b=bMrFTBAHuytU/0XH0KJo1aYUA2/sKsLngGp9R63+teaKwvZeJe34X3tdJseUayT4Xc Mf65dR19N12WFzVit5uW79Mt808jn8+xqAq5JKUK4tj/sHiHJ9ZOktwkqitPodyq843d M+CG56lTR6Ng/xyLeWB61sF2Wy6kdhbPpCDV5L8SNgJX9WG4y1vDKinkLQad91XnGJ0b vwVvKl0cPMslhMIP0nE0xsp5+G8Jxy45SY6VpfQDZztViz7WSLOQoCa+ut3UBIBExRMA AHNHfwzUYaX32R22ZVA0lD261pd8xw2tfMzqHwFiSiRGIWgH/bibm//2B6LLrhQA3xJP WgJQ== X-Gm-Message-State: ALoCoQnHbbTyiKhaf6zgZOvHOIHngBCScipUVJQklQ0noV9lL73rixUBN4fXhRXhVmcczQ8eqSZD X-Received: by 10.194.111.232 with SMTP id il8mr26206122wjb.117.1442222317070; Mon, 14 Sep 2015 02:18:37 -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 f17sm14456711wjn.38.2015.09.14.02.18.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2015 02:18:36 -0700 (PDT) From: Daniel Thompson To: Russell King Subject: [PATCH] arm: Fix backtrace generation when IPI is masked Date: Mon, 14 Sep 2015 10:18:14 +0100 Message-Id: <1442222294-2756-1-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.4.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150914_021859_621583_EEA45A00 X-CRM114-Status: GOOD ( 15.35 ) X-Spam-Score: -0.1 (/) 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, 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=-1.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, SUSPICIOUS_RECIPS,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=no 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. Some small changes to the generic code are required to support this. Signed-off-by: Daniel Thompson --- 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));