Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932771AbcC3RQl (ORCPT ); Wed, 30 Mar 2016 13:16:41 -0400 Received: from mail-am1on0062.outbound.protection.outlook.com ([157.56.112.62]:28832 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932296AbcC3RQg (ORCPT ); Wed, 30 Mar 2016 13:16:36 -0400 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; From: Chris Metcalf To: Peter Zijlstra , "Rafael J. Wysocki" , Petr Mladek , Russell King , Thomas Gleixner , Aaron Tomlin , Ingo Molnar , Andrew Morton , Daniel Thompson , , CC: Chris Metcalf Subject: [PATCH v4 2/4] nmi_backtrace: do a local dump_stack() instead of a self-NMI Date: Wed, 30 Mar 2016 13:16:08 -0400 Message-ID: <1459358170-27745-3-git-send-email-cmetcalf@mellanox.com> X-Mailer: git-send-email 2.7.2 In-Reply-To: <1459358170-27745-1-git-send-email-cmetcalf@mellanox.com> References: <1459358170-27745-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)(339900001)(189002)(199003)(92566002)(76176999)(50226001)(6806005)(36756003)(107886002)(50986999)(106466001)(19580405001)(86362001)(5008740100001)(5001970100001)(105606002)(5001770100001)(189998001)(229853001)(19580395003)(960300001)(4001430100002)(33646002)(87936001)(104016004)(2201001)(85426001)(2906002)(5003940100001)(50466002)(2950100001)(4326007)(48376002)(42186005)(47776003)(1220700001)(1096002)(11100500001)(586003)(921003)(2101003)(1121003)(83996005);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR05MB1692;H:ld-1.internal.tilera.com;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;AM1FFO11FD034;1:9HKRng0wa7Zihgzy++HO3nU+v1GG+NGBYS89mja7lfcP4/oUbkffWxZSsUQtaTS2RFiirIp0JjydKyOBV6ewfOKiByMyy8dpbebyxXYiOmO4bdyUzD63H4oV1oZjxlPTglpeYLH9nKTcCdh7zFeKvvrOdmpZdtbGcuS0zkUHj1ievld/KXQKoAeHSrFxc/MOjKtf+C7tHmR69vBGPRU1NUvumCCfudK+U7IxSxWmAHJD63PT87P5VWFFB0hiW3PJ5Trubk+5GcnLFjbo92YnC3jZr2vbSh3S+fPQnVv/Fm83kgylAjo+nlrYl2ZTXdUR3nd3QTioznL9/dIHWjqcG3cte1NZ5IjUCSqH4yNCfncK7ZXvrILYjnNEOvp/YSsU67mKPw+3/sh0JvtpWse21HbeFhfrmvMPQfv5G6D8vG90kxNNbh3CTvTvJuIJOkpQso8aJFhoN0YWiFtKzhy7EWO7SyVzNs7/4fO2WJnC6EPF7J3in4h8IGiNgBfTojbAbYhd6QFWc6DkzPnCVnqpytRcHSs9nc0zJXfNsUXY8D3AV6Ed+7vCoJSs3laQ6wVd MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 33cb7e38-aec4-47ee-ba01-08d358bf09f3 X-Microsoft-Exchange-Diagnostics: 1;HE1PR05MB1692;2:RveF8Ur0YNqb+bCAq0x+L25bcTSlaeoFB0HeF1oQijEfn+VtIoA4S/fJwQ36Z5a1r/iYx6aQ45TBbvP/wq3OW8YtKj2h0IMEpDF9IvbjruiyjokJVRnODhGIXBl87OKTL0VH244j5/zrhpjw6fczOEHhEAx+6KNUoRO0obM1B9aQ+DG78KPtLEc+5XA+kpmn;3:e4dp1whEHnqRjrJUVRDdgobiJiIidGx5mGZuA6jXPGVg0pM4L+vPIr6gzQF5i10/byiMcNqpmGjZrFpGy50RbkuPot/hAYwW6fHfecgeGeyJbIeQAbW0+Mnn4f/sb/qTcoK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HWThCQZLkrSH X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(13015025)(13023025)(13017025)(5005006)(13018025)(13024025)(10201501046)(3002001);SRVR:HE1PR05MB1692;BCL:0;PCL:0;RULEID:;SRVR:HE1PR05MB1692; X-Microsoft-Exchange-Diagnostics: 1;HE1PR05MB1692;4:m4YqxavumtQ63hzXQKtTBmj8vh8NcxDBcz+dw+O9SLQdfWyjeeLLlJ9MgN31jHqquCYRs70Yw6Sg77ecg/m2zey31tFCA2mAvKgedmg4AXm02vNe63KIV0swP/fiXirp4J0ZfudGaK6Ku4Nm5JFfHL3G0x0Qtg6tGgjCB7BU2QLwh2lz6TsTj9JFUs67Bl9xCA8qHnF8CIukFFYnYGqy4CqdXsXoy7tZjwVYrQzxMkMhVy8Rhu83bad8pnGh6Dy0IS3kX3kHoEE5S4oe5ffLDKXAWGs8pu+kj5btwh0Ri26GGIraP29ueB6UCkgqG9vuecoCYvze2aFgpDAaXYR1TIb/CWLhbUfA9Z9KGzQkv88f5CqbXdXTa2Z7EjjaH3C2PCoYpiRZtLWTs9PBZKGD6b5WnVmmxtceDc3EDYjxhCOf5fU/NTtIkCOwK1D1i4K1MADHEbAu7euP4Y8PCfN8VQ== X-Forefront-PRVS: 08978A8F5C X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;HE1PR05MB1692;23:bqskxaB5I2gHFXzWxFU60WqF70z7kwOCcJFn+6rTJ?= =?us-ascii?Q?OikmNYK2BHuOaSnU2FuikoifsE6XABqSwKUUU6/ulBCn+hSf+ZXi+mmvwI3J?= =?us-ascii?Q?5fsmHLjoiS/bvKNf6mWd8rBOh2jKdktjD05qe1dXKkWAfexfnyvPxJ3A8Rwx?= =?us-ascii?Q?s6WkWYBw+6XyKMH8eyF5OUyO29o+88vlLARjRsQjaFvD8exGS16ZCMfFKDSV?= =?us-ascii?Q?kSf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llGboKsGKn1f?= =?us-ascii?Q?klAkgL4Eio0PXssQbPl/SKx/mXqH4DpXMz9DKzawvIgOLq5pMI3Bfn9C+UP+?= =?us-ascii?Q?Yb8WzrsKzR7AWBCPAtUBjDB/ucnsaTs5vO9?= X-Microsoft-Exchange-Diagnostics: 1;HE1PR05MB1692;5:7xZGntY/K0xARDWhstnQGwG6LY12Tv3kmhLX80VXwKZ9j6HBpUrEdqmHRXxrT60ibuj512DVf25yFO/atmmZztIq4oYhzdUbMgAwQc+iDbL3ulCiXngWfq4DFO3u3I9frSSSkIj36alO088AjECjhg==;24:WOCL+vceSZ4Hq1TVwJN7hRBmABo6zrwnqx9/fmWnxLHab7gtVtzshiO7eSK3mH2UxjkjVWcRTbsgnCvc5lfSHa1HUxuxyyy3DpLIUnkr/qM= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2016 17:16:31.3969 (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: HE1PR05MB1692 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2492 Lines: 65 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 --- 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)); -- 2.7.2