Commit 3c00ea82 authored by Frederic Weisbecker's avatar Frederic Weisbecker

watchdog: Rename confusing state variable

We have two very conflicting state variable names in the
watchdog:

* watchdog_enabled: This one reflects the user interface. It's
set to 1 by default and can be overriden with boot options
or sysctl/procfs interface.

* watchdog_disabled: This is the internal toggle state that
tells if watchdog threads, timers and NMI events are currently
running or not. This state mostly depends on the user settings.
It's a convenient state latch.

Now we really need to find clearer names because those
are just too confusing to encourage deep review.

watchdog_enabled now becomes watchdog_user_enabled to reflect
its purpose as an interface.

watchdog_disabled becomes watchdog_running to suggest its
role as a pure internal state.
Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Anish Singh <anish198519851985@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Li Zhong <zhong@linux.vnet.ibm.com>
Cc: Don Zickus <dzickus@redhat.com>
parent b8900bc0
...@@ -46,7 +46,7 @@ static inline bool trigger_all_cpu_backtrace(void) ...@@ -46,7 +46,7 @@ static inline bool trigger_all_cpu_backtrace(void)
#ifdef CONFIG_LOCKUP_DETECTOR #ifdef CONFIG_LOCKUP_DETECTOR
int hw_nmi_is_cpu_stuck(struct pt_regs *); int hw_nmi_is_cpu_stuck(struct pt_regs *);
u64 hw_nmi_get_sample_period(int watchdog_thresh); u64 hw_nmi_get_sample_period(int watchdog_thresh);
extern int watchdog_enabled; extern int watchdog_user_enabled;
extern int watchdog_thresh; extern int watchdog_thresh;
struct ctl_table; struct ctl_table;
extern int proc_dowatchdog(struct ctl_table *, int , extern int proc_dowatchdog(struct ctl_table *, int ,
......
...@@ -801,7 +801,7 @@ static struct ctl_table kern_table[] = { ...@@ -801,7 +801,7 @@ static struct ctl_table kern_table[] = {
#if defined(CONFIG_LOCKUP_DETECTOR) #if defined(CONFIG_LOCKUP_DETECTOR)
{ {
.procname = "watchdog", .procname = "watchdog",
.data = &watchdog_enabled, .data = &watchdog_user_enabled,
.maxlen = sizeof (int), .maxlen = sizeof (int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dowatchdog, .proc_handler = proc_dowatchdog,
...@@ -828,7 +828,7 @@ static struct ctl_table kern_table[] = { ...@@ -828,7 +828,7 @@ static struct ctl_table kern_table[] = {
}, },
{ {
.procname = "nmi_watchdog", .procname = "nmi_watchdog",
.data = &watchdog_enabled, .data = &watchdog_user_enabled,
.maxlen = sizeof (int), .maxlen = sizeof (int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dowatchdog, .proc_handler = proc_dowatchdog,
......
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
#include <linux/kvm_para.h> #include <linux/kvm_para.h>
#include <linux/perf_event.h> #include <linux/perf_event.h>
int watchdog_enabled = 1; int watchdog_user_enabled = 1;
int __read_mostly watchdog_thresh = 10; int __read_mostly watchdog_thresh = 10;
static int __read_mostly watchdog_disabled = 1; static int __read_mostly watchdog_running;
static u64 __read_mostly sample_period; static u64 __read_mostly sample_period;
static DEFINE_PER_CPU(unsigned long, watchdog_touch_ts); static DEFINE_PER_CPU(unsigned long, watchdog_touch_ts);
...@@ -63,7 +63,7 @@ static int __init hardlockup_panic_setup(char *str) ...@@ -63,7 +63,7 @@ static int __init hardlockup_panic_setup(char *str)
else if (!strncmp(str, "nopanic", 7)) else if (!strncmp(str, "nopanic", 7))
hardlockup_panic = 0; hardlockup_panic = 0;
else if (!strncmp(str, "0", 1)) else if (!strncmp(str, "0", 1))
watchdog_enabled = 0; watchdog_user_enabled = 0;
return 1; return 1;
} }
__setup("nmi_watchdog=", hardlockup_panic_setup); __setup("nmi_watchdog=", hardlockup_panic_setup);
...@@ -82,7 +82,7 @@ __setup("softlockup_panic=", softlockup_panic_setup); ...@@ -82,7 +82,7 @@ __setup("softlockup_panic=", softlockup_panic_setup);
static int __init nowatchdog_setup(char *str) static int __init nowatchdog_setup(char *str)
{ {
watchdog_enabled = 0; watchdog_user_enabled = 0;
return 1; return 1;
} }
__setup("nowatchdog", nowatchdog_setup); __setup("nowatchdog", nowatchdog_setup);
...@@ -90,7 +90,7 @@ __setup("nowatchdog", nowatchdog_setup); ...@@ -90,7 +90,7 @@ __setup("nowatchdog", nowatchdog_setup);
/* deprecated */ /* deprecated */
static int __init nosoftlockup_setup(char *str) static int __init nosoftlockup_setup(char *str)
{ {
watchdog_enabled = 0; watchdog_user_enabled = 0;
return 1; return 1;
} }
__setup("nosoftlockup", nosoftlockup_setup); __setup("nosoftlockup", nosoftlockup_setup);
...@@ -158,7 +158,7 @@ void touch_all_softlockup_watchdogs(void) ...@@ -158,7 +158,7 @@ void touch_all_softlockup_watchdogs(void)
#ifdef CONFIG_HARDLOCKUP_DETECTOR #ifdef CONFIG_HARDLOCKUP_DETECTOR
void touch_nmi_watchdog(void) void touch_nmi_watchdog(void)
{ {
if (watchdog_enabled) { if (watchdog_user_enabled) {
unsigned cpu; unsigned cpu;
for_each_present_cpu(cpu) { for_each_present_cpu(cpu) {
...@@ -490,12 +490,12 @@ static int watchdog_enable_all_cpus(void) ...@@ -490,12 +490,12 @@ static int watchdog_enable_all_cpus(void)
{ {
int err = 0; int err = 0;
if (watchdog_disabled) { if (!watchdog_running) {
err = smpboot_register_percpu_thread(&watchdog_threads); err = smpboot_register_percpu_thread(&watchdog_threads);
if (err) if (err)
pr_err("Failed to create watchdog threads, disabled\n"); pr_err("Failed to create watchdog threads, disabled\n");
else else
watchdog_disabled = 0; watchdog_running = 1;
} }
return err; return err;
...@@ -506,8 +506,8 @@ static int watchdog_enable_all_cpus(void) ...@@ -506,8 +506,8 @@ static int watchdog_enable_all_cpus(void)
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
static void watchdog_disable_all_cpus(void) static void watchdog_disable_all_cpus(void)
{ {
if (!watchdog_disabled) { if (watchdog_running) {
watchdog_disabled = 1; watchdog_running = 0;
smpboot_unregister_percpu_thread(&watchdog_threads); smpboot_unregister_percpu_thread(&watchdog_threads);
} }
} }
...@@ -522,7 +522,7 @@ int proc_dowatchdog(struct ctl_table *table, int write, ...@@ -522,7 +522,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
int err, old_thresh, old_enabled; int err, old_thresh, old_enabled;
old_thresh = ACCESS_ONCE(watchdog_thresh); old_thresh = ACCESS_ONCE(watchdog_thresh);
old_enabled = ACCESS_ONCE(watchdog_enabled); old_enabled = ACCESS_ONCE(watchdog_user_enabled);
err = proc_dointvec_minmax(table, write, buffer, lenp, ppos); err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
if (err || !write) if (err || !write)
...@@ -531,10 +531,10 @@ int proc_dowatchdog(struct ctl_table *table, int write, ...@@ -531,10 +531,10 @@ int proc_dowatchdog(struct ctl_table *table, int write,
set_sample_period(); set_sample_period();
/* /*
* Watchdog threads shouldn't be enabled if they are * Watchdog threads shouldn't be enabled if they are
* disabled. The 'watchdog_disabled' variable check in * disabled. The 'watchdog_running' variable check in
* watchdog_*_all_cpus() function takes care of this. * watchdog_*_all_cpus() function takes care of this.
*/ */
if (watchdog_enabled && watchdog_thresh) if (watchdog_user_enabled && watchdog_thresh)
err = watchdog_enable_all_cpus(); err = watchdog_enable_all_cpus();
else else
watchdog_disable_all_cpus(); watchdog_disable_all_cpus();
...@@ -542,7 +542,7 @@ int proc_dowatchdog(struct ctl_table *table, int write, ...@@ -542,7 +542,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
/* Restore old values on failure */ /* Restore old values on failure */
if (err) { if (err) {
watchdog_thresh = old_thresh; watchdog_thresh = old_thresh;
watchdog_enabled = old_enabled; watchdog_user_enabled = old_enabled;
} }
return err; return err;
...@@ -553,6 +553,6 @@ void __init lockup_detector_init(void) ...@@ -553,6 +553,6 @@ void __init lockup_detector_init(void)
{ {
set_sample_period(); set_sample_period();
if (watchdog_enabled) if (watchdog_user_enabled)
watchdog_enable_all_cpus(); watchdog_enable_all_cpus();
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment