mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: david@lang.hm
Cc: Jeremy Maitin-Shepard <jbms@cmu.edu>,
	"Huang, Ying" <ying.huang@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Pavel Machek <pavel@ucw.cz>,
	nigel@nigel.suspend2.net, linux-kernel@vger.kernel.org,
	linux-pm@lists.linux-foundation.org
Subject: Re: [PATCH 0/2] Kexec jump: The first step to kexec base hibernation
Date: Mon, 16 Jul 2007 00:59:07 +0200	[thread overview]
Message-ID: <200707160059.08277.rjw@sisk.pl> (raw)
In-Reply-To: <Pine.LNX.4.64.0707151218320.25614@asgard.lang.hm>

On Sunday, 15 July 2007 21:23, david@lang.hm wrote:
> On Sun, 15 Jul 2007, Rafael J. Wysocki wrote:
> 
> >>>> I think this is far more complicated then it needs to be.
> >>>>
> >>>> it sounds like it should be possible to do the following
> >>>>
> >>>> 1. figure out what pages should be backed up (creating a data structure to
> >>>> hold them)
> >>>
> >>> That should be done after step 2, because the memory contents can change
> >>> in this step.
> >>
> >> no, this needs to be done by the main kernel, becouse only it knows how to
> >> find this info. the kernel that you kexec into could be very different
> >> (including different versions) and the ways to identify this data is not
> >> part of any existing API
> >
> > If the memory contents changes in step 2, then the information collected by
> > the main kernel will be inaccurate.
> 
> why would the memory use change when the new kernel is run? is it becouse 
> of whatever it does to the devices for the hand-off?

Yes, I think so, although I'm not sure, because I don't know what happens to
devices during a "normal" kexec.

> >>>> 2. kexec into the hibernate kernel (this step handles all device
> >>>> transitions today)
> >>>>
> >>>> 3. have the hibernate userspace find the data structures created in step
> >>>> #1
> >>>>
> >>>> 4. have the hibernate userspace write the pages somewhere in the suspend
> >>>> format.
> >>>
> >>> You don't need to run any hibernate userspace to carry out steps 3 and 4.
> >>
> >> you should though.
> >>
> >> by doing this write in usespace you can add in all the eye-candy (aka
> >> progress bars), network I/O, etc that you want since it doesn't affect
> >> things
> >>
> >> trying to do this in the kernel makes the kernel have to know/decide too
> >> much policy (and many things that people want to do are things that do not
> >> belong in the kernel in the first place)
> >
> > Please don't tell me.  I've written uswsusp on the basis of these arguments,
> > but I don't cosider it as an overwhelming success ...
> 
> uswsusp has the problem that you are trying to run some userspace, but not 
> other userspace as you are doing the hibernate. with this approach you 
> don't have that problem since you are running a completely seperate 
> userspace.

You're running it from a RAM disk, because you can't touch filesystems.  You
can do the same with uswsusp, just fine.

> >>>> 5. have the hibernate kernel power down the box.
> >>>>
> >>>> the only things here that sounds like they're not available in stock
> >>>> kernels are steps #1 and #3.
> >>>
> >>> Correct, up to the first remark above.
> >>>
> >>>> now this won't do the fancier suspend-to-ram-and-disk and it won't let you
> >>>> go back from the hibernate kernel to the main kernel, but it should be
> >>>> enough to let you do the suspend safely and reliably.
> >>>>
> >>>> for the restore, as I understand it the process is
> >>>>
> >>>> 1. boot a kernel, any working kernel.
> >>>>
> >>>> 2. read the suspend formatted data from wherever it was saved and feed it
> >>>> to /dev/suspend
> >>>
> >>> Yes, something like this, but you really should pay more attention to devices.
> >>>
> >>> There are things that you shouldn't do to them (like unregistering), because
> >>> some processes may be using them while we're trying to hibernate (for now
> >>> we have the freezer, but I though you'd like to do all that to eliminate it).
> >>>
> >>> Generally, you need to ensure that the devices are handled in consistent ways
> >>> by both the hibernated and image-saving kernels and that's a big piece of the
> >>> jigsaw that's missing now.
> >>
> >> the kexec process should handle the device state for the transition from
> >> one kernel to another (it has to do this now, this isn't a new
> >> requirement), so this should solve the problem during the hibernate stage.
> >
> > Well, I don't think so.
> 
> Ok, I could easily be misunderstanding something here (and the comments 
> with the latest 'kexec back and forth' patch indicate there may still be 
> work to do here after all)
> 
> >> during the wakeup stage, I thought you said that al that was needed was to
> >> feed the suspend image to /dev/suspend and the kernel in the suspend image
> >> would re-probe, or otherwise re-initialize all the devices it needs. am I
> >> misunderstanding this?
> >
> > Perhaps.  Currently, the hibernated kernel will run device_resume() after
> > the restore, which is not exactly compatible with what kexec does.
> 
> but kexec isn't needed during the restore process, is it?

