diff options
author | Bjørn Mork <bjorn@mork.no> | 2012-12-19 14:51:31 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-19 15:10:33 -0500 |
commit | 3935e89505a1c3ab3f3b0c7ef0eae54124f48905 (patch) | |
tree | 8cfa921612d9596b2baf98f23f7e797092bcaf11 | |
parent | 74779e22261172ea728b989310f6ecc991b57d62 (diff) |
watchdog: Fix disable/enable regression
Commit 8d4516904b39 ("watchdog: Fix CPU hotplug regression") causes an
oops or hard lockup when doing
echo 0 > /proc/sys/kernel/nmi_watchdog
echo 1 > /proc/sys/kernel/nmi_watchdog
and the kernel is booted with nmi_watchdog=1 (default)
Running laptop-mode-tools and disconnecting/connecting AC power will
cause this to trigger, making it a common failure scenario on laptops.
Instead of bailing out of watchdog_disable() when !watchdog_enabled we
can initialize the hrtimer regardless of watchdog_enabled status. This
makes it safe to call watchdog_disable() in the nmi_watchdog=0 case,
without the negative effect on the enabled => disabled => enabled case.
All these tests pass with this patch:
- nmi_watchdog=1
echo 0 > /proc/sys/kernel/nmi_watchdog
echo 1 > /proc/sys/kernel/nmi_watchdog
- nmi_watchdog=0
echo 0 > /sys/devices/system/cpu/cpu1/online
- nmi_watchdog=0
echo mem > /sys/power/state
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=51661
Cc: <stable@vger.kernel.org> # v3.7
Cc: Norbert Warmuth <nwarmuth@t-online.de>
Cc: Joseph Salisbury <joseph.salisbury@canonical.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | kernel/watchdog.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 997c6a16ec22..75a2ab3d0b02 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c | |||
@@ -344,6 +344,10 @@ static void watchdog_enable(unsigned int cpu) | |||
344 | { | 344 | { |
345 | struct hrtimer *hrtimer = &__raw_get_cpu_var(watchdog_hrtimer); | 345 | struct hrtimer *hrtimer = &__raw_get_cpu_var(watchdog_hrtimer); |
346 | 346 | ||
347 | /* kick off the timer for the hardlockup detector */ | ||
348 | hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); | ||
349 | hrtimer->function = watchdog_timer_fn; | ||
350 | |||
347 | if (!watchdog_enabled) { | 351 | if (!watchdog_enabled) { |
348 | kthread_park(current); | 352 | kthread_park(current); |
349 | return; | 353 | return; |
@@ -352,10 +356,6 @@ static void watchdog_enable(unsigned int cpu) | |||
352 | /* Enable the perf event */ | 356 | /* Enable the perf event */ |
353 | watchdog_nmi_enable(cpu); | 357 | watchdog_nmi_enable(cpu); |
354 | 358 | ||
355 | /* kick off the timer for the hardlockup detector */ | ||
356 | hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); | ||
357 | hrtimer->function = watchdog_timer_fn; | ||
358 | |||
359 | /* done here because hrtimer_start can only pin to smp_processor_id() */ | 359 | /* done here because hrtimer_start can only pin to smp_processor_id() */ |
360 | hrtimer_start(hrtimer, ns_to_ktime(sample_period), | 360 | hrtimer_start(hrtimer, ns_to_ktime(sample_period), |
361 | HRTIMER_MODE_REL_PINNED); | 361 | HRTIMER_MODE_REL_PINNED); |
@@ -369,9 +369,6 @@ static void watchdog_disable(unsigned int cpu) | |||
369 | { | 369 | { |
370 | struct hrtimer *hrtimer = &__raw_get_cpu_var(watchdog_hrtimer); | 370 | struct hrtimer *hrtimer = &__raw_get_cpu_var(watchdog_hrtimer); |
371 | 371 | ||
372 | if (!watchdog_enabled) | ||
373 | return; | ||
374 | |||
375 | watchdog_set_prio(SCHED_NORMAL, 0); | 372 | watchdog_set_prio(SCHED_NORMAL, 0); |
376 | hrtimer_cancel(hrtimer); | 373 | hrtimer_cancel(hrtimer); |
377 | /* disable the perf event */ | 374 | /* disable the perf event */ |