Keep the HPET-based hardlockup detector disabled unless explicitly enabled
via a command-line argument. If such parameter is not given, the
initialization of the HPET-based hardlockup detector fails and the NMI
watchdog will fall back to use the perf-based implementation.

Cc: Andi Kleen <a...@linux.intel.com>
Cc: Stephane Eranian <eran...@google.com>
Cc: "Ravi V. Shankar" <ravi.v.shan...@intel.com>
Cc: io...@lists.linux-foundation.org
Cc: linuxppc-dev@lists.ozlabs.org
Reviewed-by: Tony Luck <tony.l...@intel.com>
Signed-off-by: Ricardo Neri <ricardo.neri-calde...@linux.intel.com>
--
Changes since v6:
 * Do not reuse the nmi_watchdog command line option. Instead, use a
   separate command line option. (Nicholas Piggin)
 * Document conflict with conflict between `hpet_nmi_watchdog` and
   `nohz_full` and dependency on `no_ipi_broadcast`.

Changes since v5:
 * None

Changes since v4:
 * None

Changes since v3:
 * None

Changes since v2:
 * Do not imply that using nmi_watchdog=hpet means the detector is
   enabled. Instead, print a warning in such case.

Changes since v1:
 * Added documentation to the function handing the nmi_watchdog
   kernel command-line argument.
---
 Documentation/admin-guide/kernel-parameters.txt |  8 ++++++++
 arch/x86/kernel/watchdog_hld_hpet.c             | 17 +++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index 46268d6baa43..2d1262bb99c7 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1708,6 +1708,14 @@
        hpet_mmap=      [X86, HPET_MMAP] Allow userspace to mmap HPET
                        registers.  Default set by CONFIG_HPET_MMAP_DEFAULT.
 
+       hpet_nmi_watchdog [X86, KNL]
+                       Drive the NMI watchdog with an HPET channel. This option
+                       has no effect if the NMI watchdog is not enabled.
+                       The HPET NMI watchdog conflicts with the parameters
+                       nohz_full, no_ipi_broadcast, and hpet=disable. If any
+                       of these parameters is present the NMI watchdog will
+                       fall back to the perf-driven implementation.
+
        hugepages=      [HW] Number of HugeTLB pages to allocate at boot.
                        If this follows hugepagesz (below), it specifies
                        the number of pages of hugepagesz to be allocated.
diff --git a/arch/x86/kernel/watchdog_hld_hpet.c 
b/arch/x86/kernel/watchdog_hld_hpet.c
index a03126e02eda..0fc728ad6f15 100644
--- a/arch/x86/kernel/watchdog_hld_hpet.c
+++ b/arch/x86/kernel/watchdog_hld_hpet.c
@@ -39,6 +39,7 @@
 #include "apic/local.h"
 
 static struct hpet_hld_data *hld_data;
+static bool hardlockup_use_hpet;
 static u64 tsc_next_error;
 
 static void __init setup_hpet_channel(struct hpet_hld_data *hdata)
@@ -366,6 +367,19 @@ void hardlockup_detector_hpet_start(void)
        enable_timer(hld_data);
 }
 
+/**
+ * hardlockup_detector_hpet_setup() - Parse command-line parameters
+ * @str:       A string containing the kernel command line
+ *
+ * If selected by the user, enable this hardlockup detector.
+ */
+static int __init hardlockup_detector_hpet_setup(char *str)
+{
+       hardlockup_use_hpet = true;
+       return 1;
+}
+__setup("hpet_nmi_watchdog", hardlockup_detector_hpet_setup);
+
 static const char hpet_hld_init_failed[] = "Initialization failed:";
 
 /**
@@ -382,6 +396,9 @@ int __init hardlockup_detector_hpet_init(void)
 {
        int ret;
 
+       if (!hardlockup_use_hpet)
+               return -ENODEV;
+
        if (!is_hpet_enabled()) {
                pr_info("%s HPET unavailable\n", hpet_hld_init_failed);
                return -ENODEV;
-- 
2.25.1

Reply via email to