Generally, it's not needed.  _However_, the current handling of devices is
such that:
(a) hibernated kernel uses device_suspend() to put them into low power states
    and creates the image
(b) hibernated kernel uses device_resume() to get devices back to work and
    saves the image
(c) during the restore the boot kernel loads the image and uses
    device_suspend() to prepare devices for the "old" kernel
(d) hibernated kernel gets control and uses device_resume() to get devices back
    to work.
Now, if you use kexec instead of (a) and (b), then whatever it does to devices
is generally incompatible with the device_resume() in (d) (because, for
instance, some device driver's .resume() routine may expect some data to be
saved by the corresponding .suspend() at specific locations).

Greetings,
Rafael


-- 
"Premature optimization is the root of all evil." - Donald Knuth

  reply	other threads:[~2007-07-15 22:51 UTC|newest]

Thread overview: 125+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-11 15:30 Huang, Ying
2007-07-11 11:13 ` Pavel Machek
2007-07-12 16:28   ` Huang, Ying
2007-07-12  8:54     ` Pavel Machek
2007-07-13 23:18       ` Huang, Ying
2007-07-12  0:22 ` Andrew Morton
2007-07-12  5:48   ` Jeremy Fitzhardinge
2007-07-12  6:43     ` david
2007-07-12 12:46       ` Rafael J. Wysocki
2007-07-12 13:51         ` Mark Lord
2007-07-12 14:49           ` Pavel Machek
2007-07-12 15:35           ` Rafael J. Wysocki
2007-07-12 16:03             ` Mark Lord
2007-07-12 16:35               ` Mark Lord
2007-07-12 20:05                 ` Jeremy Maitin-Shepard
2007-07-13  2:38                   ` Mark Lord
2007-07-12 16:09           ` [linux-pm] " Alan Stern
2007-07-12 18:49           ` david
2007-07-12 18:42         ` david
2007-07-12 19:20           ` Rafael J. Wysocki
2007-07-12 19:14             ` david
2007-07-12 19:45               ` Rafael J. Wysocki
2007-07-12 17:09     ` Huang, Ying
2007-07-12 12:47       ` Rafael J. Wysocki
2007-07-12 12:38   ` Rafael J. Wysocki
2007-07-12 14:43   ` Huang, Ying
2007-07-12  7:03     ` david
2007-07-12 17:18       ` Huang, Ying
2007-07-12 10:10         ` david
2007-07-12 13:01           ` Rafael J. Wysocki
2007-07-12 13:22             ` jimmy bahuleyan
2007-07-12 19:03             ` david
2007-07-12 13:55           ` Mark Lord
2007-07-12 19:05             ` david
2007-07-12 14:06           ` Pavel Machek
2007-07-12 12:53     ` Rafael J. Wysocki
2007-07-12 18:57       ` david
2007-07-12 19:34         ` Rafael J. Wysocki
2007-07-12 19:55           ` Jeremy Maitin-Shepard
2007-07-12 20:45             ` Rafael J. Wysocki
2007-07-13  3:12             ` david
2007-07-13  9:17               ` Rafael J. Wysocki
2007-07-13  9:25                 ` david
2007-07-13 11:41                   ` Rafael J. Wysocki
2007-07-14  7:51                     ` david
2007-07-14  8:33                       ` david
2007-07-14  9:24                         ` Rafael J. Wysocki
2007-07-14 20:00                       ` Rafael J. Wysocki
2007-07-14 20:34                         ` david
2007-07-14 21:06                           ` Rafael J. Wysocki
2007-07-14 21:13                             ` david
2007-07-15 10:31                               ` Rafael J. Wysocki
2007-07-15 19:23                                 ` david
2007-07-15 22:59                                   ` Rafael J. Wysocki [this message]
2007-07-15 23:22                                     ` david
2007-07-16 12:17                                       ` Rafael J. Wysocki
2007-07-16 14:42                                         ` Huang, Ying
2007-07-16 15:40                                           ` Rafael J. Wysocki
2007-07-17  4:18                                             ` david
2007-07-17 11:46                                               ` Rafael J. Wysocki
2007-07-14 21:34                         ` david
2007-07-15 10:39                           ` Rafael J. Wysocki
2007-07-15 19:33                             ` david
2007-07-15 23:11                               ` Rafael J. Wysocki
2007-07-15 23:33                                 ` david
2007-07-13  3:06           ` david
2007-07-13  5:42             ` Hibernating To Swap Considered Harmful Joseph Fannin
2007-07-13  5:57               ` david
2007-07-13  6:20                 ` Joseph Fannin
2007-07-13  6:27                   ` david
2007-07-13  7:15                     ` Joseph Fannin
2007-07-13 14:35                       ` Jeremy Maitin-Shepard
2007-07-17  0:12                         ` Joseph Fannin
2007-07-17  5:44                           ` Oliver Neukum
2007-07-17  6:28                             ` Joseph Fannin
2007-07-17  6:42                               ` david
2007-07-17  7:26                                 ` Joseph Fannin
2007-07-17  7:34                                   ` david
2007-07-17 11:54                                     ` Rafael J. Wysocki
2007-07-17 11:52                                   ` Rafael J. Wysocki
2007-07-17  7:10                               ` Oliver Neukum
2007-07-13  9:30               ` Rafael J. Wysocki
2007-07-14  0:45                 ` Joseph Fannin
2007-07-14  9:48                   ` Rafael J. Wysocki
2007-07-16  5:37                     ` Joseph Fannin
2007-07-13  9:29             ` [PATCH 0/2] Kexec jump: The first step to kexec base hibernation Rafael J. Wysocki
2007-07-13  9:38               ` david
2007-07-13 11:59                 ` Rafael J. Wysocki
2007-07-13 14:37                   ` [linux-pm] " Alan Stern
2007-07-13 15:31                     ` Rafael J. Wysocki
2007-07-14  7:13                     ` david
2007-07-13 15:12                   ` Jeremy Maitin-Shepard
2007-07-13 15:45                     ` Rafael J. Wysocki
2007-07-13 15:50                       ` Alan Stern
2007-07-13 16:54                         ` Eric W. Biederman
2007-07-13 18:15                           ` Alan Stern
2007-07-13 21:08                             ` Rafael J. Wysocki
2007-07-13 20:55                         ` Rafael J. Wysocki
2007-07-13 16:48                       ` Jeremy Maitin-Shepard
2007-07-13 21:23                         ` Rafael J. Wysocki
2007-07-14  7:12                   ` david
2007-07-13 17:32             ` Huang, Ying
2007-07-13 12:01               ` Rafael J. Wysocki
2007-07-12 16:32     ` Eric W. Biederman
2007-07-12 19:09       ` david
2007-07-12 19:49         ` Eric W. Biederman
2007-07-13 23:15       ` Huang, Ying
2007-07-13 16:43         ` Eric W. Biederman
2007-07-14  5:48           ` Huang, Ying
2007-07-14  9:59             ` Rafael J. Wysocki
2007-07-14 10:55               ` Huang, Ying
2007-07-14 19:16                 ` Rafael J. Wysocki
2007-07-15  9:30                   ` Huang, Ying
2007-07-15 10:49                     ` Rafael J. Wysocki
2007-07-24 14:00                       ` Huang, Ying
2007-07-24 15:27                         ` Rafael J. Wysocki
2007-07-17  8:13                     ` david
2007-07-17 11:59                       ` Rafael J. Wysocki
2007-07-17 12:48                       ` Huang, Ying
2007-07-17 14:22                         ` Rafael J. Wysocki
2007-07-18  0:25                           ` david
2007-07-13  5:08 [PATCH 0/2] Kexec jump: The first step to kexec base Al Boldi
2007-07-13 15:28 ` [PATCH 0/2] Kexec jump: The first step to kexec base hibernation Al Boldi
2007-07-13 15:50   ` Rafael J. Wysocki
2007-07-14  6:07     ` Al Boldi
2007-07-13 15:28 ` Al Boldi

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=200707160059.08277.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=akpm@linux-foundation.org \
    --cc=david@lang.hm \
    --cc=jbms@cmu.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=nigel@nigel.suspend2.net \
    --cc=pavel@ucw.cz \
    --cc=ying.huang@intel.com \
    /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

all inboxes | Powered by JetHome®