From patchwork Mon Feb 29 21:40:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Metcalf X-Patchwork-Id: 8458621 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 92F109F38C for ; Mon, 29 Feb 2016 21:43:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 63BC020221 for ; Mon, 29 Feb 2016 21:42:59 +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 3A72020220 for ; Mon, 29 Feb 2016 21:42:58 +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 1aaVZF-0004mD-9j; Mon, 29 Feb 2016 21:41:25 +0000 Received: from mail-db3on0056.outbound.protection.outlook.com ([157.55.234.56] helo=emea01-db3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aaVYt-0004bN-Aq for linux-arm-kernel@lists.infradead.org; Mon, 29 Feb 2016 21:41: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=0WtyIHPdup0LILee1tekv+O5U3muDYezNJKSO5DscUw=; b=vJDdxJAeBncCJ+dgPard2LGbGUflW1bcxcC4f4peiJT5yurbzXCbEZffy8R4XLOICrEygbu7tB9US56svIzxq6xa0uRQP/kfyAJNW8Ns3XYdKuWPNbdsg97ifEGVr3mlGglMZyIGKlcufu/eWPcRC0wvToMgJU3Z032vtpBPmr0= Received: from HE1PR05CA0046.eurprd05.prod.outlook.com (10.164.28.14) by AMSPR05MB422.eurprd05.prod.outlook.com (10.242.224.148) with Microsoft SMTP Server (TLS) id 15.1.415.20; Mon, 29 Feb 2016 21:40:40 +0000 Received: from DB3FFO11FD037.protection.gbl (2a01:111:f400:7e04::130) by HE1PR05CA0046.outlook.office365.com (2a01:111:e400:59a1::14) with Microsoft SMTP Server (TLS) id 15.1.415.20 via Frontend Transport; Mon, 29 Feb 2016 21:40:39 +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 DB3FFO11FD037.mail.protection.outlook.com (10.47.217.68) with Microsoft SMTP Server (TLS) id 15.1.427.7 via Frontend Transport; Mon, 29 Feb 2016 21:40:38 +0000 Received: (from cmetcalf@localhost) by lab-41.internal.tilera.com (8.14.4/8.14.4/Submit) id u1TLebwu007166; Mon, 29 Feb 2016 16:40:37 -0500 From: Chris Metcalf To: Russell King , Thomas Gleixner , Aaron Tomlin , Ingo Molnar , Andrew Morton , Daniel Thompson , , , Subject: [PATCH 1/4] nmi_backtrace: add more trigger_*_cpu_backtrace() methods Date: Mon, 29 Feb 2016 16:40:21 -0500 Message-ID: <1456782024-7122-2-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)(85426001)(2201001)(50466002)(48376002)(4326007)(92566002)(36756003)(229853001)(4001430100002)(107886002)(42186005)(5001970100001)(1220700001)(586003)(50986999)(5003940100001)(81156008)(50226001)(87936001)(76176999)(1096002)(2906002)(189998001)(5001770100001)(575784001)(47776003)(19580395003)(19580405001)(5008740100001)(6806005)(104016004)(106466001)(2950100001)(105606002)(33646002)(42882005)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:AMSPR05MB422; H:lab-41.internal.tilera.com; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD037; 1:aUwL6w5Kk4feAck+OA0iSg9GeDT57UFWGWEPqr/LRxfuEPdNUKXwWugVXTYS+HRYxj6NlEO4fqM1aLk1m3jUJHW1Mrf8esItTbFT9PUGislaSXUNMGqt6xgWeAK6smQs72li5yqYvThDn3Ba+OcTDNqsNd1jHWukMo8NRIH9rlFakSF8/1j4RzuXRkLbhmU6WjHN2KtfcxG48ZgFwSwZHIsg6nbNjRSwb7BW6ojjKZCTIGlHmsrk0jKRVdlpXIKOXxFzaimiJiKtmtyxQSOMJY55n86Q2NrebXOgwV9dB/bbqHlWrlx/jGYMg81ywVucqT/frPCcE9NPL1YvQpiud4Cx7WM3SI6sELjFdPT24QGgP3MzpJyGiqCCuzXuFBILt1IOivXzn60kvQbfXtqA+bV5lxyBjPedrkWJyJ2WHez93bACOVWhWlS1rUyrW2OVfPnw9o3YSg/aIU1Qsx2BfJfpwI9qzmZi6W1zz9jV1t5NDMG+R2Y86qB0qhLU8Q7fMHKFE87yydOP5th/PANMuw== MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; AMSPR05MB422; 2:PW6L+t1xLlzwnyCVRuh0Wg/h8gxsaO4ul++jctktnGajbXebvCNWPoZVIWtJwYPWpt/0pUywriAtXgerTI3soZn6oSGM3epNwy4II2qvFcnSw9a2k04f+fNekEELnuzoHUfdEGriWvCt0uXs8VwEsw==; 3:msASd4XomJSsieWDptwnChtyO1oD8AetU6Lk2qLHFkD0KviLO/PUp27qjZEJ8zR2QCQgJExSsdPWjQJY6n7oH1IrJG5PtfzVUJXu6nsstoxiAQmVRPKLgaK0WisvhA3KVK1Q5u5PulqZDlCQmcaaDkQQRZMK13Wgm4vWJJF8PkM=; 25:nYAsFKHd4RrAqnzIHu7UKzPcs4xdluxuV9Bg8d3dELeFlc4hfJu05DbHK1JLC/UoE7kqzZffoHQglFbZX72mHlXb9KNKjLYHIbz9om09NzoJV97ZX3BMw7MgvllNnqJAVvaKl7qkcUGG2quTNcWKdTnjhlDs1bWhYw+yZGAdYDq+XQH8XNvfRMYfXdCZrEhM51gfenPL/0uZraDcSuwzPFpkV4JxaU5IBcDkk0pltb6Fqn+cPneRtml0s25eDcJha5c41IJAZezwzxT4EAw0LcxjTQzoNlmwIdrOo38xAtKF7+jKmg6a3rnt3rAf/ZC0k5rEochNA+piqPeDVktJTA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AMSPR05MB422; X-MS-Office365-Filtering-Correlation-Id: 546b3579-f89a-4feb-2395-08d34150f72a X-MLNXRule-EZCH-Linux: Rule triggered X-MLNXRule-Acc-Dom-4: Rule triggered X-Microsoft-Exchange-Diagnostics: 1; AMSPR05MB422; 20:iiJ30b2IHCzNJB2m9k/BCOCwMP3nskQj9neJ7/Dec7EksdaBUXJp4x2jlA5yJboRoDH0g7cBjTEzUBtL50V2LMYnIZbhs9Z5MMWg4hGrSEMJy2UsS1hinVwjcFTw3X3NJskucsjj5nZwuV2nXLnWFbkID59snPv5+j+wsIotQNi4w+rHe8VLJmrGFYEnjAvPuQkKw6kON0qZJnpPPxyIspGll5c5pXS4KJwEZ1XV4T+Cz1llOSzpaV6KU6urhiQbvq3UBaN3pk9jaTVd/3+8pmvLAS2VV23SKQiU2rx1oS5sr4yCr4ZHWnMgIs+/uL/fvWZzx6eNIHeG+ci4GBf6Fn+4BPWAFDgL9aMqA3nsfc3GuYaBZopbjUcoJdD2sJhdl1U1spRTzpLNUNxJbQTqQyc+ui5iKm7QUGs4Hy8NeZrOGjwsnBHYdIpdUZRci7s5F5fCwbZ1kcJ4ksd/Ivqrz+mGmb1PnNj8g2TN9ovech15Q1vUBONBC4U2BzZJ7rzTL2Rex4EiEjaYERzNH4ENm/L3HRwgYziLMSFVsxe/tK1VNZAidqKiS4RsyQrhMXK+ETVfK21cHULfW6U7vW/jdru4ACVpPV3Qv74lM3ndlbI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13024025)(13018025)(13015025)(13017025)(8121501046)(5005006)(13023025)(10201501046)(3002001); SRVR:AMSPR05MB422; BCL:0; PCL:0; RULEID:; SRVR:AMSPR05MB422; X-Microsoft-Exchange-Diagnostics: 1; AMSPR05MB422; 4:hF81sodmJczfFrfuxIjqyHDmgLweufHch8pMLLNeXEuK0SjxJJSXLuFK2joT1/EsD6ArmZbcLxN0jwQQX9Eq9WrgD3+EQru5XXm4+33BdFrLEKn025a+tCeVnhARxSfEHbUSvRfy55ce0AaIi5GnHB9nZN5aJ/sq0W9q1pWn8Qm09OqBxgvmkbU3Q0BbQA/inv0Hh0z4fcvhunyt73mDPN05dlUL62QHXJPTMb4yNMlqAa/AA18AnCfyg73H0BYp0Jtv+THgbeHUYvIEgCvBmmq78QRJt0woMEaqK9Yk8rWM1M/F+ysxlQvKj608v8EEQJh5DcjNN5KJLTmvOCPn7lm+nQ9GaMyHVh7aIlxBJigcIJxDsK6xCzkt0Y7vfL0Pp7xFx0gkgKL4iJOm9sPdUAKhaIYR+33get5/HxZ7CDvX5rlGKnB9n0bBosiRu39jRlfRYe1yVLiL0BSxmF5Ayg== X-Forefront-PRVS: 0867F4F1AA X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AMSPR05MB422; 23:Y7j4rhLsaiLWLTDaE50vnSFoIshM0pfzUf56oHdCZQ?= =?us-ascii?Q?tBG1ZJCDzLJ8cQqA0lA1icqwGp99ywWb9ZO4dpzT8EguumQzqII1lzrSNrrD?= =?us-ascii?Q?RaooUWMV993v1om78rnIX0Oy1XSCAXbYAfm3e4kb5BxyENL+iw/rZ3TiaTY2?= =?us-ascii?Q?ndrvY4Wx/v8Ji4gA5QY3b9sKeY+iUwpq/sNPHwdKfePMldEVWCUeBOoHo3UB?= =?us-ascii?Q?ISSRFbo6kultumubta7+YMSRvnoKMUkKJzuuvsPv1+T0k1RX2KIFTF912pU1?= =?us-ascii?Q?pYD7qBHakG0MANHCZDC8cyqZZ373ibQ72DQATihLFSFSTHoLMef4Ml+Udn4Y?= =?us-ascii?Q?vglTz3UT/FrVrf9NIGdYfHCitsaLlwZcx3sl70GiddYtM8zxCTFLzMKrQkRY?= =?us-ascii?Q?20mpqtYBrfLUBy3c/PZF6jxMs6IzQY3H2FboExoo+M4gVCsnyQi8tmnaTwsi?= =?us-ascii?Q?oDh2LFLjAajyWsKd79GHJJKn0TKXU4EZOeLeEZ3bJUvsS6Q4B+IYB/VHZkM1?= =?us-ascii?Q?Hbl2MtKlFxzVLdq98HVpSsMX0P8/DmL9z273q5a2BuoyqlgCxmJMogTOIV//?= =?us-ascii?Q?FomXHhRgeKSvhGZrNiIhwNkhCSCp2GX4ixnPIt+lSLx2vIoQ2yody9O9dBBd?= =?us-ascii?Q?V8+326m3O5OxTYlSYOPeLZKeGenFueMmLfXzze25Qq6WjObfaXqcR5+IWodY?= =?us-ascii?Q?KzSlMZeD+hyQbe+b1CmoOUUbnm2m6EOWyU6K+U1lcVA3erHiWhPpE8Vz1Qsl?= =?us-ascii?Q?dShGqmE/WxpGNK4feB2hekcrSuEA2dYyMexo7kMk8ARfX8t+LDw2JDXcq5rh?= =?us-ascii?Q?+HT8iaEXj3fd/tfbOembc1IGmEYhQz5WSmvNQYPr/GSamerQjM0qngE3mCij?= =?us-ascii?Q?0oiPzjitXCv17t3XWavo4CJcHd98UsVXl00OePL440acfflORasXtTZL8kow?= =?us-ascii?Q?jzLrZxSfe0dDH+zk+M8hp+NzOe0vih5s1dJVBfd8dEl0ox3j1yE8c/DvxhbU?= =?us-ascii?Q?WwieqDhaLsMZCaF0vqVGvO4Ij1p4u/uzS93aNhqgaZjYDbg7kVrazCeSvjG7?= =?us-ascii?Q?tTFc1VcBU8Ak1MmFWDm2oxYCBW7qHNwkAQ5Lye+oemi53GC/PJ8TR4BWc7Df?= =?us-ascii?Q?CurCG3aLJJuGFIMqb9QutWkhu9CV1FK+X6eYGkUXHEfI2BRUDFAg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; AMSPR05MB422; 5:127jd+JZ1B2XkCHepVBvdDJSSYB3SjOWrW1hWST2Is7vK3yOZX65cF2nFSIWaow8PZIgvHZxuwA817B1QEfmkQvSg7V18tZ/3kfQpwThIAgzl9YWKThdm+S8wB7BU2Hp+Z8XL+/VBuZKcCZoR3Ydlw==; 24:qp/DkhfLvvRD3YlQ/VTXfls/f6aMo93bPW71FbGpUW2pCjF4KOOtPtPZybS2Kkao8ri6njs1147ixWj3VOc4Ljx/QNajIaOk703kegSQAGQ= X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Feb 2016 21:40:38.6018 (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: AMSPR05MB422 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160229_134104_034328_96BFF627 X-CRM114-Status: GOOD ( 16.34 ) 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 you can only request a backtrace of either all cpus, or all cpus but yourself. It can also be helpful to request a remote backtrace of a single cpu, and since we want that, the logical extension is to support a cpumask as the underlying primitive. This change modifies the existing lib/nmi_backtrace.c code to take a cpumask as its basic primitive, and modifies the linux/nmi.h code to use either the old "all/all_but_self" arch methods, or the new "cpumask" method, depending on which is available. The existing clients of nmi_backtrace (arm and x86) are converted to using the new cpumask approach in this change. Signed-off-by: Chris Metcalf --- arch/arm/include/asm/irq.h | 4 +-- arch/arm/kernel/smp.c | 4 +-- arch/x86/include/asm/irq.h | 4 +-- arch/x86/kernel/apic/hw_nmi.c | 6 ++--- include/linux/nmi.h | 63 ++++++++++++++++++++++++++++++++++--------- lib/nmi_backtrace.c | 15 +++++------ 6 files changed, 65 insertions(+), 31 deletions(-) diff --git a/arch/arm/include/asm/irq.h b/arch/arm/include/asm/irq.h index 1bd9510de1b9..13f9a9a17eca 100644 --- a/arch/arm/include/asm/irq.h +++ b/arch/arm/include/asm/irq.h @@ -36,8 +36,8 @@ extern void set_handle_irq(void (*handle_irq)(struct pt_regs *)); #endif #ifdef CONFIG_SMP -extern void arch_trigger_all_cpu_backtrace(bool); -#define arch_trigger_all_cpu_backtrace(x) arch_trigger_all_cpu_backtrace(x) +extern void arch_trigger_cpumask_backtrace(const cpumask_t *mask); +#define arch_trigger_cpumask_backtrace(x) arch_trigger_cpumask_backtrace(x) #endif static inline int nr_legacy_irqs(void) diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 37312f6749f3..208125658e56 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -758,7 +758,7 @@ static void raise_nmi(cpumask_t *mask) smp_cross_call(mask, IPI_CPU_BACKTRACE); } -void arch_trigger_all_cpu_backtrace(bool include_self) +void arch_trigger_cpumask_backtrace(const cpumask_t *mask) { - nmi_trigger_all_cpu_backtrace(include_self, raise_nmi); + nmi_trigger_cpumask_backtrace(mask, raise_nmi); } diff --git a/arch/x86/include/asm/irq.h b/arch/x86/include/asm/irq.h index e7de5c9a4fbd..18bdc8cc5c63 100644 --- a/arch/x86/include/asm/irq.h +++ b/arch/x86/include/asm/irq.h @@ -50,8 +50,8 @@ extern int vector_used_by_percpu_irq(unsigned int vector); extern void init_ISA_irqs(void); #ifdef CONFIG_X86_LOCAL_APIC -void arch_trigger_all_cpu_backtrace(bool); -#define arch_trigger_all_cpu_backtrace arch_trigger_all_cpu_backtrace +void arch_trigger_cpumask_backtrace(const struct cpumask *mask); +#define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace #endif #endif /* _ASM_X86_IRQ_H */ diff --git a/arch/x86/kernel/apic/hw_nmi.c b/arch/x86/kernel/apic/hw_nmi.c index 045e424fb368..63f0b69ad6a6 100644 --- a/arch/x86/kernel/apic/hw_nmi.c +++ b/arch/x86/kernel/apic/hw_nmi.c @@ -27,15 +27,15 @@ u64 hw_nmi_get_sample_period(int watchdog_thresh) } #endif -#ifdef arch_trigger_all_cpu_backtrace +#ifdef arch_trigger_cpumask_backtrace static void nmi_raise_cpu_backtrace(cpumask_t *mask) { apic->send_IPI_mask(mask, NMI_VECTOR); } -void arch_trigger_all_cpu_backtrace(bool include_self) +void arch_trigger_cpumask_backtrace(const cpumask_t *mask) { - nmi_trigger_all_cpu_backtrace(include_self, nmi_raise_cpu_backtrace); + nmi_trigger_cpumask_backtrace(mask, nmi_raise_cpu_backtrace); } static int diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 7ec5b86735f3..951875f4f072 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -31,38 +31,75 @@ static inline void hardlockup_detector_disable(void) {} #endif /* - * Create trigger_all_cpu_backtrace() out of the arch-provided - * base function. Return whether such support was available, + * Create trigger_all_cpu_backtrace() etc out of the arch-provided + * base function(s). Return whether such support was available, * to allow calling code to fall back to some other mechanism: */ -#ifdef arch_trigger_all_cpu_backtrace static inline bool trigger_all_cpu_backtrace(void) { +#if defined(arch_trigger_all_cpu_backtrace) arch_trigger_all_cpu_backtrace(true); - return true; +#elif defined(arch_trigger_cpumask_backtrace) + arch_trigger_cpumask_backtrace(cpu_online_mask); + return true; +#else + return false; +#endif } + static inline bool trigger_allbutself_cpu_backtrace(void) { +#if defined(arch_trigger_all_cpu_backtrace) arch_trigger_all_cpu_backtrace(false); return true; -} - -/* generic implementation */ -void nmi_trigger_all_cpu_backtrace(bool include_self, - void (*raise)(cpumask_t *mask)); -bool nmi_cpu_backtrace(struct pt_regs *regs); +#elif defined(arch_trigger_cpumask_backtrace) + cpumask_var_t mask; + int cpu = get_cpu(); + if (!alloc_cpumask_var(&mask, GFP_KERNEL)) + return false; + cpumask_copy(mask, cpu_online_mask); + cpumask_clear_cpu(cpu, mask); + arch_trigger_cpumask_backtrace(mask); + put_cpu(); + free_cpumask_var(mask); + return true; #else -static inline bool trigger_all_cpu_backtrace(void) -{ return false; +#endif } -static inline bool trigger_allbutself_cpu_backtrace(void) + +static inline bool trigger_cpumask_backtrace(struct cpumask *mask) { +#if defined(arch_trigger_cpumask_backtrace) + arch_trigger_cpumask_backtrace(mask); + return true; +#else return false; +#endif } + +static inline bool trigger_single_cpu_backtrace(int cpu) +{ +#if defined(arch_trigger_cpumask_backtrace) + cpumask_var_t mask; + + if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) + return false; + cpumask_set_cpu(cpu, mask); + arch_trigger_cpumask_backtrace(mask); + free_cpumask_var(mask); + return true; +#else + return false; #endif +} + +/* generic implementation */ +void nmi_trigger_cpumask_backtrace(const cpumask_t *mask, + void (*raise)(cpumask_t *mask)); +bool nmi_cpu_backtrace(struct pt_regs *regs); #ifdef CONFIG_LOCKUP_DETECTOR int hw_nmi_is_cpu_stuck(struct pt_regs *); diff --git a/lib/nmi_backtrace.c b/lib/nmi_backtrace.c index 6019c53c669e..db63ac75eba0 100644 --- a/lib/nmi_backtrace.c +++ b/lib/nmi_backtrace.c @@ -18,7 +18,7 @@ #include #include -#ifdef arch_trigger_all_cpu_backtrace +#ifdef arch_trigger_cpumask_backtrace /* For reliability, we're prepared to waste bits here. */ static DECLARE_BITMAP(backtrace_mask, NR_CPUS) __read_mostly; static cpumask_t printtrace_mask; @@ -44,12 +44,12 @@ static void print_seq_line(struct nmi_seq_buf *s, int start, int end) } /* - * When raise() is called it will be is passed a pointer to the + * When raise() is called it will be passed a pointer to the * backtrace_mask. Architectures that call nmi_cpu_backtrace() * directly from their raise() functions may rely on the mask * they are passed being updated as a side effect of this call. */ -void nmi_trigger_all_cpu_backtrace(bool include_self, +void nmi_trigger_cpumask_backtrace(const cpumask_t *mask, void (*raise)(cpumask_t *mask)) { struct nmi_seq_buf *s; @@ -64,10 +64,7 @@ void nmi_trigger_all_cpu_backtrace(bool include_self, return; } - cpumask_copy(to_cpumask(backtrace_mask), cpu_online_mask); - if (!include_self) - cpumask_clear_cpu(this_cpu, to_cpumask(backtrace_mask)); - + cpumask_copy(to_cpumask(backtrace_mask), mask); cpumask_copy(&printtrace_mask, to_cpumask(backtrace_mask)); /* @@ -80,8 +77,8 @@ void nmi_trigger_all_cpu_backtrace(bool include_self, } if (!cpumask_empty(to_cpumask(backtrace_mask))) { - pr_info("Sending NMI to %s CPUs:\n", - (include_self ? "all" : "other")); + pr_info("Sending NMI from CPU %d to CPUs %*pbl:\n", + this_cpu, nr_cpumask_bits, to_cpumask(backtrace_mask)); raise(to_cpumask(backtrace_mask)); }