From patchwork Tue May 14 14:02:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Neri X-Patchwork-Id: 1099502 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 453KNn3tHbz9s4Y for ; Wed, 15 May 2019 00:11:21 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 453KNn31P9zDqMp for ; Wed, 15 May 2019 00:11:21 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.intel.com (client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=ricardo.neri-calderon@linux.intel.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 453KCL5d9szDqDC for ; Wed, 15 May 2019 00:03:10 +1000 (AEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 May 2019 07:02:58 -0700 X-ExtLoop1: 1 Received: from unknown (HELO luv-build.sc.intel.com) ([172.25.110.25]) by fmsmga005.fm.intel.com with ESMTP; 14 May 2019 07:02:58 -0700 From: Ricardo Neri To: Thomas Gleixner , Ingo Molnar , Borislav Petkov Subject: [RFC PATCH v3 10/21] watchdog/hardlockup: Add function to enable NMI watchdog on all allowed CPUs at once Date: Tue, 14 May 2019 07:02:03 -0700 Message-Id: <1557842534-4266-11-git-send-email-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1557842534-4266-1-git-send-email-ricardo.neri-calderon@linux.intel.com> References: <1557842534-4266-1-git-send-email-ricardo.neri-calderon@linux.intel.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J. Wysocki" , Peter Zijlstra , Alexei Starovoitov , Stephane Eranian , Kai-Heng Feng , Paul Mackerras , "H. Peter Anvin" , sparclinux@vger.kernel.org, Davidlohr Bueso , Ashok Raj , Joerg Roedel , x86@kernel.org, "Luis R. Rodriguez" , David Rientjes , Andi Kleen , Waiman Long , "Paul E. McKenney" , Don Zickus , "Ravi V. Shankar" , Konrad Rzeszutek Wilk , Marc Zyngier , Ricardo Neri , Frederic Weisbecker , Nicholas Piggin , Ricardo Neri , Byungchul Park , Babu Moger , Mathieu Desnoyers , Josh Poimboeuf , Tony Luck , Randy Dunlap , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Masami Hiramatsu , Suravee Suthikulpanit , Philippe Ombredanne , Colin Ian King , Andrew Morton , linuxppc-dev@lists.ozlabs.org, "David S. Miller" Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" When there are more than one implementation of the NMI watchdog, there may be situations in which switching from one to another is needed (e.g., if the time-stamp counter becomes unstable, the HPET-based NMI watchdog can no longer be used. The perf-based implementation of the hardlockup detector makes use of various per-CPU variables which are accessed via this_cpu operations. Hence, each CPU needs to enable its own NMI watchdog if using the perf implementation. Add functionality to switch from one NMI watchdog to another and do it from each allowed CPU. Cc: "H. Peter Anvin" Cc: Ashok Raj Cc: Andi Kleen Cc: Tony Luck Cc: "Rafael J. Wysocki" Cc: Don Zickus Cc: Nicholas Piggin Cc: Michael Ellerman Cc: Frederic Weisbecker Cc: Alexei Starovoitov Cc: Babu Moger Cc: "David S. Miller" Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Mathieu Desnoyers Cc: Masami Hiramatsu Cc: Peter Zijlstra Cc: Andrew Morton Cc: Philippe Ombredanne Cc: Colin Ian King Cc: Byungchul Park Cc: "Paul E. McKenney" Cc: "Luis R. Rodriguez" Cc: Waiman Long Cc: Josh Poimboeuf Cc: Randy Dunlap Cc: Davidlohr Bueso Cc: Marc Zyngier Cc: Kai-Heng Feng Cc: Konrad Rzeszutek Wilk Cc: David Rientjes Cc: Stephane Eranian Cc: Suravee Suthikulpanit Cc: "Ravi V. Shankar" Cc: x86@kernel.org Cc: sparclinux@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Ricardo Neri --- include/linux/nmi.h | 2 ++ kernel/watchdog.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/linux/nmi.h b/include/linux/nmi.h index e5f1a86e20b7..6d828334348b 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -83,9 +83,11 @@ static inline void reset_hung_task_detector(void) { } #if defined(CONFIG_HARDLOCKUP_DETECTOR) extern void hardlockup_detector_disable(void); +extern void hardlockup_start_all(void); extern unsigned int hardlockup_panic; #else static inline void hardlockup_detector_disable(void) {} +static inline void hardlockup_start_all(void) {} #endif #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR) diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 7f9e7b9306fe..be589001200a 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -566,6 +566,21 @@ int lockup_detector_offline_cpu(unsigned int cpu) return 0; } +static int hardlockup_start_fn(void *data) +{ + watchdog_nmi_enable(smp_processor_id()); + return 0; +} + +void hardlockup_start_all(void) +{ + int cpu; + + cpumask_copy(&watchdog_allowed_mask, &watchdog_cpumask); + for_each_cpu(cpu, &watchdog_allowed_mask) + smp_call_on_cpu(cpu, hardlockup_start_fn, NULL, false); +} + static void lockup_detector_reconfigure(void) { cpus_read_lock();