Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Mandeep Singh Baines and committed by
Ingo Molnar
586692a5 e04ab2bc

+20 -23
+3 -2
include/linux/nmi.h
··· 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
-1
include/linux/sched.h
··· 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)
+8 -4
kernel/sysctl.c
··· 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 }, ··· 757 755 .data = &watchdog_enabled, 758 756 .maxlen = sizeof (int), 759 757 .mode = 0644, 760 - .proc_handler = proc_dowatchdog_enabled, 758 + .proc_handler = proc_dowatchdog, 759 + .extra1 = &zero, 760 + .extra2 = &one, 761 761 }, 762 762 #endif 763 763 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
+9 -16
kernel/watchdog.c
··· 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); ··· 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 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; ··· 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