From patchwork Wed Mar 16 17:02:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Metcalf X-Patchwork-Id: 8602831 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 7F7DAC0553 for ; Wed, 16 Mar 2016 17:12:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C793202AE for ; Wed, 16 Mar 2016 17:12:28 +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 381C120149 for ; Wed, 16 Mar 2016 17:12:27 +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 1agEqn-0006XA-QM; Wed, 16 Mar 2016 17:03:13 +0000 Received: from mail-ve1eur01on0077.outbound.protection.outlook.com ([104.47.1.77] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1agEqW-0006Kj-R0 for linux-arm-kernel@lists.infradead.org; Wed, 16 Mar 2016 17:03:02 +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=KtJ+OGAObK+8O6bVmOl4ld4Fw0A/TSeweEUwBJv35TU=; b=X4E/FHB3jpNfVtpSUIkv8AAAAgXBYy/SD/HbtAgr4nLjCdMMC3RSHiM/Rr+N+VEjBzdVdbV5Yo5LWfl6uamp08wNpfNAB7uGTP0PfD12XI5J6x5IfhfKllTJhc6w1OocI1vzXjZTXYEhtklu7V/uQn42jjzI90zSj7z86bCCVBU= Received: from AMXPR05CA0023.eurprd05.prod.outlook.com (10.242.9.151) by VI1PR05MB1693.eurprd05.prod.outlook.com (10.165.235.155) with Microsoft SMTP Server (TLS) id 15.1.434.16; Wed, 16 Mar 2016 17:02:32 +0000 Received: from AM1FFO11FD021.protection.gbl (2a01:111:f400:7e00::146) by AMXPR05CA0023.outlook.office365.com (2a01:111:e400:803c::23) with Microsoft SMTP Server (TLS) id 15.1.443.12 via Frontend Transport; Wed, 16 Mar 2016 17:02:32 +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 AM1FFO11FD021.mail.protection.outlook.com (10.174.64.210) with Microsoft SMTP Server (TLS) id 15.1.434.11 via Frontend Transport; Wed, 16 Mar 2016 17:02:31 +0000 Received: (from cmetcalf@localhost) by ld-1.internal.tilera.com (8.14.4/8.14.4/Submit) id u2GH2UVP029386; Wed, 16 Mar 2016 13:02:30 -0400 From: Chris Metcalf To: Peter Zijlstra , Russell King , Thomas Gleixner , Aaron Tomlin , Ingo Molnar , Andrew Morton , Daniel Thompson , , , Subject: [PATCH v2 1/4] nmi_backtrace: add more trigger_*_cpu_backtrace() methods Date: Wed, 16 Mar 2016 13:02:10 -0400 Message-ID: <1458147733-29338-2-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)(1109001)(1110001)(339900001)(189002)(199003)(11100500001)(87936001)(36756003)(50466002)(4326007)(85426001)(86362001)(2950100001)(104016004)(2906002)(6806005)(42186005)(5008740100001)(2201001)(5003940100001)(575784001)(50986999)(76176999)(48376002)(1096002)(1220700001)(586003)(33646002)(19580395003)(92566002)(5001970100001)(47776003)(5001770100001)(229853001)(107886002)(19580405001)(106466001)(189998001)(105606002)(960300001)(921003)(1121003)(83996005)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB1693; H:ld-1.internal.tilera.com; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11FD021; 1:7cMXvWyoaz1RKbAV2B2Rd9a0fECK3GHhqkRvrxzoNZ38JazAheTWMpGeI9Sh+LtncgsvQAHxUhu6bHbudeuk73zsNYTWKs2FSY74V9FDMRQUgSMC4dUst7+efSBES/tTve9sAax9uPiws++xJ1cVgxcdGx1vgYvjVLLXRo8afg7BCQF2liDqxfM11lRqSStJVNvaaP5DCqcj/Znq6ENP0aNGj2oxz6MPbkRS0y+v6GHdhtjI3TMkvXzO5lxeyfDuvbxQRJxdJ2NKpaH3WIZjjfPSXzuOJqjUjjSoyttMpvnbJ+giacztOPTGfzBFlnLyABLN1GAkq9CincnaydjHamL4DwkT4qjYiqbP3nz2lXQ65jiOAr0d1YtZ9/rUzk4RRq6BU0YhHLbvhYCtXbxD3zUAeMJnBIZmpLa0SqJJFO0NM2KwjV6hwypoYqXiv/JigQLEL42m2AV1H6oB0srdRu+GjlxiIqu98QN7O7yrP1k4T4RNtI2H3lQzF/XyBNyi7uqc7yI7d9O+rKl5e+AtW50EvkjVz3gUKyNYqWTd7zQ= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 64eb7134-3cfb-4241-9960-08d34dbcc39a X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB1693; 2:P6ed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9HvQa8FFWus2aLfAjgxWqW+bqNc/JLnyiOv3nHEcXd0p7UTdu8mN0BkCztsNz8+V4Eby+G6OxBtQkBe7BS+XSu5d65YKt5ntXmQAgUMCU4N1mYocl5n4ujPJ5DRuEgCp9mxHYbo1mOLPwLMLZPzzLLaKOSRn4cCIQmFHbYmpZxVjwOBPE+ULlOkfoxswkWruW3+z7YXZAcWWEc2iajaPZ4nmw8oZCjHUB+stldoA4XMUSbSoYcVz+kF22UbTNwRWWiUJTSkNymYSd7U2dUuhyCe0iTm8yoCXRm0qYA0SNU40deup73rxNT7rtJxLf0x7oTsP05n4z X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(13023025)(13017025)(13024025)(13015025)(13018025)(8121501046)(3002001)(10201501046); SRVR:VI1PR05MB1693; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB1693; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB1693; 4:8O0z/QUU3IGxGX6aMUIBz0HOQ/rqvYf78KZGAM05Je7fANl1gqoTubjTrpF/yB8bEqBj6QcmOuBGmddK3caA9pmY4J4A1CIG6Nz6trO0n8MpPc5HlhsAjLD8cv7IBz+ZEiPsO+unpBQ9KCTX7vo95gTqzu+f3ZNNePJ57O5xGziAvjnevpm0ci4nvWFoZUPaVWyeqQRhzVVK2095Wq1jqiurqQlO9lVMU5ZwXxn2w7wXa69kJusS1Vq3qgx9MqHZl81MtHXERpd8oDEyNfintfd4C1FNRs9UdwHZO5DPCtslJuJQfOtY4zdK82Mm3szAQ/R0+8zFJWXD2e7ipCoFY4hU3N2pH7q3QSbyiIs/KAb7sxpx1CwPeV67CjyamnTKL1iJAPAsrU0KbFsKhHCZurG55DN5hb+oADc25+Z6GEoykuBF7FYQw7ly+hQiaZIC5Ue/gQ8GzkgstQHUa1bwVQ== X-Forefront-PRVS: 08831F51DC X-Microsoft-Exchange-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WmrmzgIlQEQ/SXbb25ig4OswjVOkp54PAteUcIlJdyYB?= =?us-ascii?Q?uEb0wanlcESBOPZd/WQHw8oaGvfLe5lSzyyjBD7QVfQzsY7YY1cjNm9UUr2h?= =?us-ascii?Q?tu/YMsnHJuDNJMlLA7WDbShm8JT/BHCI/secI5Cda5bGCinwxp8mMvAx7J4r?= =?us-ascii?Q?ZvywLsp+5ijbaiTp+y+6XALB5llQeTB7zrNOQ2uLuhmbQkJncUybXGJSvKmQ?= =?us-ascii?Q?JxIC5wQaE07lyuVz5THwAvTtvGwCBWt0Qa8plP6h5+t94nvn1CItsJKLlLy6?= =?us-ascii?Q?NMSItkKza5kGubkwAexpBFhiTOAA6MKH121j65cgs0U3nrcuVa592rfnTbwO?= =?us-ascii?Q?vTi/AijqF2DF9I=3D?= X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB1693; 5:grcRGPRILwH7ddmjGcgEXiG4pNgQ5v6r09j6RgNJ/Y2yEzgCWB+iFXgLpiypjFC95T2kczU9lzLzFKGHv5AcbGi1BIiAsdzps/HNqeJ7FiU5+d3d9m+UVHQ+0R4eYRBcsmg8TtJd3LIRakGuRVbnuw==; 24:hqfwmZ85XRHk+0xdbMgedvockM1LHT8FEIuYvX3QUapVxwwdBYEHbp2hP1m+zM3XeF+GxVT55su5PStvy4UoFO72/vkLb/IwdN61CqKRt0g= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Mar 2016 17:02:31.5883 (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: VI1PR05MB1693 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160316_100257_396271_A6976C9A X-CRM114-Status: GOOD ( 15.64 ) 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 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)); }