Merge branch 'linus' into core/urgent, to pick up dependent commits
[linux-2.6-microblaze.git] / kernel / watchdog_hld.c
index a7f137c..e449a23 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Detect hard lockups on a system
  *
@@ -12,6 +13,7 @@
 #define pr_fmt(fmt) "NMI watchdog: " fmt
 
 #include <linux/nmi.h>
+#include <linux/atomic.h>
 #include <linux/module.h>
 #include <linux/sched/debug.h>
 
@@ -25,7 +27,7 @@ static DEFINE_PER_CPU(struct perf_event *, dead_event);
 static struct cpumask dead_events_mask;
 
 static unsigned long hardlockup_allcpu_dumped;
-static unsigned int watchdog_cpus;
+static atomic_t watchdog_cpus = ATOMIC_INIT(0);
 
 void arch_touch_nmi_watchdog(void)
 {
@@ -189,7 +191,8 @@ void hardlockup_detector_perf_enable(void)
        if (hardlockup_detector_event_create())
                return;
 
-       if (!watchdog_cpus++)
+       /* use original value for check */
+       if (!atomic_fetch_inc(&watchdog_cpus))
                pr_info("Enabled. Permanently consumes one hw-PMU counter.\n");
 
        perf_event_enable(this_cpu_read(watchdog_ev));
@@ -207,7 +210,7 @@ void hardlockup_detector_perf_disable(void)
                this_cpu_write(watchdog_ev, NULL);
                this_cpu_write(dead_event, event);
                cpumask_set_cpu(smp_processor_id(), &dead_events_mask);
-               watchdog_cpus--;
+               atomic_dec(&watchdog_cpus);
        }
 }