From patchwork Mon Feb 29 21:40:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Metcalf X-Patchwork-Id: 8458631 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 D7C24C0553 for ; Mon, 29 Feb 2016 21:43:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D6AB72022D for ; Mon, 29 Feb 2016 21:43:10 +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 E878B20221 for ; Mon, 29 Feb 2016 21:43:09 +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 1aaVZS-0004sP-3F; Mon, 29 Feb 2016 21:41:38 +0000 Received: from mail-db5eur01on0049.outbound.protection.outlook.com ([104.47.2.49] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aaVZ0-0004co-8e for linux-arm-kernel@lists.infradead.org; Mon, 29 Feb 2016 21:41:12 +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=xDxqiLJAw+hdOAIag8PV3UchKcxM+1odpkyBfva43dg=; b=f1rhSIi6nEv5sZSkVcKQfmLPIpelXoPeVsjVwLPX2I51M0Kzo1bIQZuayHhlgghiYaFamR33nifVXwSlGsCwEx4NMqDj8saER8JRQA9E9hbVPt+sd6W1uuFvYklmTMg6y368WNhaPx1Rkgbeof6vdIPP86Uqy2qJstF/z+b4lnk= Received: from AMSPR05CA0043.eurprd05.prod.outlook.com (10.242.77.171) by AMSPR05MB421.eurprd05.prod.outlook.com (10.242.224.140) with Microsoft SMTP Server (TLS) id 15.1.415.20; Mon, 29 Feb 2016 21:40:47 +0000 Received: from DB3FFO11FD035.protection.gbl (2a01:111:f400:7e04::173) by AMSPR05CA0043.outlook.office365.com (2a01:111:e400:8000::43) with Microsoft SMTP Server (TLS) id 15.1.415.20 via Frontend Transport; Mon, 29 Feb 2016 21:40:46 +0000 Authentication-Results: spf=fail (sender IP is 12.216.194.146) smtp.mailfrom=ezchip.com; ezchip.com; dkim=none (message not signed) header.d=none; ezchip.com; dmarc=none action=none header.from=ezchip.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=lab-41.internal.tilera.com; Received: from lab-41.internal.tilera.com (12.216.194.146) by DB3FFO11FD035.mail.protection.outlook.com (10.47.217.66) with Microsoft SMTP Server (TLS) id 15.1.422.5 via Frontend Transport; Mon, 29 Feb 2016 21:40:45 +0000 Received: (from cmetcalf@localhost) by lab-41.internal.tilera.com (8.14.4/8.14.4/Submit) id u1TLeiCU007168; Mon, 29 Feb 2016 16:40:44 -0500 From: Chris Metcalf To: Russell King , Thomas Gleixner , Aaron Tomlin , Ingo Molnar , Andrew Morton , Daniel Thompson , , Subject: [PATCH 3/4] nmi_backtrace: do a local dump_stack() instead of a self-NMI Date: Mon, 29 Feb 2016 16:40:23 -0500 Message-ID: <1456782024-7122-4-git-send-email-cmetcalf@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1456782024-7122-1-git-send-email-cmetcalf@ezchip.com> References: <1456782024-7122-1-git-send-email-cmetcalf@ezchip.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CPI:12.216.194.146; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(48376002)(4001430100002)(50466002)(33646002)(2906002)(2950100001)(4326007)(189998001)(92566002)(5001970100001)(107886002)(5003940100001)(105606002)(87936001)(85426001)(42186005)(229853001)(81156008)(19580405001)(106466001)(19580395003)(47776003)(586003)(36756003)(76176999)(50986999)(50226001)(2201001)(6806005)(104016004)(1220700001)(1096002)(5001770100001)(5008740100001)(42882005)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:AMSPR05MB421; H:lab-41.internal.tilera.com; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD035; 1:nKJZxtBFjhOrbv+M1Bo+lECXkCKi2N/GzhnUOQhR5Q3Qetu7B80uaxlLBbV+IDL7CWw66m9f3b7P6GcgwRD6PH3pU/tOjA+40XaaIFEuyBbIVgY43I+9roU3u6yWWC4cDOoCQ5uYqc6MaDeLfG1zZq0e8/IdkQIy17pkWyIAj/INEXQ5KuCjXK4kaUM7q6eYlBmceI0fwMsdzZ2tj+khf1wmo64X2ZOUxQ6LzoK6emhNb75DV5O987qHEzr3m6KV/L+CfHnaE/V6pZoArfh2ruPDztq6nczWWTPvxETVYVzFCIjld0DuPorq7xuVF551R5Un5Rao/fUOtOn1twy3ik46rA/AouBQd0Z0xHVkKf11Jcu8LqRlIWc+3nH9ZO9xgwntSZo77aozv/zguY2CAM9kILakvciXGmS1tB27xcVLUsqVxaEL1ifN2JTrPvENXEKfaRPgCEGULwCcA2nTxCEf6Kw3bHG8sXeaQGJncpGoYI7EYl6sJrIeJQhZeylqjRXIt+31wb4KXQ3iqPSPVg== MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; AMSPR05MB421; 2:ATUFcQJ/u79GSceXVFofQQEKSFGqkkt8fkJnwWhaxf8ZWoZtvuUJRdaQD4AxMDRCib85xNL9eWOmYZUO/DcpHUub2icsE3A1zUvaNAB+g8zXOlswBxiUq1ul+4dnoyNXZw6kCg2a2loCzu/IuCrimQ==; 3:RU9Bf0EbxGbIRAUL9swwfQX3YmYDNicWbYzmAbYQrPc8quu6Hu0oSXmQdbkR4iiKEduVO4JaOtVCGkDgyAhhCJf+fHEo/rwvnumqS5du9J5Lnrebm2eOE57/lsh/PklXObY3hxeKRd+k0NjKv1YD6vzZsjNFpLuMywsU/S0eJQM=; 25:2hFMqZ2lvOGbOkOjiKf4cey8Y6I36Ry5b0rgOgalvuNAvGqbUP/qiZlQlKV9V5QNrss9C33LmvKhj1Qr7aiJuIr9wZf12GOjMd+I7JdBG4PSMHgd1jXuMt1iVzR57krn2DYSI6G3pLcWtoJbVxrNZxPgdYiNQxCBzrCdX9x9KS6j1Ym4YJFl8yPK9CgGpDsRUWP7yUCW4KS0nWiGjnHNm3oScTrPzU03cGnRmLtNYSLaU2eZW4Vyu/WTp64gRsDFFYehcNMXuD1CBZDc9HtFGtqpFUJBA55uheRgcscgy142lRDkT11nbaUtYUIh7bmkJvrMdC8FHTnZaDKs5pwTEg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AMSPR05MB421; X-MS-Office365-Filtering-Correlation-Id: 3a631695-84a5-409b-8f96-08d34150fb82 X-MLNXRule-EZCH-Linux: Rule triggered X-MLNXRule-Acc-Dom-4: Rule triggered X-Microsoft-Exchange-Diagnostics: 1; AMSPR05MB421; 20:YAGuRYMjTjVo/acDW6OsMy7gra7efylGigjDtZP7ofoaIM/jdO9rIV33ODvvy5ScrcajKSVOZ72/clRD9HTrX1xDGsRLbUQLub9lNH5UmLupRWEbHNtRs1SUAyzOQjHcF5YnIo0t7JQUpLStlmu5oBVuDgbcjg9t+w4JFKmbd3NHsfWY/XM3rklDuHEEnUOBZ5se3ETr2Khr+KzEmHZ54x9DGmVRDV3g9lSukoCL+ecsocYFGRiUd8W6xPnqkiiBRFO7pYtdrRFz4ZCueR2KbDac0hJ//jx8UY7LDGFlYmAaHBJS6XEagALgv8O38qBRF4xcuiw7Y+tnZ5WeiY2v0Zp8gJ89hYgmSsN6GFsJ2N9NhAwh20wUQ1Ry8Wlraj3etZyCHsQfZyvZUImad0DmD1pSjcrsBOxmo6QusnCyBPirEHCq546xA5KLAW+a3ybmGZOSFz4Mj/3NHE6al8RaKTs8bqsten07v52db3Ui46+s4730OTd1wnsAqD5cUNT3fC0A7xiApBafcROUhX3Zjy1JMu1kUR5FJzMqNGSGuonFUC3Y1WscBGG9OHAnzkrm3fFyfgUm+C37jFNCIDN1DoDyuAQUXsRscF01hg+6HXg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13017025)(5005006)(13023025)(13015025)(13018025)(13024025)(8121501046)(3002001)(10201501046); SRVR:AMSPR05MB421; BCL:0; PCL:0; RULEID:; SRVR:AMSPR05MB421; X-Microsoft-Exchange-Diagnostics: 1; AMSPR05MB421; 4:oF3pH9jpZzSkLhtIqcC3A/OquAQlP61x4yL4kjHL9/9xKz+7+bRzV7/2LrLpAgmgeC+zDTXnGZaJY5uVX5LCh43xCENmWLxDX/QRqiI0/wmDVwmq4gfCOOpMTX8sX1/Ylewt4o/MPQyeBT/X8cOU8Bv93slAsXYlbw8tFFgTJxo6lpMATN4uekv++P0C6JHRItUBRwQvMr7l2D0WmxO0e8ofDLu5aiggNGdk1Fb6DnpM85BGZpQrA4SWgOJTUK6Fbavv0jTldSgnYez91qftiEDAT0weHQgibwqtEylHyDmfSb37WENCU1mmh1wA4HH+EYw74jrjlSiXmeq6tZyOawf0NUMpoRvYB49jIgWwWi2egPJ+8peACBIVDkEpdgPEXTw9EBNkSIk5WzePFz7fualBjPgeFywA/OJEZh+IQNw1k7K/TmtWFPxlqTErjiApJmYouP87uloARtuEX2l3qQ== X-Forefront-PRVS: 0867F4F1AA X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AMSPR05MB421; 23:U1qYhiyC+VvMkNC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ovvitKZ3cd9xQSjDDc2Vx9Edx48nrNEioZ0XEaW5Iq94gdJBqzNQ?= =?us-ascii?Q?HXFB+wCb0Ca057v/DmqyIw6YCuEsIZ28E+ynSoCV37D8bDReSMKdqfpClCIm?= =?us-ascii?Q?745KjCPkgxDxbzuRkwxDAFdHsdd6/rVRx99qGMsSK7BhG9uGEpHIv1R3I+5m?= =?us-ascii?Q?caGzwbtjE8R6YwBcDkQ0HogM4W/QtGxzhk4zB3hOLtVm5HT7KEKaJfjayZEj?= =?us-ascii?Q?4WdttC9LxYdu5C03EXsXcjx/WFbz49?= X-Microsoft-Exchange-Diagnostics: 1; AMSPR05MB421; 5:ZOscpzVLXMgVG/sdPlMavm8g+4fPLCRDh9k2kpfpoEKg5yZhh0P+srRe1Uut9hue2qVCXRHtvJdn9+chZ6HMVTaBFOAR/ogB2+D0J1DTMVIyI7XBitxgXWz2mIE04Ac0iDoQOV9WVnEkjK01E2VnLw==; 24:rTpCLaAlxk0Oudco+CSCrY30t3p9gkACDb7TrBJ1y98eH2qvBgB+MJ0z2XBl43oGMKfNX/XEIdDwwUieRZgkagDkPLJZPmTpkaTqTfnr8TI= X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Feb 2016 21:40:45.8766 (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=[lab-41.internal.tilera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMSPR05MB421 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160229_134110_783035_16A33286 X-CRM114-Status: GOOD ( 15.48 ) X-Spam-Score: -1.9 (-) 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=-4.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=ham 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 f878efc9e851..b9a92b90b914 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));