NMI watchdog: fix for lockup detector breakage on resume

On the suspend/resume path the boot CPU does not go though an
offline->online transition.  This breaks the NMI detector post-resume
since it depends on PMU state that is lost when the system gets
suspended.

Fix this by forcing a CPU offline->online transition for the lockup
detector on the boot CPU during resume.

To provide more context, we enable NMI watchdog on Chrome OS.  We have
seen several reports of systems freezing up completely which indicated
that the NMI watchdog was not firing for some reason.

Debugging further, we found a simple way of repro'ing system freezes --
issuing the command 'tasket 1 sh -c "echo nmilockup > /proc/breakme"'
after the system has been suspended/resumed one or more times.

With this patch in place, the system freeze result in panics, as
expected.

These panics provide a nice stack trace for us to debug the actual issue
causing the freeze.

[akpm@linux-foundation.org: fiddle with code comment]
[akpm@linux-foundation.org: make lockup_detector_bootcpu_resume() conditional on CONFIG_SUSPEND]
[akpm@linux-foundation.org: fix section errors]
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Mandeep Singh Baines <msb@chromium.org>
Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Sameer Nanda 2012-07-30 14:40:00 -07:00 committed by Linus Torvalds
parent 190320c3b6
commit 45226e944c
3 changed files with 30 additions and 2 deletions

View File

@ -334,6 +334,14 @@ static inline void lockup_detector_init(void)
}
#endif
#if defined(CONFIG_LOCKUP_DETECTOR) && defined(CONFIG_SUSPEND)
void lockup_detector_bootcpu_resume(void);
#else
static inline void lockup_detector_bootcpu_resume(void)
{
}
#endif
#ifdef CONFIG_DETECT_HUNG_TASK
extern unsigned int sysctl_hung_task_panic;
extern unsigned long sysctl_hung_task_check_count;

View File

@ -178,6 +178,9 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
arch_suspend_enable_irqs();
BUG_ON(irqs_disabled());
/* Kick the lockup detector */
lockup_detector_bootcpu_resume();
Enable_cpus:
enable_nonboot_cpus();

View File

@ -575,7 +575,7 @@ out:
/*
* Create/destroy watchdog threads as CPUs come and go:
*/
static int __cpuinit
static int
cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
{
int hotcpu = (unsigned long)hcpu;
@ -610,10 +610,27 @@ cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
return NOTIFY_OK;
}
static struct notifier_block __cpuinitdata cpu_nfb = {
static struct notifier_block cpu_nfb = {
.notifier_call = cpu_callback
};
#ifdef CONFIG_SUSPEND
/*
* On exit from suspend we force an offline->online transition on the boot CPU
* so that the PMU state that was lost while in suspended state gets set up
* properly for the boot CPU. This information is required for restarting the
* NMI watchdog.
*/
void lockup_detector_bootcpu_resume(void)
{
void *cpu = (void *)(long)smp_processor_id();
cpu_callback(&cpu_nfb, CPU_DEAD_FROZEN, cpu);
cpu_callback(&cpu_nfb, CPU_UP_PREPARE_FROZEN, cpu);
cpu_callback(&cpu_nfb, CPU_ONLINE_FROZEN, cpu);
}
#endif
void __init lockup_detector_init(void)
{
void *cpu = (void *)(long)smp_processor_id();