LWN.net Logo

Kernel Summit: Software suspend

This article is part of LWN's 2004 Kernel Summit coverage.
Pat Mochel, who has been absent from the kernel development community for much of the last year, made a reappearance to discuss the future of software suspend in Linux. He started by apologizing to Pavel Machek for having forked the swsusp code a year ago. Pat has just posted a set of patches merging his fork ("pmdisk") back into the swsusp base, so that there will be, once again, a single software suspend implementation in the mainline kernel.

Pat claimed that the existing software suspend code works on most systems. In particular, it works on all systems he has access to, so it is very hard to try to address the remaining issues. Linus asked how many people in the room were actually using the software suspend code; only a few hands were raised. He noted that there was rather too much complaining about software suspend going on, and not enough people actually working with it.

Many of the remaining problems are in device drivers. Suspend support has to be added to drivers explicitly, and, thereafter, it tends not to see much testing. So suspend support in drivers varies from nonexistent to present but unreliable. It was noted that the driver interface needs some work; the values passed to drivers are not consistent, and some drivers need more information. In particular, some drivers need to know whether the kernel is truly being shut down, or whether a different kernel will be booted; the necessary device preparation differs in the two cases. There was talk of (eventually) changing the driver API to add that information, or perhaps just adding a global variable to hold the "system intent." The global variable is seen by some as an ugly, short-term hack, but other developers fear it would never go away once it is introduced.

Software suspend is only useful if the system can, later, be restored. The current restore code is seen as being somewhat fragile; if the system's hardware is changed while things are down, they may not come back up properly. The proper approach, it would seem, is to use the hotplug system to "hot remove" all devices at suspend time, and treat everything on the system as new once it comes back up.

Some developers do not like the process of booting a Linux kernel which proceeds to overwrite itself with the system image made at suspend time. Perhaps, it was suggested, it would be better to restore directly from a minimal boot loader. That is not likely to happen, however. There is a fair amount of complicated setup which can be required before the system image can be retrieved; software RAID setup is one example. There are also, it would seem, patent issues with restoring directly from a special-purpose boot-time loader.

Nigel Cunningham's swsusp2 code was mentioned. Nigel, unfortunately, was unable to attend the summit to present his view of things. The discussion centered on the large and intrusive nature of the swsusp2 patch. What swsusp2 really needs is somebody to break it down into a series of relatively small patches, each of which can be considered on its own merits. Once that is done, some parts of swsusp2, at least, may make it into the mainline.

The discussion of future tasks was mostly taken up by details. The process of "refrigerating" processes needs to be split so that user processes are stopped before kernel processes. Once user processes are stopped, it should be possible to write their pages directly to disk, rather than copying them into a big in-memory image first. Should, it was asked, user pages be flushed out separately to backing store, or just written all together to the suspend image? The latter case is quite a bit quicker, as it turns out, both before and after the system is suspended. Writing one big, contiguous image is faster than writing many smaller chunks spread out over the disk, and it is faster to get those pages back into memory at resume time, rather than forcing them to be read individually via page faults.

Suspend to RAM was discussed briefly; there is, it seems, a resurgence of interest in this area.

One of the remaining difficult issues is restoring video state. Much of this discussion was deferred until the video drivers session later in the afternoon, however.

>> Next: Kobjects and sysfs.


(Log in to post comments)

Kernel Summit: Software suspend

Posted Jul 20, 2004 5:27 UTC (Tue) by cborni (subscriber, #12949) [Link]

Good to see some progress in this area.
The sad thing is, I am absolutely not interested in suspend to disk. I
would prefer to have a proper suspend-to-ram solution.
From my experience, having a big bunch of memory, rebooting is almost as
fast as suspend to disk.

I need suspend to disk

Posted Jul 20, 2004 17:05 UTC (Tue) by thomask (guest, #17985) [Link]

Until suspend to disk is implemented properly, I won't be able to use Linux on my laptop. It is crucial for me that it boots in about 10-20 seconds, which is what Windows can do with hibernation. Unless I can find a system that I like that boots in 10-20 secs (including all my BIOS stuff...). Ah well. Maybe one day I'll be able to use Linux for everything...

I need suspend to disk

Posted Jul 21, 2004 5:43 UTC (Wed) by NCunningham (guest, #6457) [Link]

You should be able to accomplish that now (using Suspend2, of course :>), depending of course upon the speed of your system and size of your image.

Kernel Summit: Software suspend

Posted Jul 20, 2004 18:46 UTC (Tue) by dambacher (subscriber, #1710) [Link]

It's very sad, that swsusp2 did not get that attention on the summit.
I run it on 2.4.24 and 2.6.7 and it works perfectly, and I think it's worth merging

But best would be to consolidate pmdisk, swsusp and swsusp2 to one _stable_ and performant implementation and include acpi support for suspend to ram and standby.

This is a demonstration of a not soo good thing in free software development: sometimes it would be better to join and not to fork!


Kernel Summit: Software suspend

Posted Jul 21, 2004 5:41 UTC (Wed) by NCunningham (guest, #6457) [Link]

Hi.

Yes, sorry I wasn't able to be there. Some of us don't do this for a job :>

Interesting comment on saving the image in parts: that's precisely what Suspend2 does: LRU pages are saved in part 1 and the rest of the kernel in another.

For what it's worth, recent changes to Suspend2 address some of the issues that were raised: the freezer has been rewritten to freeze userspace prior to kernel space (Pavel's suggestion), and that means that the intrusiveness of the patch has greatly reduced.

Once Patrick and Pavel have finised merging, I intend to work on getting Suspend2 merged in as well. Preparation for that is being done now, including breaking the code up into parts.

Regards,

Nigel

Kernel Summit: Software suspend

Posted Jul 22, 2004 12:08 UTC (Thu) by aigarius (subscriber, #7329) [Link]

Great news, we are all for you three to join up! :)

Copyright © 2004, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds