use 'do-not-hibernate' NOT 'do-not-suspend' to prevent hibernate following kernel upgrade

Bug #14908 reported by Scott Bronson
42
Affects Status Importance Assigned to Milestone
kernel-package (Ubuntu)
Fix Released
Medium
Paul Sladen
powermanagement-interface (Ubuntu)
Fix Released
Medium
Paul Sladen

Bug Description

suspend-to-disk appears to work very well except for one thing...

If the kernel is upgraded, the machine still suspends. However, when it tries
to resume, the suspended image complains of "version mismatch" and fails. All
data on the suspended image to be lost. Because kernel upgrades are now an
automatic process, the user is unlikely to realize that it has even happened.
At least, I didn't.

Steps to reproduce:

1. upgrade your kernel
2. run /etc/acpi/hibernate.sh
3. Try to resume. It will fail and all data will be lost.

This is with Hoary on an IBM T23 laptop.

Revision history for this message
Matt Zimmerman (mdz) wrote :

The system should refuse to hibernate in this case, though it's somewhat tricky
to do that robustly.

However, kernel upgrades are not (nor have they ever been) automatic; no
packages are upgraded except when the user explicitly requests it.

Matthew, Thom: is there anything quick, dirty and safe we can do to catch the
most common cases for Hoary?

Revision history for this message
Matthew Garrett (mjg59) wrote :

I can't think of one that isn't (at least) moderately fragile. Thom?

Revision history for this message
Thom May (thombot) wrote :

Not that I can think of. However, when we upgrade the kernel, should we register
a reboot event with upgrade-manager? This would at least mitigate the problem
somewhat.

Revision history for this message
Matthew Garrett (mjg59) wrote :

On kernel upgrades, we probably need to drop something that'll disable
hibernate. Matt, what's the best way to deal with this?

Revision history for this message
Matt Zimmerman (mdz) wrote :

(In reply to comment #4)
> On kernel upgrades, we probably need to drop something that'll disable
> hibernate. Matt, what's the best way to deal with this?

I mailed you a script which tries to heuristically determine if we'll be using a
different kernel on the next boot. Your sentence above gave me an idea for how
to improve it even further:

Kernel upgrades already drop a file in /var/lib/update-notifier/user.d to
indicate to the user that they should reboot. Unfortunately, I think it's dated
based on the timestamp in the .deb, and not when it is installed, but perhaps it
could still be useful

Revision history for this message
puff (puff) wrote :

I've encountered two different (but similar) problems on my Thinkpad T43p.

With the vanilla ubuntu install, I was getting the occasional "swsusp: Resume
mismatch: version" on restarting, and it would start from scratch.

I installed the linux-686 module to get the full benefit of my memory (the
default kernel only sees 1GB, while I have 2GB total) and my CPU. Then swsusp
stopped working at all - it wouldn't even shut down cleanly, I had to hard-shutdown.

I'm also seeing swsusp "lose" the ipw2200 module on resume. I'll file a
separate bug on that.

Revision history for this message
John Cooper (choffee) wrote :

Hi,

At first glance I added this to the top of /etc/acpi/hibernate.sh.

grubkern=`awk 'BEGIN { kern=0 } {if ( $1 == "default" ) f=$2; if ( $1 == "kernel" ) if ( f == kern ) { gsub(".*z-","",$2 ) ;print $2 ; ( kern = kern + 1 ) } }' /boot/grub/menu.lst`

if [ $grubkern != `uname -r` ] ; then exit 1 ; fi

It just checks the default kernel is the same as the running one. Pretty hacky but it works! Might be nice if it could return a messages to the user somehow rather than just quitting.

In the end I thought that maybe grub-update should perhaps write out a file when it notices a change in default kernel.

Revision history for this message
Matt Zimmerman (mdz) wrote : Re: [Bug 14908] Re: swsusp fails after automatic kernel upgrade

On Mon, Apr 10, 2006 at 01:35:30PM -0000, John Cooper wrote:
> At first glance I added this to the top of /etc/acpi/hibernate.sh.
>
> grubkern=`awk 'BEGIN { kern=0 } {if ( $1 == "default" ) f=$2; if ( $1 == "kernel" ) if ( f == kern ) { gsub(".*z-","",$2 ) ;print $2 ; ( kern = kern + 1 ) } }' /boot/grub/menu.lst`
>
> if [ $grubkern != `uname -r` ] ; then exit 1 ; fi
>
> It just checks the default kernel is the same as the running one. Pretty hacky but it works! Might be nice if it could return a messages to the user somehow rather than just quitting.
>
> In the end I thought that maybe grub-update should perhaps write out a file when it notices a change in default kernel.

That looks like it would only work in the case of a kernel ABI change, since
the filename doesn't change otherwise (though hibernation resume would still
fail).

Perhaps we should arrange for newly-installed kernels to always drop/touch a
file, and on reboot, remove it. That would provide a reliable test.
Matthew, what do you think?

--
 - mdz

Revision history for this message
Matthew Garrett (mjg59) wrote : Re: [Bug 14908] Re: [Bug 14908] Re: swsusp fails after automatic kernel upgrade

Yes, that sounds practical.

--
Matthew Garrett | <email address hidden>

Revision history for this message
Ulrich Lukas (ulrich-lukas) wrote : Re: swsusp fails after automatic kernel upgrade

Hi,

in order not to slow down the everyday boot process, I would suggest not to touch a file, but to drop a short shellscript together with a link to the /etc/rc init script system (or "upstart"-system), which deletes itself after the first successful reboot.

Otherwise, one would have to always check for this file during the start of the system.

Revision history for this message
Matt Zimmerman (mdz) wrote :

Ben, please arrange for future kernels to drop a file or such so that we can test its timestamp against the uptime of the system to determine whether the kernel has been upgraded since the last reboot (and refuse to hibernate in this case).

Revision history for this message
Ben Collins (ben-collins) wrote : Re: [Bug 14908] Re: swsusp fails after automatic kernel upgrade

On Sat, 2006-10-21 at 00:07 +0000, Matt Zimmerman wrote:
> Ben, please arrange for future kernels to drop a file or such so that we
> can test its timestamp against the uptime of the system to determine
> whether the kernel has been upgraded since the last reboot (and refuse
> to hibernate in this case).

I thought we had setup the /proc/version_signature file for this very
reason?

Also, it's very easy to test for /var/run/reboot-required, which shows
that some update of the system is requiring a reboot. The largest user
of this file is the kernel. I would be willing to bet that other users
would also be grounds for not hibernating.

So if the hibernation scripts test for /var/run/reboot-required, they
could use this as a means for deciding not to hibernate.

Revision history for this message
Paul Sladen (sladen) wrote : Re: swsusp fails after automatic kernel upgrade

This is related to bug #36577, worth dup'ing it? That bug is that 'pmi' should deny hibernation is the same kernel will not be used on next boot.

Revision history for this message
Matt Zimmerman (mdz) wrote :

Done. If consensus is that the acpi-support task here should be powermanagement-interface instead, please change it.

Revision history for this message
Matt Zimmerman (mdz) wrote : Re: [Bug 14908] Re: swsusp fails after automatic kernel upgrade

On Fri, Oct 20, 2006 at 08:57:21PM -0400, Ben Collins wrote:
> On Sat, 2006-10-21 at 00:07 +0000, Matt Zimmerman wrote:
> > Ben, please arrange for future kernels to drop a file or such so that we
> > can test its timestamp against the uptime of the system to determine
> > whether the kernel has been upgraded since the last reboot (and refuse
> > to hibernate in this case).
>
> I thought we had setup the /proc/version_signature file for this very
> reason?

I don't think that's quite enough, since it's non-trivial to query for the
version of the kernel which will be used on the next boot in order to
compare with this. The test which I think gives us the best combination of
accuracy and simplicity is "has a new kernel been installed since the last
boot?". That will only be wrong under special and unusual circumstances
(user installing a new non-default kernel).

> Also, it's very easy to test for /var/run/reboot-required, which shows
> that some update of the system is requiring a reboot. The largest user
> of this file is the kernel. I would be willing to bet that other users
> would also be grounds for not hibernating.
>
> So if the hibernation scripts test for /var/run/reboot-required, they
> could use this as a means for deciding not to hibernate.

Unfortunately, several other components use this as well. initscripts,
udev, dbus, hal, etc., and we don't want to disable hibernation
unnecessarily in those cases (especially for users of the development
branch where those may change often).

--
 - mdz

Revision history for this message
Carey Underwood (cwillu) wrote : Re: swsusp fails after automatic kernel upgrade

The old kernel isn't automatically uninstalled, is it? Would a better approach be to make hibernation somehow trigger the use of the old kernel?

Just a thought, I don't really have any solid idea of how one would implement it beyond hacking up '/boot/grub/menu.lst'.

Revision history for this message
Matt Zimmerman (mdz) wrote :

Ben, please arrange to have the kernels touch a file or otherwise record this information in a form which is easy to test for.

Ideally we should display some sort of notification if we decide not to hibernate, but we don't do that if there isn't swap available etc., so at least logging it and not blowing up would be an improvement.

Changed in linux-source-2.6.17:
assignee: nobody → ben-collins
Revision history for this message
Richard Hughes (richard-hughes) wrote :

Wouldn't this also be fixed if you guys used pm-utils? mjg59 - I thought you guys were going to think about switching to pm-utils in feisty - so we can get this sort of thing common upstream. mdz - have you looked at the HAL suspend and hibernate failure reporting code from davidz?

Revision history for this message
Ben Collins (ben-collins) wrote :

The postinst now touches: /var/run/do-not-suspend

So anything that needs to know should fail to suspend when this file exists.

Changed in linux-source-2.6.17:
importance: Undecided → Medium
status: Unconfirmed → Fix Committed
Revision history for this message
Matt Zimmerman (mdz) wrote :

Shouldn't this be do-not-hibernate, or do-not-suspend-to-disk? suspending to RAM is perfectly OK in this scenario, isn't it?

Revision history for this message
Paul Sladen (sladen) wrote :

mdz: yes, that is correct, 'do-not-hibernate' is the issue, suspending is fine. There are other cases where 'suspend' does not work, but hibernate does.

Revision history for this message
Paul Sladen (sladen) wrote :

I'd like to get this fixed to 'do-not-hibernate' before feisty leaves the door, otherwise we'll be carrying (totally broken) compatibility code for forever after.

Changed in kernel-package:
status: Fix Committed → Confirmed
Paul Sladen (sladen)
Changed in acpi-support:
importance: High → Medium
Revision history for this message
Paul Sladen (sladen) wrote :

 kernel-package (10.065ubuntu5) feisty; urgency=low
 .
   * Touch '/var/run/do-not-hibernate' instead of '/var/run/do-not-suspend'
     to indicate to the power-management layer that the kernel that is likely
     to be used following a hibernate/resume-from-hibernate cycle has changed.
     Re-closes: (Launchpad: #14908)

Changed in kernel-package:
assignee: ben-collins → sladen
status: Confirmed → Fix Released
Revision history for this message
Paul Sladen (sladen) wrote :

Changes:
 powermanagement-interface (0.3.13) feisty; urgency=low
 .
   * Make 'pmi.acpi' check for '/var/run/do-not-hibernate' and deny
     hibernation if the file exists (from an upgrade of the default
     kernel which would cause a failure on resume-from-hibernate).
     (Closes: Launchpad #14908).

Changed in powermanagement-interface:
assignee: mjg59 → sladen
status: Confirmed → Fix Committed
Changed in kernel-package:
status: Fix Released → Fix Committed
Paul Sladen (sladen)
Changed in kernel-package:
status: Fix Committed → Fix Released
Changed in powermanagement-interface:
status: Fix Committed → Fix Released
Revision history for this message
Katsudon (katsudon) wrote :

Gutsy Beta, KDE:

The problem is still there, at least in KDE (no blocking of hibernation after kernel update). Should I reopen the bug or make it somehow more visible to KDE development?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.