aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/watchdog.c
diff options
context:
space:
mode:
authorMandeep Singh Baines <msb@chromium.org>2011-05-23 01:10:22 -0400
committerIngo Molnar <mingo@elte.hu>2011-05-23 05:58:59 -0400
commit586692a5a5fc5740c8a46abc0f2365495c2d7c5f (patch)
treebc08228e67a968d83691c9efc5ea1feda9e6f98b /kernel/watchdog.c
parente04ab2bc41b35c0cb6cdb07c8443f91aa738cf78 (diff)
watchdog: Disable watchdog when thresh is zero
This restores the previous behavior of softlock_thresh. Currently, setting watchdog_thresh to zero causes the watchdog kthreads to consume a lot of CPU. In addition, the logic of proc_dowatchdog_thresh and proc_dowatchdog_enabled has been factored into proc_dowatchdog. Signed-off-by: Mandeep Singh Baines <msb@chromium.org> Cc: Marcin Slusarz <marcin.slusarz@gmail.com> Cc: Don Zickus <dzickus@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Frederic Weisbecker <fweisbec@gmail.com> Link: http://lkml.kernel.org/r/1306127423-3347-3-git-send-email-msb@chromium.org Signed-off-by: Ingo Molnar <mingo@elte.hu> LKML-Reference: <20110517071018.GE22305@elte.hu>
Diffstat (limited to 'kernel/watchdog.c')
-rw-r--r--kernel/watchdog.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index cf0e09f452e7..60301916f62e 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -28,7 +28,7 @@
28#include <linux/perf_event.h> 28#include <linux/perf_event.h>
29 29
30int watchdog_enabled = 1; 30int watchdog_enabled = 1;
31int __read_mostly softlockup_thresh = 60; 31int __read_mostly watchdog_thresh = 60;
32 32
33static DEFINE_PER_CPU(unsigned long, watchdog_touch_ts); 33static DEFINE_PER_CPU(unsigned long, watchdog_touch_ts);
34static DEFINE_PER_CPU(struct task_struct *, softlockup_watchdog); 34static DEFINE_PER_CPU(struct task_struct *, softlockup_watchdog);
@@ -105,12 +105,12 @@ static unsigned long get_timestamp(int this_cpu)
105static unsigned long get_sample_period(void) 105static unsigned long get_sample_period(void)
106{ 106{
107 /* 107 /*
108 * convert softlockup_thresh from seconds to ns 108 * convert watchdog_thresh from seconds to ns
109 * the divide by 5 is to give hrtimer 5 chances to 109 * the divide by 5 is to give hrtimer 5 chances to
110 * increment before the hardlockup detector generates 110 * increment before the hardlockup detector generates
111 * a warning 111 * a warning
112 */ 112 */
113 return softlockup_thresh * (NSEC_PER_SEC / 5); 113 return watchdog_thresh * (NSEC_PER_SEC / 5);
114} 114}
115 115
116/* Commands for resetting the watchdog */ 116/* Commands for resetting the watchdog */
@@ -182,7 +182,7 @@ static int is_softlockup(unsigned long touch_ts)
182 unsigned long now = get_timestamp(smp_processor_id()); 182 unsigned long now = get_timestamp(smp_processor_id());
183 183
184 /* Warn about unreasonable delays: */ 184 /* Warn about unreasonable delays: */
185 if (time_after(now, touch_ts + softlockup_thresh)) 185 if (time_after(now, touch_ts + watchdog_thresh))
186 return now - touch_ts; 186 return now - touch_ts;
187 187
188 return 0; 188 return 0;
@@ -501,19 +501,19 @@ static void watchdog_disable_all_cpus(void)
501/* sysctl functions */ 501/* sysctl functions */
502#ifdef CONFIG_SYSCTL 502#ifdef CONFIG_SYSCTL
503/* 503/*
504 * proc handler for /proc/sys/kernel/nmi_watchdog 504 * proc handler for /proc/sys/kernel/nmi_watchdog,watchdog_thresh
505 */ 505 */
506 506
507int proc_dowatchdog_enabled(struct ctl_table *table, int write, 507int proc_dowatchdog(struct ctl_table *table, int write,
508 void __user *buffer, size_t *length, loff_t *ppos) 508 void __user *buffer, size_t *lenp, loff_t *ppos)
509{ 509{
510 int ret; 510 int ret;
511 511
512 ret = proc_dointvec(table, write, buffer, length, ppos); 512 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
513 if (ret || !write) 513 if (ret || !write)
514 goto out; 514 goto out;
515 515
516 if (watchdog_enabled) 516 if (watchdog_enabled && watchdog_thresh)
517 watchdog_enable_all_cpus(); 517 watchdog_enable_all_cpus();
518 else 518 else
519 watchdog_disable_all_cpus(); 519 watchdog_disable_all_cpus();
@@ -521,13 +521,6 @@ int proc_dowatchdog_enabled(struct ctl_table *table, int write,
521out: 521out:
522 return ret; 522 return ret;
523} 523}
524
525int proc_dowatchdog_thresh(struct ctl_table *table, int write,
526 void __user *buffer,
527 size_t *lenp, loff_t *ppos)
528{
529 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
530}
531#endif /* CONFIG_SYSCTL */ 524#endif /* CONFIG_SYSCTL */
532 525
533 526