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: 53540 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id 39D342056A for ; Mon, 14 Sep 2015 09:18:39 +0000 (UTC) Received: by wicuu12 with SMTP id uu12sf38894988wic.2 for ; Mon, 14 Sep 2015 02:18:38 -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:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=C+mYpgQfkaxPemHI28SQQYyipW3hqQL3zYJ3Ab04ewk=; b=emDar2QvmU4DpFgUpgsOIpnOXC4lJ6m9t0QO9aiGQpqdnokvTAlsgqN2zvW5oOkd6+ 99+FwEwUHdpHGVP0RunltbRbtY7gja/EUZXiDA7uuHM6D9UeWOYbEhHndHDWyWEwzIya KpOB/49RsGVzl9gFKJE0dCkvVtPKqn41ATbMl195XyzJTQRw00aVJD5ZAr8u1Ob+R5bC AhOg++jjITnw1uouso6BIbwkpNO+hjN5TkVIrQmvMa7a2PXyYU0NQ/FHSbwNoB4U1WsG r0cOLPMJC5BgoR/L3hg3Gpyr7F70GpfDCja7Zw0W+woZO+O3ij0iYloL3twAyrFiHUvs xxhg== X-Gm-Message-State: ALoCoQk5c4HW9TJXoKUsdJLLkb4Qw/duqdPAWKw8LSoYIMjtda+E/mfqIWmkfI6Tmw8LygNxWVT8 X-Received: by 10.112.89.228 with SMTP id br4mr2808600lbb.3.1442222318478; Mon, 14 Sep 2015 02:18:38 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.129 with SMTP id 1ls488567lau.58.gmail; Mon, 14 Sep 2015 02:18:38 -0700 (PDT) X-Received: by 10.152.120.234 with SMTP id lf10mr12698686lab.28.1442222318334; Mon, 14 Sep 2015 02:18:38 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id qd10si9089849lbb.77.2015.09.14.02.18.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2015 02:18:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by lagj9 with SMTP id j9so83663240lag.2 for ; Mon, 14 Sep 2015 02:18:38 -0700 (PDT) X-Received: by 10.152.22.133 with SMTP id d5mr12531186laf.112.1442222318243; Mon, 14 Sep 2015 02:18:38 -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 w3csp1079277lbq; Mon, 14 Sep 2015 02:18:37 -0700 (PDT) X-Received: by 10.181.13.102 with SMTP id ex6mr24160181wid.64.1442222317483; Mon, 14 Sep 2015 02:18:37 -0700 (PDT) Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com. [209.85.212.171]) by mx.google.com with ESMTPS id u9si17333503wjx.196.2015.09.14.02.18.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2015 02:18:37 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.212.171 as permitted sender) client-ip=209.85.212.171; Received: by wiclk2 with SMTP id lk2so124257798wic.1 for ; Mon, 14 Sep 2015 02:18:37 -0700 (PDT) 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 Cc: Daniel Thompson , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, patches@linaro.org, linaro-kernel@lists.linaro.org, Thomas Gleixner 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-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.50 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. 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));