From patchwork Wed Mar 30 17:16:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Metcalf X-Patchwork-Id: 8701701 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 8BAA3C0553 for ; Wed, 30 Mar 2016 17:21:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A4A8E20376 for ; Wed, 30 Mar 2016 17:21:22 +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 2333B20374 for ; Wed, 30 Mar 2016 17:21:17 +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 1alJmH-0007rQ-Gk; Wed, 30 Mar 2016 17:19:33 +0000 Received: from mail-am1on0079.outbound.protection.outlook.com ([157.56.112.79] helo=emea01-am1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1alJjv-00060K-17 for linux-arm-kernel@lists.infradead.org; Wed, 30 Mar 2016 17:17:14 +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=Ab3cAJnonkm91m8fb0z0oxcxeGnZXtfU9/acCBeyCX/yuz8GMHRU/wCvnKcIWyK3fE7tG5+cmjxYZMK8nBcxzlomv+uerzyKsMKC7/Xtr1ilSDvNrR3wOnoO2A/EbOJ6UX21owNKC4PIappxNHeEMyNlamQjvNJkvZemu2RVLKE= Received: from AM4PR0501CA0033.eurprd05.prod.outlook.com (10.167.83.171) by HE1PR05MB1692.eurprd05.prod.outlook.com (10.169.119.158) with Microsoft SMTP Server (TLS) id 15.1.447.15; Wed, 30 Mar 2016 17:16:32 +0000 Received: from AM1FFO11FD034.protection.gbl (2a01:111:f400:7e00::140) by AM4PR0501CA0033.outlook.office365.com (2603:10a6:200:6::43) with Microsoft SMTP Server (TLS) id 15.1.447.15 via Frontend Transport; Wed, 30 Mar 2016 17:16:31 +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 AM1FFO11FD034.mail.protection.outlook.com (10.174.64.223) with Microsoft SMTP Server (TLS) id 15.1.453.6 via Frontend Transport; Wed, 30 Mar 2016 17:16:31 +0000 Received: (from cmetcalf@localhost) by ld-1.internal.tilera.com (8.14.4/8.14.4/Submit) id u2UHGUCx027794; Wed, 30 Mar 2016 13:16:30 -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 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 X-MS-Office365-Filtering-Correlation-Id: 33cb7e38-aec4-47ee-ba01-08d358bf09f3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9bLShxwdZ2y8UckH9a/gDmZU7h1yaAAClaefc4D8u62L9dLH6ifQ4ZdeEFY+X2LAMk9MJ/82N9Illhz+3unZy1fwR+M26zUw8SBmk7IyrN7r1RqOhXPBjCQbPQ43IjOxfLNstxUwS6sVndOUIV5yoHK5Tv0Ie6UDbG+tMApzX2jPzvRA8ZTgjCW8tVLGxsj19tPzxa7XqIIF0bwiPTeKv2667q+pLMvPhHtqJiv3i1ENXjrM6Q7aA5KBVSusyEZ2yNJIPHkxWS2rtrds3dbUTx4C0osYPdL0saO86P1kCQ5kNPrll4pZd7y7Ttqe72NRCLffJ5FF1KkXFDiz+npzRjxsQB7ojbPvlezJS0d6QNKOHWThCQZLkrSH 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?kSfwOXbVlrl+94t/acbzXVPtBhvtwL+uiAFDDSTBlv9f/bg2Fo7jy3p+KLms?= =?us-ascii?Q?TCwMTMa0fsO/cY0SLkFbtbZ46MEmw1s4uH8Dt/uRPjOdrega82vVHbzu6/1+?= =?us-ascii?Q?FCc+OWlijma6mm52cBHUxOxI0M9YFh48jy3fGRLePRlIKNl4BLj7HocH98XX?= =?us-ascii?Q?m0fkTSiS3LF8V3VP0/uFGjYkNLeFfh0Cif7LTjjUUO/ik7hOv2s5rVa4HYSX?= =?us-ascii?Q?OT6C67uIhAR2rcB+fS1geEdf/XHO7IdxUtQ3NanmZW3Fmknl0k9NlI4KMgry?= =?us-ascii?Q?4SgTEY3QdK1PPYqGZtVLjzVH7/f96WMXX+1L2gTKQ5E2KyKuBU3oqxWQuHNh?= =?us-ascii?Q?ZqJwImP4bdlN2exCCjEq+xveu1TphSeig/3iVitiIQ2qgnUh2uaTGxRjjrQB?= =?us-ascii?Q?pZTYfeyOfsbh4yaWkKT0LmI/iZNd8F0PQp41aIAr3MYc2j5bYH/yBUAbu4Xh?= =?us-ascii?Q?4fHkrdUoDjxFvrc/LP5j2byJd99NGUeGejPMvBETGZMQyYhPdDSFKE0WekQ+?= =?us-ascii?Q?4U9HGekltNHD11C2tFKg44nmywsXSso2NIsyUNw7d6b0bf4vR5fU+gFo2Bqj?= =?us-ascii?Q?KI5Ym0OtWDukYP30Dhycn4Oo+BoxEc9Yng0O8sux2fXFpyorkz6Kz6CO6k11?= =?us-ascii?Q?ycsn7m57NRs+ZKtjTO3idUZuWLkoKne5F3dKibOhbjnphnUAD2y6hQ9rSKcr?= =?us-ascii?Q?c+74fUcla7f/auOpzPZRg8cnnt2Zj67+a867aDqFI0UvuBeXdBeVT0NqEDGU?= =?us-ascii?Q?VVjeKfz7CAVp9Y75MCW2baTEfS4YGcZfsPJPE1rEhCU07nH5Dl963g8MpIXx?= =?us-ascii?Q?vkmsD01oMa0bI6rnYpThrLQxC+aiO/7NcoGNM7NDPh00y6W3llGboKsGKn1f?= =?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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160330_101708_188074_90FD148F X-CRM114-Status: GOOD ( 15.08 ) 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 --- 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));