From patchwork Tue Apr 5 17:26:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Metcalf X-Patchwork-Id: 8753731 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 18285C0553 for ; Tue, 5 Apr 2016 17:29:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2F0472038E for ; Tue, 5 Apr 2016 17:29:25 +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 3613F20351 for ; Tue, 5 Apr 2016 17:29:24 +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 1anUla-0008QD-VU; Tue, 05 Apr 2016 17:27:50 +0000 Received: from mail-db5eur01on0054.outbound.protection.outlook.com ([104.47.2.54] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1anUlC-00086V-HJ for linux-arm-kernel@lists.infradead.org; Tue, 05 Apr 2016 17:27:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=FF65cOBOxrlCJLdn73DDqvPMXTZ4I3DzATsrCotkfsI=; b=sJsxDZHwV9LnsZK4RjHk7KKXkSzra6nOa1T21C4AFi1t3QNZ1Ip4ZWgfbHrozuvrnHXSrsAk+/kiIUnkR4T/VkVolkSN2egzuOu/79Ul+BT+4VbGw2qyhGyy+mFtA673cQ8Q0PxxIK2p8nDJQD+x6PhuFXA5MhlBvCr1C8cNyyc= Received: from AMXPR05CA0049.eurprd05.prod.outlook.com (10.242.9.177) by VI1PR05MB1693.eurprd05.prod.outlook.com (10.165.235.155) with Microsoft SMTP Server (TLS) id 15.1.447.15; Tue, 5 Apr 2016 17:27:03 +0000 Received: from DB3FFO11FD055.protection.gbl (2a01:111:f400:7e04::118) by AMXPR05CA0049.outlook.office365.com (2a01:111:e400:803c::49) with Microsoft SMTP Server (TLS) id 15.1.447.15 via Frontend Transport; Tue, 5 Apr 2016 17:27:03 +0000 Authentication-Results: spf=fail (sender IP is 12.216.194.146) smtp.mailfrom=ezchip.com; mellanox.com; dkim=none (message not signed) header.d=none; mellanox.com; dmarc=fail action=none header.from=mellanox.com; Received-SPF: Fail (protection.outlook.com: domain of ezchip.com does not designate 12.216.194.146 as permitted sender) receiver=protection.outlook.com; client-ip=12.216.194.146; helo=ld-1.internal.tilera.com; Received: from ld-1.internal.tilera.com (12.216.194.146) by DB3FFO11FD055.mail.protection.outlook.com (10.47.217.127) with Microsoft SMTP Server (TLS) id 15.1.453.6 via Frontend Transport; Tue, 5 Apr 2016 17:27:02 +0000 Received: (from cmetcalf@localhost) by ld-1.internal.tilera.com (8.14.4/8.14.4/Submit) id u35HR1Fm015175; Tue, 5 Apr 2016 13:27:01 -0400 From: Chris Metcalf To: Peter Zijlstra , "Rafael J. Wysocki" , Petr Mladek , Russell King , Thomas Gleixner , Aaron Tomlin , Ingo Molnar , Andrew Morton , Daniel Thompson , , Subject: [PATCH v5 2/4] nmi_backtrace: do a local dump_stack() instead of a self-NMI Date: Tue, 5 Apr 2016 13:26:46 -0400 Message-ID: <1459877208-15119-3-git-send-email-cmetcalf@mellanox.com> X-Mailer: git-send-email 2.7.2 In-Reply-To: <1459877208-15119-1-git-send-email-cmetcalf@mellanox.com> References: <1459877208-15119-1-git-send-email-cmetcalf@mellanox.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:12.216.194.146; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(5008740100001)(105606002)(48376002)(2201001)(85426001)(92566002)(50466002)(36756003)(6806005)(960300001)(33646002)(104016004)(2950100001)(86362001)(42186005)(2906002)(4326007)(229853001)(586003)(1096002)(1220700001)(5001770100001)(11100500001)(87936001)(5001970100001)(189998001)(4001430100002)(76176999)(47776003)(107886002)(19580395003)(19580405001)(50226001)(106466001)(5003940100001)(50986999)(921003)(83996005)(2101003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB1693; H:ld-1.internal.tilera.com; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD055; 1:3csMIUDhkzKv0P6O6K+om3SfiSncJOgGQFUydIZCxEm9y4m2LpBGMeTLDrSFCeJ6vHgPKpuE8EVDoIyk0F7Zv0PJiF+Zlw4cMF48oWUjE7f19S1XeWp8GzoRJgYEqAXyuAnNb0RkeL9D0FdzIkAfhx61v2GH8Nn/yV905NOwJ/xr/Jwc48F2ZlGW3dZQAjZfLzwRcTq3jpXERWm9NhZsDFm+qRHt5hN/mFT5bVKse7dJJ+FTfzsU7bgrCBq6fEQLMm72lxwQqAD8RkzVJvLCv0yma4snbBYUNx+vM4xIXHNxVCiUP7ySNZHxj4etJpBnxo7cv6TJ713UF0dzxM7UszOTzCr3kq10YNdsyO+AgiTaW6NNC4bqF1RL8r26621PMDshjNCb2CbaAsW79GkQeOa01l+3tJT6nbx9hZ9TPTmvaGlqjE7IMb/CyocbvUfUs2M2juqQ1jEglVj2TPLHVrsYWE6nyg1zD8FJ5IwSW/ted5R3AiZSF/jSdPX4zu5RR+ZLzp72AbHyVRytXCqtVy2lMUrUqRp9NnmSCwJ0EovQx82c+PxrmT5Jq9MelYDqXwjN5kn9whoa6paGA7j+6kWD4prMrLNU+pHosL0KNGNOWZF5QmKL7Ra1WMtIuURF MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 5f8481ec-f395-49da-c1d5-08d35d7780d9 X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB1693; 2:clCaBpNWI2iOE/jKa6FpEbqwTXu5pPvIVPAFL1HKszHOc0ZOmvC+ov4T658TafhAHfAI2RL7m5Zy2oq7Y5DXla6q6/yR5ip5YYRN00lQX3h01nRhWZtkkDSCegITGrhJXiMPL9iNT70ioRnl+no4beZDPbfJJbPta/H4qRknRecrxxikOc3MJ5yIRKdJ//EX; 3:U9pGgZOY3d2qbXGL57zZJTGLSxiLIAazAXMDbq98LwsD+RxB20PqRjDA/MFOY6lezoUP8g/s1tmW6htKfnw3Wz0QJDDMfd/Pu1fJ0kGgMZNd8oo6KY3Rw0TJw1AT5pfJPiWqyquZYMBFaSrGh4htCnmui93auD0EPsKEFKt2ySokCeldC4RsvlRdQFkaExzOqFwpExTZTTnL5kxobFdwEuyayr0korqtSB/6oK+TGgU= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VI1PR05MB1693; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB1693; 25:7KHIRHrbjuRe2vGAOdUFSDgax7QwbioQDMoNTl/n3A4WLa73BCnIo/8Xs+YX0ZNkkYCOgpV15MpMo9WpVQpImKyjuDcJzrdt093xqskz5ij7a0gEpseF23BwXLCmnECIzUeIthg3fiX6KixfpqpMMuoBAqp7AZrNwY0m71yNNB8QPqh0VAr50jvudKAKU/t/jBNyY0qY+oS/86GeHQ56dFzBOGC/ew6CnlOYc27kUuVRZIGqvjh/xaS5yHXfIaud5Ib0cTFIgK6u3aB15TudVIBq1m9k9UV+1uGbxLyOR3i3x6Sg27mfkVcEUqU+98ypkekkQ9+4BR0EQCvEHFGyRpHSIW306xP25Sg1MR1KNgRuG7OSvkNwuFeCVc9AUCnxD4KJn0jz5kW0AJrU1tQR5b/dllHNEujcyGF6MxPqwwocEy3JuQdW8uswprebgAb3FLwiPMhwRvkwOrTsDZdfpJ8kBX9MleF4wKmCLkZUqh59NzpKonOgjFEDoLsZ9XjCPeMqKjFDxrzIauEH7oSaWJlXq9ghjHTqbV365NHpbBEyWIRhdyytuPohgoKIqcWFBNvcEfVpv9VKz0NONIDbtAlQIyYYcJVNgwS601jFGIDhLEvpairjPW4zQDBKk3Y8423e+RHfqNb/QMosHv/5dDqIdtHB9mUVpUVFOHDrbTilPVHEfoOQqXuaVJvcJbNN X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB1693; 20:1El/C+dbFgYcsHCZ6L7HhKBDSk3UAU1n7nzAhD/GImVnYubf/D1IBeKhauJOXmfubKjn+wuYbKV3yo2VTIkxTUP8/BkdvBDlqmBg6JUqtNhbJvor2BHRMW7U7aEnMkq8tI96zmNIMeh78NLrFzPZxffXhiRtW4fgtiu+vmtdyJB47LHLQZGpp/DIaFKCy1AIRnbBTHYR5ozTWBeRiey0cHJqwX2GbS2dd6d13ujA8pO7ENp1gsIPDyW3flzd0Sgo7QT3HeAuUWOVplpViU18t93Prl+v34YEzHa+0PJd26crc/x3iXhf3oL+Km9Ydm8l87b6QRmtIEembekJ3zF9njUq3rzPLat4huCmHM1WukkLMYuPVJHbblb2besBTIaObxbjxcgm8/l42OOvBxYKXDWEKwlWM9Y78EAeRjqHNQNP696Xavu9vLD50HyE0hIaBEkt8J+jdRlpnNBpGaJMg7BnuJ5FCvQNp2diw5ZYvpDgxjZ/+Urgrk4Uy5oe5XJt X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(13015025)(13023025)(13024025)(8121501046)(13018025)(13017025)(10201501046)(3002001); SRVR:VI1PR05MB1693; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB1693; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB1693; 4:HK2VvzVOykZjIcnHkPr7JDk4D4Of52B+5w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jcvGrtL2FxYWi6jBFxfByd+RzE4CoKocToN+DRxDMr35kc+e/LSTVpPkDhrzD5MGtxB+D6YJUuzykEkQRwuXxn9Q==; 24:G6ZD+IaUf8yUbMdOMYYUlPHowoIzNjlI3qw9kLs3LGvkUx/UX8wLBAtYV7PhZYro02ZdI5t8IWKJNfjycOExFM+fpvy6KvAD7mlqT1hqcUA= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2016 17:27:02.5974 (UTC) X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a652971c-7d2e-4d9b-a6a4-d149256f461b; Ip=[12.216.194.146]; Helo=[ld-1.internal.tilera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB1693 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160405_102727_119810_D8C26921 X-CRM114-Status: GOOD ( 14.66 ) X-Spam-Score: -2.0 (--) 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: Chris Metcalf Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID, 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 there is code that checks whether it should call dump_stack() explicitly, to avoid trying to raise an NMI when the current context is not preemptible by the backtrace IPI. Similarly, the forthcoming arch/tile support uses an IPI mechanism that does not support generating an NMI to self. Accordingly, move the code that guards this case into the generic mechanism, and invoke it unconditionally whenever we want a backtrace of the current cpu. It seems plausible that in all cases, dump_stack() will generate better information than generating a stack from the NMI handler. The register state will be missing, but that state is likely not particularly helpful in any case. Or, if we think it is helpful, we should be capturing and emitting the current register state in all cases when regs == NULL is passed to nmi_cpu_backtrace(). Signed-off-by: Chris Metcalf Acked-by: Aaron Tomlin --- arch/arm/kernel/smp.c | 9 --------- lib/nmi_backtrace.c | 9 +++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 72ad8485993a..07223f2a3ee0 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -746,15 +746,6 @@ 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. Note - * that nmi_cpu_backtrace() automatically removes the current cpu - * from mask. - */ - 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 db63ac75eba0..9375c0279b73 100644 --- a/lib/nmi_backtrace.c +++ b/lib/nmi_backtrace.c @@ -76,6 +76,15 @@ void nmi_trigger_cpumask_backtrace(const cpumask_t *mask, seq_buf_init(&s->seq, s->buffer, NMI_BUF_SIZE); } + /* + * Don't try to send an NMI to this cpu; it may work on some + * architectures, but on others it may not, and we'll get + * information at least as useful just by doing a dump_stack() here. + * Note that nmi_cpu_backtrace(NULL) will clear the cpu bit. + */ + if (cpumask_test_cpu(this_cpu, to_cpumask(backtrace_mask))) + nmi_cpu_backtrace(NULL); + if (!cpumask_empty(to_cpumask(backtrace_mask))) { pr_info("Sending NMI from CPU %d to CPUs %*pbl:\n", this_cpu, nr_cpumask_bits, to_cpumask(backtrace_mask));