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: 53635 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id 4C91422A22 for ; Tue, 15 Sep 2015 11:05:36 +0000 (UTC) Received: by lbbti1 with SMTP id ti1sf55828000lbb.3 for ; Tue, 15 Sep 2015 04:05:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=F66wKI1fInRtNbMEq5h/3zL9crH+n6+BAKStBsK0Q/I=; b=FoK0bsM1kfJheQvO61D5ZHn765DIF0LPziQstX7zzB3Gg/BcmTKOtbeD4S96XAqdQj B/4vUeV+0j6ENQLTtxKHDf2/Q0N0XMjiTrljxneqDeRReV4CorxkwXpvv4ghb+SXTqVO NLm5laEe3P2mghT6LSEVY1SnuJ0X5c8jL9PzSeyIbdRsVl7dOuy8mjhN1Nk8Dt/wVVDh Bf4SQ6of2vrYufD8pxc+fbYs+mIDgaq2q2oj31k91QzZBBNF41P8/lpwpxl7f3JYPjdv h1dNnWOq/B5H8hE8HxNZUyrq2kKp7W4igPf9AWS41zsgQnzn+LPWJsTfY8/BLvOrjKRg mSGA== X-Gm-Message-State: ALoCoQmYhTXCnPHHgRJmTDlUv2XkyLeKth0wuQ3QCyARzTKi0BqSOIpLUEwK/SfArJXMCbs6r85W X-Received: by 10.152.9.36 with SMTP id w4mr1604076laa.7.1442315135242; Tue, 15 Sep 2015 04:05:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.138 with SMTP id y10ls146725laj.35.gmail; Tue, 15 Sep 2015 04:05:35 -0700 (PDT) X-Received: by 10.112.161.232 with SMTP id xv8mr17772222lbb.7.1442315135083; Tue, 15 Sep 2015 04:05:35 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id dy8si12949698lbb.55.2015.09.15.04.05.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2015 04:05:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by lagj9 with SMTP id j9so106306704lag.2 for ; Tue, 15 Sep 2015 04:05:34 -0700 (PDT) X-Received: by 10.112.146.104 with SMTP id tb8mr18004672lbb.35.1442315134646; Tue, 15 Sep 2015 04:05:34 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1725396lbq; Tue, 15 Sep 2015 04:05:33 -0700 (PDT) X-Received: by 10.180.105.234 with SMTP id gp10mr5807855wib.51.1442315133886; Tue, 15 Sep 2015 04:05:33 -0700 (PDT) Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com. [209.85.212.170]) by mx.google.com with ESMTPS id kf6si25066710wjb.11.2015.09.15.04.05.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2015 04:05:33 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.212.170 as permitted sender) client-ip=209.85.212.170; Received: by wicfx3 with SMTP id fx3so23155977wic.1 for ; Tue, 15 Sep 2015 04:05:33 -0700 (PDT) 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 Cc: Daniel Thompson , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, patches@linaro.org, linaro-kernel@lists.linaro.org, Thomas Gleixner , Hillf Danton 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.thompson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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));