aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/watchdog.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2013-05-19 14:45:15 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2013-06-20 09:41:18 -0400
commit3c00ea82c724fab0b98f15428a804cb45eb9ad38 (patch)
tree3e380db50cf9bc5d2962c25cc80707bfd9fc834c /kernel/watchdog.c
parentb8900bc0217fac8e68085997bee2f05e6db931a2 (diff)
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: Frederic 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>
Diffstat (limited to 'kernel/watchdog.c')
-rw-r--r--kernel/watchdog.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 52c9a9b91bdd..51c4f34d258e 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -29,9 +29,9 @@
29#include <linux/kvm_para.h> 29#include <linux/kvm_para.h>
30#include <linux/perf_event.h> 30#include <linux/perf_event.h>
31 31
32int watchdog_enabled = 1; 32int watchdog_user_enabled = 1;
33int __read_mostly watchdog_thresh = 10; 33int __read_mostly watchdog_thresh = 10;
34static int __read_mostly watchdog_disabled = 1; 34static int __read_mostly watchdog_running;
35static u64 __read_mostly sample_period; 35static u64 __read_mostly sample_period;
36 36
37static DEFINE_PER_CPU(unsigned long, watchdog_touch_ts); 37static DEFINE_PER_CPU(unsigned long, watchdog_touch_ts);
@@ -63,7 +63,7 @@ static int __init hardlockup_panic_setup(char *str)
63 else if (!strncmp(str, "nopanic", 7)) 63 else if (!strncmp(str, "nopanic", 7))
64 hardlockup_panic = 0; 64 hardlockup_panic = 0;
65 else if (!strncmp(str, "0", 1)) 65 else if (!strncmp(str, "0", 1))
66 watchdog_enabled = 0; 66 watchdog_user_enabled = 0;
67 return 1; 67 return 1;
68} 68}
69__setup("nmi_watchdog=", hardlockup_panic_setup); 69__setup("nmi_watchdog=", hardlockup_panic_setup);
@@ -82,7 +82,7 @@ __setup("softlockup_panic=", softlockup_panic_setup);
82 82
83static int __init nowatchdog_setup(char *str) 83static int __init nowatchdog_setup(char *str)
84{ 84{
85 watchdog_enabled = 0; 85 watchdog_user_enabled = 0;
86 return 1; 86 return 1;
87} 87}
88__setup("nowatchdog", nowatchdog_setup); 88__setup("nowatchdog", nowatchdog_setup);
@@ -90,7 +90,7 @@ __setup("nowatchdog", nowatchdog_setup);
90/* deprecated */ 90/* deprecated */
91static int __init nosoftlockup_setup(char *str) 91static int __init nosoftlockup_setup(char *str)
92{ 92{
93 watchdog_enabled = 0; 93 watchdog_user_enabled = 0;
94 return 1; 94 return 1;
95} 95}
96__setup("nosoftlockup", nosoftlockup_setup); 96__setup("nosoftlockup", nosoftlockup_setup);
@@ -158,7 +158,7 @@ void touch_all_softlockup_watchdogs(void)
158#ifdef CONFIG_HARDLOCKUP_DETECTOR 158#ifdef CONFIG_HARDLOCKUP_DETECTOR
159void touch_nmi_watchdog(void) 159void touch_nmi_watchdog(void)
160{ 160{
161 if (watchdog_enabled) { 161 if (watchdog_user_enabled) {
162 unsigned cpu; 162 unsigned cpu;
163 163
164 for_each_present_cpu(cpu) { 164 for_each_present_cpu(cpu) {
@@ -490,12 +490,12 @@ static int watchdog_enable_all_cpus(void)
490{ 490{
491 int err = 0; 491 int err = 0;
492 492
493 if (watchdog_disabled) { 493 if (!watchdog_running) {
494 err = smpboot_register_percpu_thread(&watchdog_threads); 494 err = smpboot_register_percpu_thread(&watchdog_threads);
495 if (err) 495 if (err)
496 pr_err("Failed to create watchdog threads, disabled\n"); 496 pr_err("Failed to create watchdog threads, disabled\n");
497 else 497 else
498 watchdog_disabled = 0; 498 watchdog_running = 1;
499 } 499 }
500 500
501 return err; 501 return err;
@@ -506,8 +506,8 @@ static int watchdog_enable_all_cpus(void)
506#ifdef CONFIG_SYSCTL 506#ifdef CONFIG_SYSCTL
507static void watchdog_disable_all_cpus(void) 507static void watchdog_disable_all_cpus(void)
508{ 508{
509 if (!watchdog_disabled) { 509 if (watchdog_running) {
510 watchdog_disabled = 1; 510 watchdog_running = 0;
511 smpboot_unregister_percpu_thread(&watchdog_threads); 511 smpboot_unregister_percpu_thread(&watchdog_threads);
512 } 512 }
513} 513}
@@ -522,7 +522,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
522 int err, old_thresh, old_enabled; 522 int err, old_thresh, old_enabled;
523 523
524 old_thresh = ACCESS_ONCE(watchdog_thresh); 524 old_thresh = ACCESS_ONCE(watchdog_thresh);
525 old_enabled = ACCESS_ONCE(watchdog_enabled); 525 old_enabled = ACCESS_ONCE(watchdog_user_enabled);
526 526
527 err = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 527 err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
528 if (err || !write) 528 if (err || !write)
@@ -531,10 +531,10 @@ int proc_dowatchdog(struct ctl_table *table, int write,
531 set_sample_period(); 531 set_sample_period();
532 /* 532 /*
533 * Watchdog threads shouldn't be enabled if they are 533 * Watchdog threads shouldn't be enabled if they are
534 * disabled. The 'watchdog_disabled' variable check in 534 * disabled. The 'watchdog_running' variable check in
535 * watchdog_*_all_cpus() function takes care of this. 535 * watchdog_*_all_cpus() function takes care of this.
536 */ 536 */
537 if (watchdog_enabled && watchdog_thresh) 537 if (watchdog_user_enabled && watchdog_thresh)
538 err = watchdog_enable_all_cpus(); 538 err = watchdog_enable_all_cpus();
539 else 539 else
540 watchdog_disable_all_cpus(); 540 watchdog_disable_all_cpus();
@@ -542,7 +542,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
542 /* Restore old values on failure */ 542 /* Restore old values on failure */
543 if (err) { 543 if (err) {
544 watchdog_thresh = old_thresh; 544 watchdog_thresh = old_thresh;
545 watchdog_enabled = old_enabled; 545 watchdog_user_enabled = old_enabled;
546 } 546 }
547 547
548 return err; 548 return err;
@@ -553,6 +553,6 @@ void __init lockup_detector_init(void)
553{ 553{
554 set_sample_period(); 554 set_sample_period();
555 555
556 if (watchdog_enabled) 556 if (watchdog_user_enabled)
557 watchdog_enable_all_cpus(); 557 watchdog_enable_all_cpus();
558} 558}