aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
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
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')
-rw-r--r--kernel/sysctl.c12
-rw-r--r--kernel/watchdog.c25
2 files changed, 17 insertions, 20 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index c0bb32414b17..3dd0c46fa3bb 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -730,14 +730,16 @@ static struct ctl_table kern_table[] = {
730 .data = &watchdog_enabled, 730 .data = &watchdog_enabled,
731 .maxlen = sizeof (int), 731 .maxlen = sizeof (int),
732 .mode = 0644, 732 .mode = 0644,
733 .proc_handler = proc_dowatchdog_enabled, 733 .proc_handler = proc_dowatchdog,
734 .extra1 = &zero,
735 .extra2 = &one,
734 }, 736 },
735 { 737 {
736 .procname = "watchdog_thresh", 738 .procname = "watchdog_thresh",
737 .data = &softlockup_thresh, 739 .data = &watchdog_thresh,
738 .maxlen = sizeof(int), 740 .maxlen = sizeof(int),
739 .mode = 0644, 741 .mode = 0644,
740 .proc_handler = proc_dowatchdog_thresh, 742 .proc_handler = proc_dowatchdog,
741 .extra1 = &neg_one, 743 .extra1 = &neg_one,
742 .extra2 = &sixty, 744 .extra2 = &sixty,
743 }, 745 },
@@ -755,7 +757,9 @@ static struct ctl_table kern_table[] = {
755 .data = &watchdog_enabled, 757 .data = &watchdog_enabled,
756 .maxlen = sizeof (int), 758 .maxlen = sizeof (int),
757 .mode = 0644, 759 .mode = 0644,
758 .proc_handler = proc_dowatchdog_enabled, 760 .proc_handler = proc_dowatchdog,
761 .extra1 = &zero,
762 .extra2 = &one,
759 }, 763 },
760#endif 764#endif
761#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 765#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
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