I spent some time with a gleam in my eye yesterday, but the more I thought
about it, the dimmer the gleam got. Here are some of the issues I came up
with, which should be considered in addition to the ones mentioned above.
- At the moment, Suspend2 supports file-backed suspend to ram - we enter
S3 instead of powering down after writing the image. From that state, if
your battery runs out, you do a normal resume, if it doesn't, we just
reread the small portion of memory that was overwritten for the atomic
copy, and then you're resumed. With kexec, this wouldn't be possible.
- It makes things a lot more complicated for users. One of the reasons I
don't like the userspace suspend idea is because it makes it much easier
to break the whole set up. Requiring another kernel would have the same
- If makes things more complicated programmatically. I doubt that 8MB or
16M would be enough. We need to be able to load all the data to be
atomically restored. That's normally 20-30% of the image, so for a 1GB
image, we need to load up to 512MB, but normally 200-300MB. Unless kexec
does some magic that allows us to access memory outside of the mem= limit
(and I won't deny it's possible!), I'm not sure it can work. Presumably
we'd also need to do some interesting things to get access to the
information in the kernel we're writing, to figure out which pages are LRU
and which aren't (for doing the full image of memory).
- I don't understand kexec much at all yet, but doesn't the switch to the
new kernel take place in real mode? In that case, getting the resume to
happen would require adding extra real mode code to be invoked in place of
the initial boot code, implementing the return to where we left off when
suspending. Not impossible, but it's more complication.
In short, while it sounds nice, and it would be possible, I don't think it
is feasible. As always, I'm willing to be educated that this isn't the
Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds