LWN.net Logo

Advertisement

Free copy of The Founder's Checklist and The Founders Pitch Deck Template from M L Bittle - New York; Advisor/Coach.

Advertise here

Software suspend: and then there were two

Software suspend has long been one of the problem areas in the Linux kernel. Despite multiple available implementations, truly reliable, out-of-the-box support for suspending a system to disk and (crucially) restoring it again is still missing. The return of one long-missing developer may help to improve things, however.

Pat Mochel is the author of much of the power management and device model code in the 2.6 kernel. At one point in his efforts, his communications with software suspend ("swsusp") maintainer Pavel Machek broke down. In response, Patrick created his own fork of the software suspend code, which he called "pmdisk." The pmdisk code went into the kernel, and a small amount of work was done on it, but then Pat got busy with other things and vanished from the kernel development community. Nobody else was working on pmdisk, so the effort simply stalled. Pavel has discussed its removal from the kernel more than once, but that has not ever happened.

Just in time for the Kernel Summit, Pat returned with a 25-part patch set. Pat now believes that he made a mistake by forking the software suspend code, and is trying to make up. So his patch set removes pmdisk from the 2.6 kernel - but not before merging its best parts into the existing swsusp code base. With this patch set, swsusp is significantly cleaned up and more firmly integrated into the kernel's power management subsystem. This code base, Pat hopes, will prove a good starting place for further work toward respectable software suspend support.

There is one other player in this game, however: the swsusp2 work done by Nigel Cunningham and others. This code, which forked from swsusp some time ago, exists as a out-of-tree patch. It is, however, by many accounts, the most featureful and reliable software suspend implementation available for Linux. Swsusp2 offers a more polished display, the ability to abort the suspend operation, and more. Nigel has recently been making noises about trying to merge swsusp2 into the 2.6 mainline.

The last time this topic came up, there was a significant amount of resistance. All versions of swsusp feature a "refrigerator," which is a mechanism for cooling off all processes in the system before suspending the system itself. The swsusp2 refrigerator has seen significant amounts of work intended to keep the system from refrigerating processes which might still be needed by other parts of the system before it is suspended. The result is a large number of macro calls interspersed through the rest of the kernel marking places where a process should not be refrigerated. These changes make the swsusp2 patch relatively intrusive; they also create a new kind of critical section within the kernel which looks hard to maintain over the long run.

The current feeling, as reflected at the kernel summit, is that much of Nigel's work cannot be merged in its current form. It also needs to be split into a set of small, incremental patches before it can be considered. Hopefully this work will happen, however; swsusp2 has things to offer. If its best features can be merged in with swsusp, perhaps the kernel may yet move from three unreliable software suspend implementations to a single version which actually works.


(Log in to post comments)

Software suspend: and then there were two

Posted Jul 22, 2004 7:43 UTC (Thu) by NCunningham (guest, #6457) [Link]

Ummm.. the section about the freezer is out of date, I'm afraid.

The macros were removed about a month ago, and the freezer implementation is much simpler now, but just as reliable.

Regards,

Nigel

Software suspend: and then there were two

Posted Jul 22, 2004 17:18 UTC (Thu) by xav (subscriber, #18536) [Link]

Your fault for not being present at the Kernel Summit to explain how swsusp2 works :)

Software suspend: and then there were two

Posted Jul 26, 2004 8:12 UTC (Mon) by NCunningham (guest, #6457) [Link]

:>

I'm thinking about preparing a paper for the Aussie Linux conference next year.

Software suspend: and then there were two

Posted Jul 22, 2004 17:53 UTC (Thu) by Ross (subscriber, #4065) [Link]

I'm curious about the integration plans. Are you planning to merge with
Pat's changes and then with the mainline kernel or will one of the patch
sets be merged with mainline and then the other? And are there any
conflicting changes which won't be able to exist in the same code base?
Inquiring minds want to know ;)

Software suspend

Posted Jul 24, 2004 22:17 UTC (Sat) by Duncan (guest, #6647) [Link]

From the coverage, it looks to me like the
two current mainline
implementations will merge first, since that code is already cooked and
the patches ready to integrate. That would also bring an immediate
benefit in the form of simplification of the current two implementations
into one, lessening code bloat and simplifying the task of later
integration of swsuspend2.

Of course, that's all in how I read the LWN coverage. I could be reading
it wrong.

As for swsuspend2, I read that its the only one that does SMP, which
interests me since I've a dual Opteron system here as my desktop. (Yes,
it's fast! I've put that speed to good use running Gentoo, stage-one
compiled from source, and just freshly updated to KDE 3.3.0-beta2 today.
=:^) It'd be nice to be able to reliably suspend it and shut the fans and
the like off, since it's in my bedroom, and it IS a dual Opteron, with all
the cooling requirements that means. <g>

I recently discovered, to my GREAT surprise, that hardware suspend to RAM
seems to work on this system -- with one caveat -- upon recovery, my time
is all screwed up, as it doesn't advance with the hwclock over suspend and
naturally the software time doesn't advance either. The /real/
complicating factor there is that I've been running NTP, and it
would /really/ skew its compensation factor if it tried to do a time sync
in /that/ state!

Anyway, now that I know hardware suspend to RAM /can/ work, when I get
time, I'm hoping to throw an NTP service shutdown script into the suspend
sequence, and an NTPClient fast-sync script into the resume, b4 restarting
the NTP service itself.

That said, I'd STILL like to be able to suspend to disk, and be able to
entirely power off the system, and swsuspend2 seems my only chance at
that, at this point, tho I've been hesitant to look into it as it'd be my
first off-main patch, and I generally catch all the full releases and part
of the rcs, and an out-of-tree patch would mean either slowing down on
that, or potentially large amounts of work to keep it merged, particularly
given the rumored intrusiveness of the patch. I'd be /very/ happy to see
it merged into mainline, however, /particularly/ if it works for my dual
Opteron!

Duncan

Software suspend

Posted Jul 26, 2004 8:11 UTC (Mon) by NCunningham (guest, #6457) [Link]

X64-64 isn't supported yet, but it's not far away.

Regards,

Nigel

Software suspend: and then there were two

Posted Jul 26, 2004 8:10 UTC (Mon) by NCunningham (guest, #6457) [Link]

Hi.

Duncan's reply is right. The two in-kernel versions are being merged first. There are already patches in the -mm tree.

After the dust has settled, I'll push my patches.

Right now I'm preparing the last feature changes to suspend2 before merging: adding support for resuming an initrd and making suspend modular. This will allow encrypted storage of an image (the encryption can be set up from the initrd), and will also allow at least some upgrades to suspend to be done without rebooting the system. The system I'm running right now has LZF, GZIP and swapwriter support compiled as modules. I just need to get the core done.

Regards,

Nigel

Software suspend: and then there were two

Posted Jul 23, 2004 12:57 UTC (Fri) by erich (subscriber, #7127) [Link]

I'd really love to see swsusp2 in the mainline kernel. It rocks.
I've been playing around with a different init concept - based on a minit extension i wrote - that would even allow stopping services not needed when the system is suspended (freeing memory and thus making suspend faster and easier). Unfortunately this isn't in a state of being published; i hope i could find some time during summer break, but i fear i won't.

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