Commit 586692a5a5fc5740c8a46abc0f2365495c2d7c5f

Authored by Mandeep Singh Baines
Committed by Ingo Molnar
1 parent e04ab2bc41

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>

Showing 4 changed files with 20 additions and 23 deletions Side-by-side Diff

... ... @@ -47,9 +47,10 @@
47 47 int hw_nmi_is_cpu_stuck(struct pt_regs *);
48 48 u64 hw_nmi_get_sample_period(void);
49 49 extern int watchdog_enabled;
  50 +extern int watchdog_thresh;
50 51 struct ctl_table;
51   -extern int proc_dowatchdog_enabled(struct ctl_table *, int ,
52   - void __user *, size_t *, loff_t *);
  52 +extern int proc_dowatchdog(struct ctl_table *, int ,
  53 + void __user *, size_t *, loff_t *);
53 54 #endif
54 55  
55 56 #endif
include/linux/sched.h
... ... @@ -315,7 +315,6 @@
315 315 void __user *buffer,
316 316 size_t *lenp, loff_t *ppos);
317 317 extern unsigned int softlockup_panic;
318   -extern int softlockup_thresh;
319 318 void lockup_detector_init(void);
320 319 #else
321 320 static inline void touch_softlockup_watchdog(void)
... ... @@ -730,14 +730,16 @@
730 730 .data = &watchdog_enabled,
731 731 .maxlen = sizeof (int),
732 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 738 .procname = "watchdog_thresh",
737   - .data = &softlockup_thresh,
  739 + .data = &watchdog_thresh,
738 740 .maxlen = sizeof(int),
739 741 .mode = 0644,
740   - .proc_handler = proc_dowatchdog_thresh,
  742 + .proc_handler = proc_dowatchdog,
741 743 .extra1 = &neg_one,
742 744 .extra2 = &sixty,
743 745 },
... ... @@ -755,7 +757,9 @@
755 757 .data = &watchdog_enabled,
756 758 .maxlen = sizeof (int),
757 759 .mode = 0644,
758   - .proc_handler = proc_dowatchdog_enabled,
  760 + .proc_handler = proc_dowatchdog,
  761 + .extra1 = &zero,
  762 + .extra2 = &one,
759 763 },
760 764 #endif
761 765 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
... ... @@ -28,7 +28,7 @@
28 28 #include <linux/perf_event.h>
29 29  
30 30 int watchdog_enabled = 1;
31   -int __read_mostly softlockup_thresh = 60;
  31 +int __read_mostly watchdog_thresh = 60;
32 32  
33 33 static DEFINE_PER_CPU(unsigned long, watchdog_touch_ts);
34 34 static DEFINE_PER_CPU(struct task_struct *, softlockup_watchdog);
35 35  
... ... @@ -105,12 +105,12 @@
105 105 static 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 109 * the divide by 5 is to give hrtimer 5 chances to
110 110 * increment before the hardlockup detector generates
111 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 116 /* Commands for resetting the watchdog */
... ... @@ -182,7 +182,7 @@
182 182 unsigned long now = get_timestamp(smp_processor_id());
183 183  
184 184 /* Warn about unreasonable delays: */
185   - if (time_after(now, touch_ts + softlockup_thresh))
  185 + if (time_after(now, touch_ts + watchdog_thresh))
186 186 return now - touch_ts;
187 187  
188 188 return 0;
189 189  
190 190  
191 191  
192 192  
... ... @@ -501,32 +501,25 @@
501 501 /* sysctl functions */
502 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  
507   -int proc_dowatchdog_enabled(struct ctl_table *table, int write,
508   - void __user *buffer, size_t *length, loff_t *ppos)
  507 +int proc_dowatchdog(struct ctl_table *table, int write,
  508 + void __user *buffer, size_t *lenp, loff_t *ppos)
509 509 {
510 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 513 if (ret || !write)
514 514 goto out;
515 515  
516   - if (watchdog_enabled)
  516 + if (watchdog_enabled && watchdog_thresh)
517 517 watchdog_enable_all_cpus();
518 518 else
519 519 watchdog_disable_all_cpus();
520 520  
521 521 out:
522 522 return ret;
523   -}
524   -
525   -int 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 523 }
531 524 #endif /* CONFIG_SYSCTL */
532 525