Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1946893img; Wed, 27 Feb 2019 08:07:09 -0800 (PST) X-Google-Smtp-Source: AHgI3IYqT0L6Uw55MUSelW3xD1QVX4+3Pnru/tL9UiG+7otjYsrTOqruIQDPod3cWLCFy6iQbglL X-Received: by 2002:a17:902:27a8:: with SMTP id d37mr2895185plb.164.1551283629270; Wed, 27 Feb 2019 08:07:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551283629; cv=none; d=google.com; s=arc-20160816; b=JSW6m2vB7KEhTt/ArLCpd6u0L7MqxAQ6LfxNlt9m9HI8eLL/28pbr4jGsTLCGW7LbZ DhDET88aRB5sQWyJwhbOStPq3ioaRm/dTVU97T2LbnCLHzVsO7YJ2VHwwE4w3g2ctTud DwpH3TnBOFPOvss1rGQxmvDvlpjNDoBDtfEOliKk5XEvXtHdybgRnuHgfkl5e0ZDQXrt E/R4NV/6/ikdjNEJ/oU1DEOaajQYEMBFiNlHCisADOhztfgWtZRMOPcrgkIbLNPFdU97 HyQp4do9x9jh8CTR4STZmtuvEay84CNlRYU8e9DReFUFKdwbRw9QhnYLuEgOxmBGgc+u 21nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=ADVJynzEu+Jj8HRQmkIPKXu4v3kFNTb1/rm/UOxb3+c=; b=dmhXu70sP/917X0hc7CK8OVWf0fO4BYJnuSx/VFdUceqcY+JKptpeOQwDvNEp9QzKg /5ys5wyEDTV+Pcw6gkzf4e+wDRO2r1MTqZNTMw6s04rVKbEz9PLCir4moGr4WsXJFoB1 X0M8GcolRHaLEAP3f+8vxkLd8F4K8znqP6TlMog2g55aNAfgn5CzT9bRgnVenncbxiA/ pfIb6LLCUKncezFGVyhE337VgSEeE+YqHBx1dN4sponWyahGiCMJe9PpoXh3xcCWU310 YrMq5fR98NNGNDPK3jZcwHvL6+lAMu1mKQ/OZQ8vU/ndYIxtVtbtftr8q8iQdoPbpD6C w2tA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c24si14952653pgg.534.2019.02.27.08.06.50; Wed, 27 Feb 2019 08:07:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730159AbfB0QGN (ORCPT + 99 others); Wed, 27 Feb 2019 11:06:13 -0500 Received: from mga02.intel.com ([134.134.136.20]:24153 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729825AbfB0QF5 (ORCPT ); Wed, 27 Feb 2019 11:05:57 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2019 08:05:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,420,1544515200"; d="scan'208";a="303011737" Received: from unknown (HELO luv-build.sc.intel.com) ([172.25.110.25]) by orsmga005.jf.intel.com with ESMTP; 27 Feb 2019 08:05:55 -0800 From: Ricardo Neri To: Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Ashok Raj , Andi Kleen , Peter Zijlstra , "Ravi V. Shankar" , x86@kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , Ricardo Neri , "H. Peter Anvin" , Tony Luck , Clemens Ladisch , Arnd Bergmann , Philippe Ombredanne , Kate Stewart , "Rafael J. Wysocki" , Mimi Zohar , Jan Kiszka , Nick Desaulniers , Masahiro Yamada , Nayna Jain Subject: [RFC PATCH v2 13/14] watchdog/hardlockup/hpet: Only enable the HPET watchdog via a boot parameter Date: Wed, 27 Feb 2019 08:05:17 -0800 Message-Id: <1551283518-18922-14-git-send-email-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551283518-18922-1-git-send-email-ricardo.neri-calderon@linux.intel.com> References: <1551283518-18922-1-git-send-email-ricardo.neri-calderon@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Keep the HPET-based hardlockup detector disabled unless explicitly enabled via a command line argument. If such parameter is not given, the hardlockup detector will fallback to use the perf-based implementation. The function hardlockup_panic_setup() is updated to return 0 in order to to allow __setup functions of specific hardlockup detectors (in this case hardlockup_detector_hpet_setup()) to inspect the nmi_watchdog boot parameter. Cc: "H. Peter Anvin" Cc: Ashok Raj Cc: Andi Kleen Cc: Tony Luck Cc: Peter Zijlstra Cc: Clemens Ladisch Cc: Arnd Bergmann Cc: Philippe Ombredanne Cc: Kate Stewart Cc: "Rafael J. Wysocki" Cc: Mimi Zohar Cc: Jan Kiszka Cc: Nick Desaulniers Cc: Masahiro Yamada Cc: Nayna Jain Cc: "Ravi V. Shankar" Cc: x86@kernel.org Signed-off-by: Ricardo Neri -- checkpatch gives the following warning: CHECK: __setup appears un-documented -- check Documentation/admin-guide/kernel-parameters.rst +__setup("nmi_watchdog=", hardlockup_detector_hpet_setup); This is a false-positive as the option nmi_watchdog is already documented. The option is re-evaluated in this file as well. --- .../admin-guide/kernel-parameters.txt | 6 +++++- arch/x86/kernel/watchdog_hld_hpet.c | 20 +++++++++++++++++++ kernel/watchdog.c | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index cf8f5877d85f..c6270ddeb130 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2739,7 +2739,7 @@ Format: [state][,regs][,debounce][,die] nmi_watchdog= [KNL,BUGS=X86] Debugging features for SMP kernels - Format: [panic,][nopanic,][num] + Format: [panic,][nopanic,][num,][hpet] Valid num: 0 or 1 0 - turn hardlockup detector in nmi_watchdog off 1 - turn hardlockup detector in nmi_watchdog on @@ -2749,6 +2749,10 @@ please see 'nowatchdog'. This is useful when you use a panic=... timeout and need the box quickly up again. + When hpet is specified, the NMI watchdog will be driven + by an HPET timer, if available in the system. Otherwise, + the perf-based implementation will be used. Specifying + hpet implies that nmi_watchdog is on. These settings can be accessed at runtime via the nmi_watchdog and hardlockup_panic sysctls. diff --git a/arch/x86/kernel/watchdog_hld_hpet.c b/arch/x86/kernel/watchdog_hld_hpet.c index 65b4699f249a..4402deff4b77 100644 --- a/arch/x86/kernel/watchdog_hld_hpet.c +++ b/arch/x86/kernel/watchdog_hld_hpet.c @@ -20,6 +20,7 @@ #include static struct hpet_hld_data *hld_data; +static bool hardlockup_use_hpet; /** * get_count() - Get the current count of the HPET timer @@ -391,6 +392,22 @@ void hardlockup_detector_hpet_stop(void) disable_timer(hld_data); } +/** + * hardlockup_detector_hpet_setup() - Parse command-line parameters + * @str: A string containing the kernel command line + * + * Parse the nmi_watchdog parameter from the kernel command line. If + * selected by the user, use this implementation to detect hardlockups. + */ +static int __init hardlockup_detector_hpet_setup(char *str) +{ + if (strstr(str, "hpet")) + hardlockup_use_hpet = true; + + return 0; +} +__setup("nmi_watchdog=", hardlockup_detector_hpet_setup); + /** * hardlockup_detector_hpet_init() - Initialize the hardlockup detector * @@ -405,6 +422,9 @@ int __init hardlockup_detector_hpet_init(void) { int ret; + if (!hardlockup_use_hpet) + return -ENODEV; + if (!is_hpet_enabled()) return -ENODEV; diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 367aa81294ef..28cad7310378 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -78,7 +78,7 @@ static int __init hardlockup_panic_setup(char *str) nmi_watchdog_user_enabled = 0; else if (!strncmp(str, "1", 1)) nmi_watchdog_user_enabled = 1; - return 1; + return 0; } __setup("nmi_watchdog=", hardlockup_panic_setup); -- 2.17.1