From: Jeremy Maitin-Shepard <jbms@cmu.edu>
To: linux-kernel@vger.kernel.org
Cc: Linus Torvalds <torvalds@osdl.org>,
Nigel Cunningham <nigel@nigel.suspend2.net>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>, Pavel Machek <pavel@ucw.cz>
Cc: suspend2-devel@lists.suspend2.net
Subject: A kexec approach to hibernation
Date: Fri, 01 Jun 2007 16:39:51 -0400 [thread overview]
Message-ID: <878xb3l888.fsf@jbms.ath.cx> (raw)
I figured I'd throw this idea out, since although it is not perfect, it
has the potential to elegantly solve a lot of issues with hibernate.
Just as kexec can now be used to write a crashdump after a kernel panic,
a fresh kexec-loaded kernel (loaded into unused memory) could be used to
write the hibernate image of the existing kernel to disk, and then power
off the system (or suspend to ram, or anything else). This avoids the
need for the original kernel to jump through hoops to hibernate itself
in place.
A hibernate sequence would be approximately as follows:
1. Free some memory if needed or desired, and disable the swap device
if it is going to be used to write the hibernate image.
2. Load the fresh kernel in a chunk of available (possibly
pre-allocated) memory (there must also be enough available memory
for this kernel to use).
3. Disable interrupts and stop all devices.
4. Jump to the new kernel, passing whatever state information will be
needed by it to know how to write the image.
5. The new kernel loads, and then either kernel space or user space
writes the necessary data from the old kernel to disk.
6. The new kernel either powers off or suspends to ram. If it suspends
to ram, then it would need to be able to jump back to the old kernel
when it resumes from ram.
The advantages of this approach include:
- having a completely functional system (with a completely functional
userspace) from which the image is written, without having to worry
about messing up the state that is being saved (hell, the user could
even do it via an interactive shell on the new kernel);
- no need to worry about trying to use drivers while some processes are
frozen;
- no need for complicated process freezing; the same logic that can be
used for suspend to ram should be sufficient;
- no need for an atomic copy of memory, or any other complicated memory
copying; the memory of the old kernel, including the page cache, can
be written directly;
- instead of needing a significant amount of free memory to store the
atomic copy, only a few megabytes would needed to load and run the
new kernel.
It may or may not be necessary to require that the new kernel used to
write the image is the same as the existing kernel; it will likely be
useful to require that it is built from the same sources and with a
similar config. It would likely be useful, however, to either compile
out or (e.g. via the kernel command-line) disable the initialization of
drivers that will not be needed to write the image, such as sound
drivers, cdrom drivers, filesystems, and network drivers (if the image
is not to be written via the network).
Of course, if special initialization was needed under the original
kernel to set up the devices that will be used to write the image, such
as device mapper setup, or network initialization, that will have to be
repeated under the new kernel as well. This is the principal
disadvantage to this approach, but since it must be done during resume
from hibernation in any case, it doesn't seem like a very significant
disadvantage. The other disadvantage is that there would be the
delay of loading the fresh kernel; this may, however, only take a second
or two, which is relatively insignificant compared to the time required
to actually write the image, and the delay could be reduced by stripping
out unnecessary drivers from the image-writing kernel.
--
Jeremy Maitin-Shepard
next reply other threads:[~2007-06-01 20:45 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-01 20:39 Jeremy Maitin-Shepard [this message]
2007-06-01 21:39 ` A kexec approach to hibernation Rafael J. Wysocki
2007-06-01 22:25 ` Jeremy Maitin-Shepard
2007-06-01 23:14 ` Rafael J. Wysocki
2007-06-01 23:54 ` Jeremy Maitin-Shepard
2007-06-02 0:33 ` Rafael J. Wysocki
2007-06-02 1:54 ` Jeremy Maitin-Shepard
2007-06-02 9:22 ` Rafael J. Wysocki
2007-06-04 10:46 ` Pavel Machek
2007-06-04 12:20 ` Matthew Garrett
2007-06-04 13:10 ` Pavel Machek
2007-06-04 13:16 ` Matthew Garrett
2007-06-11 2:02 ` H. Peter Anvin
2007-06-11 22:44 ` Nigel Cunningham
2007-06-04 22:09 ` Jeremy Maitin-Shepard
2007-06-04 22:36 ` Nigel Cunningham
2007-06-05 8:15 ` Xavier Bestel
2007-06-05 9:34 ` Stefan Seyfried
2007-06-05 9:40 ` Xavier Bestel
2007-06-04 22:51 ` Pavel Machek
2007-06-11 15:07 ` Jeremy Maitin-Shepard
2007-06-11 3:40 ` Nigel Cunningham
2007-06-11 15:01 ` Jeremy Maitin-Shepard
2007-06-11 15:45 ` Xavier Bestel
2007-06-11 15:51 ` Jeremy Maitin-Shepard
2007-06-11 16:03 ` Xavier Bestel
2007-06-11 17:05 ` Jeremy Maitin-Shepard
2007-06-04 4:40 ` Vivek Goyal
2007-06-04 5:22 ` Nigel Cunningham
2007-06-04 8:05 ` Rafael J. Wysocki
2007-06-04 8:14 ` Nigel Cunningham
2007-06-04 21:44 ` Jeremy Maitin-Shepard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878xb3l888.fsf@jbms.ath.cx \
--to=jbms@cmu.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=nigel@nigel.suspend2.net \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox