Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752547AbcCVRUE (ORCPT ); Tue, 22 Mar 2016 13:20:04 -0400 Received: from mail-db3on0095.outbound.protection.outlook.com ([157.55.234.95]:33312 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751297AbcCVRT7 (ORCPT ); Tue, 22 Mar 2016 13:19:59 -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" , Russell King , Thomas Gleixner , Aaron Tomlin , Ingo Molnar , Andrew Morton , Daniel Thompson , , CC: Chris Metcalf Subject: [PATCH v3 2/4] nmi_backtrace: do a local dump_stack() instead of a self-NMI Date: Tue, 22 Mar 2016 13:19:37 -0400 Message-ID: <1458667179-19630-3-git-send-email-cmetcalf@mellanox.com> X-Mailer: git-send-email 2.7.2 In-Reply-To: <1458667179-19630-1-git-send-email-cmetcalf@mellanox.com> References: <1458667179-19630-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)(76176999)(50986999)(36756003)(86362001)(85426001)(50466002)(48376002)(42186005)(33646002)(105606002)(4326007)(106466001)(229853001)(189998001)(2906002)(1096002)(107886002)(586003)(1220700001)(5001770100001)(5001970100001)(104016004)(11100500001)(2201001)(4001430100002)(2950100001)(87936001)(50226001)(960300001)(19580395003)(92566002)(47776003)(19580405001)(5008740100001)(6806005)(921003)(1121003)(83996005);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR05MB1692;H:ld-1.internal.tilera.com;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;AM1FFO11FD015;1:sb7TAi45/WmtCE1q+SelOt+YzlJFisEKzUYLRrUy9LbZzbucu1GzKO1gn+ORPW+E3kSdgMrhBFFq7HiAzCV8BpTyjbUg7Dg+KJ8BAyYAl8qB4Fjn/j5DPFTQmU3zKHMS/O/RD/4q/IIbK9UXBvuS1p6ZOCReG7i429oc7y61SAEQ17AgHEtovb5d6Wu2+yGLLd2ktBCP/Ndnkaxgsdt5JaN5ZRhEhQL6fnzIESGMCVVu1BhFV0UJ7WrZbKryPCLqX3Dc2WEU/vi3zMpDlMxpXyBb6su0KMqdnrcO7FPZaWjVdSoxiZTVLWiG7WPz/E9jk9oWdXdFkUpUPb+OHiP3JHwAEBE/HN0HwCUJFzC5ygHKiQE3kIMEEK/042Mw1Ljt1pJZhVy6QvjgOYPiz4iv1fY8IYh+shGXocf03lcOantcgQ6OsJHCTgvyt6DbVRazxGTlO5RFbJYeivDvo/qPA3s5nce9FY1mUPiHSUF78e/SX7PY4upKyHICR9RO4sOfF5vvWoemnG98nAJlgqujm4uVaQ2tJjdTSg+pAzmoW4jR7JriFRi85ip+MVd9Pjxy MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 4ee4e941-a6b1-49c8-a1c7-08d352762faf X-Microsoft-Exchange-Diagnostics: 1;HE1PR05MB1692;2:tqLd01K8kTvkB+iWk32ulf3Z14NX6SUtGVVAfp1bGvh7ykHaK1eWVYY9lOdUZ8RWfP4SCgPOc3/gLMpbSt8Pgnk8V8d7+DZ/7tf0gwBwn7IQ4zQayekvRkdZGxv347LvEVlWxUcyR79IfbAmI7y2tjR2q2tTzYq4i2RbcoSKpIYmZFjwSZfbrp7JgZO7HYWw;3:BJq40yq+00RzE52NasGiRSfH1c8EPDZbRsjZi7KICNCTMCzdGZTVtHNuOzzPTvZa5Yk7ORsSpgk4XdFGbZa6ldmpdOTfXpdDQqp6vUDKQYDXoF9S+1Yd2Ali4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xNtBDJgGS+1pvgmGKEF4ZM5TT+tzraaFP/onpIhrk70tDKNP6IYKsv1v3sErfZELAZS/MnhhZFEih324lCWgRIFJUpGiOPwMMrsbhyhUsblT40uOxlZKW043BIpipvhwEMMRyE8BWa+m/gdWm/Wv1GWKM5dnho5+GuwRCi4I4tgsz20q6DdmtiiV6ErLn6WF+MbT7NtfuAD7wqtygZPREYD6pMZ1YJxhorWr2VLb5WI9czRN9SLgRSN9h1LPm24/8K/2EBZ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(13023025)(13024025)(13015025)(13017025)(5005006)(13018025)(8121501046)(3002001)(10201501046);SRVR:HE1PR05MB1692;BCL:0;PCL:0;RULEID:;SRVR:HE1PR05MB1692; X-Microsoft-Exchange-Diagnostics: 1;HE1PR05MB1692;4:6/xxjJCJAR0iWvAQjxDY/pOI/HvvJ9gzppRRbJnPyhyUAl4jQ7s2wUga8yq66TcWeKFxbdzf4Jq5ktw5GCtZNDTmzChA3AdoC49cyOwsdomD4X8lRpKQtXW+3eDYyNwVCO1sIuvLvSLzU0QkoNOU5WUUNTcbfBW2OJc/t9rOXq83TK9Iia4n6ypdkwqHMFGKnf/c/95tYoTXGY2c1wFXI+QrEeGI1gKz/nuyYC4ylE3cIwq0QPHQ5yZkd1kI/hn9VceIh6O2Kwm9rUu+4J/rUU/YiMSbwPrsPnMQox/pb6EmoO1Eqj7BULXNQVBxMksN1pU6U5fzKa4WcTop1hHEitJGuLuPa2F6bSwMPaOomM2gKup3clPf5csq6Qbk9x3gcVhf4/lA7v755lifn4rSlLt+fUrnj47MXDhucgMbjz/hKog5My7an9E5wm752V3c1o4TjxP/tk+RhgJJUqIiIQ== X-Forefront-PRVS: 08897B549D X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;HE1PR05MB1692;23:67Fuv1EvWdihOyVKFTNcn5fRjOx/6SktJvKGq04Vy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3kvVoBogsl8v7TFM76OBdiYJ?= =?us-ascii?Q?hjTasv+bX8oF6pvaybKDp2HLgFTBx/QGzzV6HZSVO3/Ee0Zi5tZNF0CHOjBo?= =?us-ascii?Q?QlyXPhOkrKX422g4D7dg7KVxBZbBFwuYxdq8YgfTfsuIziYcssn2U85yWeSm?= =?us-ascii?Q?cnE14ghDjl1Zo/JEegIvOngZHvXhuCmPTeAHd6qxA1IzBcWsES5EiNYD19xG?= =?us-ascii?Q?k/QaGqI5LYQLfBidzKIdcqQ+1vqzSOt3LtiiW9EPB7g/Jffqh1Ynw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;HE1PR05MB1692;5:cluSIPvk+Z8IRaZd06/LWBM12ePdLkmBCt4pFxIdhg1wG55KtVIARPxCHEZY4Ek4ObC/GDPpwcf4+E/tO/vw5jODE7dOpu7oyRRYvs9kn1XW+ZWN2CEMudfIhQEqNThjduc8OvQHlyj/w99HWEfE5w==;24:TkNvVW1wsZdP4rdfh7ViD4gYLv9Fqo/K+/jzCHW4CmMRVYbvbXCWn4C8sjip++MUPDzNkTuxv5UviNAA4uLtx+geAxBuv8wCcbsFRgJ22fU= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2016 17:19:54.4817 (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 208125658e56..26a9ac6bc616 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