diff mbox

2.6.30: hibernation/swsusp lockup due to acpi-cpufreq

Message ID 20090616142217.GA5548@sig21.net (mailing list archive)
State RFC, archived
Headers show

Commit Message

Johannes Stezenbach June 16, 2009, 2:22 p.m. UTC
On Tue, Jun 16, 2009 at 02:16:28AM +0200, Rafael J. Wysocki wrote:
> On Tuesday 16 June 2009, Johannes Stezenbach wrote:
> > 
> > on my aging Thinkpad T42p resume from hibernation
> > fails in 2.6.30. There is a backtrace on suspend prior
> > to writing out the disk image, but I cannot capture
> > it due to lack of a serial port on the T42p. On
> > resume the machine is dead after reading the image
> > from disk.
> > 
> > I've bisected this to:
> > 
> >  commit 01599fca6758d2cd133e78f87426fc851c9ea725
> >  Author: Andrew Morton <akpm@linux-foundation.org>
> >  Date:   Mon Apr 13 10:27:49 2009 -0700
> > 
> >     cpufreq: use smp_call_function_[single|many]() in acpi-cpufreq.c
> > 
> > I see in git log that this commit is known broken, but the
> > resume on my machine is still broken in 2.6.30.
> > 
> > If I disable CONFIG_X86_ACPI_CPUFREQ suspend/resume works in 2.6.30.
> 
> Thanks a lot for bisecting this!
> 
> Is it the reason for the enabling of interrupts during cpufreq_suspend()?
> 
> /me wonders
> 
> Is there anything we can do to fix this quickly?

I think your guess was right. The patch below fixes the
problem for me (hang after resume and backtrace on suspend).


Johannes
-----------------------------

Fix swsusp failure on !SMP

Commit 01599fca6758d2cd133e78f87426fc851c9ea725 introduced
a regression which caused a backtrace on suspend and
a hang on resume on a Thinkpad T42p (Pentium M CPU).

Signed-off-by: Johannes Stezenbach <js@sig21.net>


--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Andrew Morton June 16, 2009, 6:55 p.m. UTC | #1
On Tue, 16 Jun 2009 16:22:17 +0200
Johannes Stezenbach <js@sig21.net> wrote:

> Fix swsusp failure on !SMP
> 
> Commit 01599fca6758d2cd133e78f87426fc851c9ea725 introduced
> a regression which caused a backtrace on suspend and
> a hang on resume on a Thinkpad T42p (Pentium M CPU).
> 
> Signed-off-by: Johannes Stezenbach <js@sig21.net>
> 
> 
> --- linux-2.6.30/kernel/up.c.orig	2009-06-16 15:56:28.000000000 +0200
> +++ linux-2.6.30/kernel/up.c	2009-06-16 15:57:27.000000000 +0200
> @@ -10,11 +10,13 @@
>  int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
>  				int wait)
>  {
> +	unsigned long flags;
> +
>  	WARN_ON(cpu != 0);
>  
> -	local_irq_disable();
> +	local_irq_save(flags);
>  	(func)(info);
> -	local_irq_enable();
> +	local_irq_restore(flags);
>  
>  	return 0;
>  }

ok, what's going on here?  The patch implies that someone (presumably
acpi-cpufreq) is calling smp_call_function_single() with local
interrupts disabled.  That's a bug on SMP kernels.  And it'll generate
a trace if it happens:

	/* Can deadlock when called with interrupts disabled */
	WARN_ON_ONCE(irqs_disabled() && !oops_in_progress);

but nobody has reported such a trace AFAIK?

Also, prior to 01599fca6758d2cd133e78f87426fc851c9ea725, acpi-cpufreq
was using work_on_cpu().  If it was calling work_on_cpu() with local
interrupts disabled then that would have been a bug too, which could
generate might_sleep() or scheduling-while-atomic warnings.



Because it is a bug to call the SMP version of
smp_call_function_single() with local interrupts disabled, I don't
think we should need to apply the above patch.

But I don't know what we _should_ do because I don't know what the bug
is.  Are you able to get us a copy of that stack trace?

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Johannes Stezenbach June 16, 2009, 7:57 p.m. UTC | #2
On Tue, Jun 16, 2009 at 11:55:40AM -0700, Andrew Morton wrote:
> On Tue, 16 Jun 2009 16:22:17 +0200
> Johannes Stezenbach <js@sig21.net> wrote:
> 
> > Fix swsusp failure on !SMP
> > 
> > Commit 01599fca6758d2cd133e78f87426fc851c9ea725 introduced
> > a regression which caused a backtrace on suspend and
> > a hang on resume on a Thinkpad T42p (Pentium M CPU).
> > 
> > Signed-off-by: Johannes Stezenbach <js@sig21.net>
> > 
> > 
> > --- linux-2.6.30/kernel/up.c.orig	2009-06-16 15:56:28.000000000 +0200
> > +++ linux-2.6.30/kernel/up.c	2009-06-16 15:57:27.000000000 +0200
> > @@ -10,11 +10,13 @@
> >  int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
> >  				int wait)
> >  {
> > +	unsigned long flags;
> > +
> >  	WARN_ON(cpu != 0);
> >  
> > -	local_irq_disable();
> > +	local_irq_save(flags);
> >  	(func)(info);
> > -	local_irq_enable();
> > +	local_irq_restore(flags);
> >  
> >  	return 0;
> >  }
> 
> ok, what's going on here?  The patch implies that someone (presumably
> acpi-cpufreq) is calling smp_call_function_single() with local
> interrupts disabled.  That's a bug on SMP kernels.  And it'll generate
> a trace if it happens:
> 
> 	/* Can deadlock when called with interrupts disabled */
> 	WARN_ON_ONCE(irqs_disabled() && !oops_in_progress);
> 
> but nobody has reported such a trace AFAIK?

This problem apparently only exists on !SMP kernels...

> Also, prior to 01599fca6758d2cd133e78f87426fc851c9ea725, acpi-cpufreq
> was using work_on_cpu().  If it was calling work_on_cpu() with local
> interrupts disabled then that would have been a bug too, which could
> generate might_sleep() or scheduling-while-atomic warnings.

On !SMP, work_on_cpu() is just a function call:
http://lxr.linux.no/linux+v2.6.30/include/linux/workqueue.h#L261

> Because it is a bug to call the SMP version of
> smp_call_function_single() with local interrupts disabled, I don't
> think we should need to apply the above patch.

and on SMP, smp_call_function_single() also uses
local_irq_save/restore() iff  cpu == this_cpu:
http://lxr.linux.no/linux+v2.6.30/kernel/smp.c#L272

> But I don't know what we _should_ do because I don't know what the bug
> is.  Are you able to get us a copy of that stack trace?

Unfortunately my laptop doesn't have a serial port, and the
stack trace is large and scrolls off the screen, I can only
see the last part of it and I would need to find someone with
a camera to take a picture...


Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

--- linux-2.6.30/kernel/up.c.orig	2009-06-16 15:56:28.000000000 +0200
+++ linux-2.6.30/kernel/up.c	2009-06-16 15:57:27.000000000 +0200
@@ -10,11 +10,13 @@ 
 int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
 				int wait)
 {
+	unsigned long flags;
+
 	WARN_ON(cpu != 0);
 
-	local_irq_disable();
+	local_irq_save(flags);
 	(func)(info);
-	local_irq_enable();
+	local_irq_restore(flags);
 
 	return 0;
 }