From patchwork Wed Mar 16 17:02:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Metcalf X-Patchwork-Id: 8602841 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 CA6F0C0553 for ; Wed, 16 Mar 2016 17:12:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DCB7B20149 for ; Wed, 16 Mar 2016 17:12:29 +0000 (UTC) Received: from bombadil.infradead.org (unknown [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 EE688202E6 for ; Wed, 16 Mar 2016 17:12:28 +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 1agEr4-0006ad-Dr; Wed, 16 Mar 2016 17:03:30 +0000 Received: from mail-am1on0066.outbound.protection.outlook.com ([157.56.112.66] helo=emea01-am1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1agEqa-0006Li-Ja for linux-arm-kernel@lists.infradead.org; Wed, 16 Mar 2016 17:03:06 +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=+AekgeqcJk5YS7d2VcUueK63fpkOhhT48BOUqPZAsdI=; b=GvqX0GEvA/U6vwt7wOo3FFh6E1ovt0VXR9vFQO3tHvNaWE/c3c2ANpn1vMApPmU/dlJSrbSKeLxodO9mL8oYaUV2ULSWLSUB9kXhXOVpRVVXZVbFymaVXKUalinBp74RbnkYE4cVVkYskhXpZG2n5VKhVMGLRxhlAr9yBbxtoCI= Received: from DB3PR05CA0047.eurprd05.prod.outlook.com (10.160.41.175) by AM4PR05MB1684.eurprd05.prod.outlook.com (10.165.246.7) with Microsoft SMTP Server (TLS) id 15.1.434.16; Wed, 16 Mar 2016 17:02:35 +0000 Received: from AM1FFO11FD024.protection.gbl (2a01:111:f400:7e00::182) by DB3PR05CA0047.outlook.office365.com (2a01:111:e400:9428::47) with Microsoft SMTP Server (TLS) id 15.1.434.16 via Frontend Transport; Wed, 16 Mar 2016 17:02:35 +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 AM1FFO11FD024.mail.protection.outlook.com (10.174.64.213) with Microsoft SMTP Server (TLS) id 15.1.434.11 via Frontend Transport; Wed, 16 Mar 2016 17:02:35 +0000 Received: (from cmetcalf@localhost) by ld-1.internal.tilera.com (8.14.4/8.14.4/Submit) id u2GH2XqY029387; Wed, 16 Mar 2016 13:02:33 -0400 From: Chris Metcalf To: Peter Zijlstra , Russell King , Thomas Gleixner , Aaron Tomlin , Ingo Molnar , Andrew Morton , Daniel Thompson , , Subject: [PATCH v2 2/4] nmi_backtrace: do a local dump_stack() instead of a self-NMI Date: Wed, 16 Mar 2016 13:02:11 -0400 Message-ID: <1458147733-29338-3-git-send-email-cmetcalf@mellanox.com> X-Mailer: git-send-email 2.7.2 In-Reply-To: <1458147733-29338-1-git-send-email-cmetcalf@mellanox.com> References: <1458147733-29338-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)(1110001)(1109001)(339900001)(199003)(189002)(33646002)(50986999)(87936001)(2950100001)(47776003)(1096002)(42186005)(48376002)(189998001)(36756003)(2906002)(1220700001)(5008740100001)(76176999)(106466001)(50466002)(107886002)(105606002)(2201001)(4326007)(5001770100001)(92566002)(85426001)(19580395003)(586003)(960300001)(5003940100001)(6806005)(104016004)(5001970100001)(229853001)(86362001)(19580405001)(11100500001)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB1684; H:ld-1.internal.tilera.com; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11FD024; 1:g2LEwo1GSSzuVZ7nchcLFNCfPhDrjKa/KYWo4E9yDpTYyqCObdVXL+rqfXgH0GFOuqnkVQ+k9bqLVnO8pXGpT1pjCBlmxkSqzR4D7ZvkjDz7jU/tQ1Y+mT1VEM/dEA2HUiOX0C8PNz0g7rct3UhdHO+cKk9j7vDjlBcQpYJF5Fp7KVwTcMkUnOeeFICeXpCHjsfgb62v5j3aG0Ax3SC+PwBRGBriPgAR4J2bwYddC/TLKMgdznGuwkictHuDrBH1EU+amgDZT1IiaptYDgksw9lwH0Fsw78+qlGcafaxnJYkiyrRCc6O69dxdw68m1A19l6Sxvlvg8fcKlzVTCtlr+kQbnDLn9mGgyBgVIj1r3xWkrgmpNwqo1afpEqxdIkLfKvuF0eVHiSm+kF11il09903W60R2HRCfH2VBeQb2a6wKzsqFwjqhzF8CXz2d8Gd8mFsBThkUcnNJImIpzvFgoRRS4ksqCkCvkz8nNGBj/AhtditZTeiiTzc8fC8D97TQuLIrW3iLo0yR2wWFjZBKgmnugpqGtGC+yVuzi5rnLM= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: bf1e46f5-163e-42bc-971f-08d34dbcc5aa X-Microsoft-Exchange-Diagnostics: 1; AM4PR05MB1684; 2:VI2spLtQQLhByghnfa88/hRVIt3VRg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HRop+L55uZ77Iet9Xii8eY/zgBCrmZGOfOS1XO5yP0Pk/YOsTR/m4uPDhh1flbBj/bRrsHENWapPQ8caFW3HzaTL2lhmvsNwGzdBo+5ByTPRnwnf3aQ79OuM0snMGJlrBo4ucLxswoB9JKHarCgSUaaYFLkw1E2JQmgbeljHrKsomTIQFOnsUq9Uz7K6SWGqRqQYD8i+gBNmT+fP+j+IDToR5oRRgbrh3XHTvlTTXLrmfDaqtrhKIZlPkZFp/nW26yaQeBI4uaUiuTTb3pOoSU8CZd4ZrY/g83KspJfJL5LwdUeZG X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(13018025)(13023025)(5005006)(13015025)(13017025)(13024025)(3002001)(10201501046); SRVR:AM4PR05MB1684; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB1684; X-Microsoft-Exchange-Diagnostics: 1; AM4PR05MB1684; 4:+JGic4fLnxbnnS9z2Nf5+n0OMMOXfKza0bcBETK4nybeP72Wus/XQKN/mwVzqX5mSbRvObAavoBLPAhYFcUhZaqWmwK6JeBsg7RS/YP2fUBczMANkUQxY5YzcK83u/b4qRkTYauXTgBrFVQs3AvpkTYkpgSQTFc9nV3iB4zfGiwTw+sdouG1OfMb71t2tgTkqTMW0Ann/D/77QCgrP4LZC0we3F/9E4FYVmtygHkhlAHLTLf3X/mwbgIK8BhT8dkjuxW26jd5cC9veYCWEjCrQbdDxQ7pZGyTP2D9h4Se5nFXAWv9SOn5iUlUvxOgAk8xpY7zbmKN71fAHwWFLvC2xwMbQuLeSqTT1Ye0VCpC6CaEORYTdSaPllkKth8ObA6l+Ru3SzplWr0+eXTVa8hgj56VaCO8G24rA6WfML1rCmWQRoL96tC0yRxUVQIIrbSEzZiAc4796kXYQ2jdegeFg== X-Forefront-PRVS: 08831F51DC X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR05MB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Shk0zPw7vALlc91S?= =?us-ascii?Q?eqUFV4Lu1YLgXIK1QyMRG65X1SoeFWlQSS50Kv7GQXM7x86E0OmnpBI89d8N?= =?us-ascii?Q?EjxagkAJ35DRZW0KWPqkbNkaUG/U9N8Ia06JJQ4Sw3rVjaPXNQuUj+ITqbAY?= =?us-ascii?Q?3Cj5LXBCToT9S4yTnGAnC2zDV9fK6nERZSQzcxyigIafUpwFIJYAKBxloVfY?= =?us-ascii?Q?2iARcOtjxdNIkv3lhp3xOjHv55ZKLgGuDGPJG7gyHVl10LG06ENKmkieKzE6?= =?us-ascii?Q?zReZkiOyU0=3D?= X-Microsoft-Exchange-Diagnostics: 1; AM4PR05MB1684; 5:A/nn0JLdAmfrCs2OWOzEl4TxXgczm3t+jxfd52+cO6G9cbL2JMhAlZAu+VuN6FsHCGAcvT2uXhgycRj+PW4YLxA/wQTX9pzxi6dmv4hA+2otSETQgF89fujPvpqKMxQAp0EFT/IifnOyQdRuFeln7Q==; 24:FOmNvXBRoqeohmV2kVi4cPre/TFINSbEhVepMt6XobCFzrU0D0Lmy32FqHVyDld2PGgrIoHq0OMTKB7B4TjLwxEb/u7W0AiuJZgo9ICqsUs= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Mar 2016 17:02:35.0641 (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: AM4PR05MB1684 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160316_100301_465155_159B5921 X-CRM114-Status: GOOD ( 15.35 ) 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=-3.3 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, RDNS_NONE, 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 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));