mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Milton Miller <miltonm@bga.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Ying Huang <ying.huang@intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"Rafael J. Wysocki" <rjw@sisk.pl>, David Lang <david@lang.hm>,
	linux-pm <linux-pm@lists.linux-foundation.org>,
	Jeremy Maitin-Shepard <jbms@cmu.edu>
Subject: Re: [linux-pm] Re: Hibernation considerations
Date: Fri, 20 Jul 2007 14:08:26 -0500	[thread overview]
Message-ID: <fe998950b9d5ad317d5c1f5ff4e21ac9@bga.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0707201408060.2546-100000@iolanthe.rowland.org>


On Jul 20, 2007, at 1:17 PM, Alan Stern wrote:

> On Fri, 20 Jul 2007, Milton Miller wrote:
>
>> On Jul 20, 2007, at 11:20 AM, Alan Stern wrote:
>>> On Fri, 20 Jul 2007, Milton Miller wrote:
>>>>> We can't do this unless we have frozen tasks (this way, or another)
>>>>> before
>>>>> carrying out the entire operation.
>>>>
>>>> What can't we do?   We've already worked with the drivers to quesce
>>>> the
>>>> hardware and put any information to resume the device in ram.  Now 
>>>> we
>>>> ask them to put their device in low power mode so we can go to 
>>>> sleep.
>>>> Even if we schedule, the only thing userspace could touch is memory.
>>>
>>> Userspace can submit I/O requests.  Someone will have to audit every
>>> driver to make sure that such I/O requests don't cause a quiesced
>>> device to become active.  If the device is active, it will make the
>>> memory snapshot inconsistent with the on-device data.
>>
>> If a driver is waking a device between the time it was told by
>> hibernation "suspend all operations and save your device state to ram"
>> and "resume your device" then it is a buggy driver.
>
> That's exactly my point.  As far as I know nobody has done a survey,
> but I bet you'd find _many_ drivers are buggy either in this way or the
> converse (forcing an I/O request to fail immediately instead of waiting
> until the suspend is over when it could succeed).  They have this bug
> because they were written -- those which include any suspend/resume
> support at all -- under the assumption that they could rely on the
> freezer.
>
> And that's why Rafael said "We can't do this unless we have frozen
> tasks (this way, or another) before carrying out the entire operation."
> Until the drivers are fixed -- which seems like a tremendous job --
> none of this will work.

So this is in the way of removing the freezer ... but as we are not 
relying on doing any io other than suspend device operation, save state 
to ram, then later put device in low power mode for s3 and/or s4, and 
finally restore and resume to running.

>> I argue the process can make the io request after we write to disk, we
>> just can't service it.  If we are suspended it will go to the request
>> queue, and eventually the process will wait for normal throttling
>> mechanisms until the driver is woken up.
>
> Many drivers don't have request queues.  Even for the ones that do,
> there are I/O pathways that bypass the queue (think of ioctl or sysfs).

So its not a flag in make_request, fine.

>> Actually, my point was more "what kernel services do the drivers need
>> to transition from quiesced to low power for acpi S4 or
>> suspend-to-ram"?  We can't give them allocate-memory (but we give them
>> a call "we are going to suspend" when they can), but does "run this
>> tasklet" help?  What timer facilities are needed?
>
> Some drivers need the ability to schedule.  Some will need the ability
> to allocate memory (although GFP_ATOMIC is probably sufficient).  Some
> will need timers to run.

Can they allocate the memory in advance?  (Call them when we know we 
want to suspend, they make the allocations they will need; we later 
call them again to release the allocations).

If you need timers, you probably want some scheduling?

>> Do we need to differentate init (por by bios) and resume from quiesced
>> (for reboot, kexec start/resume)?  I hope not.
>
> Yes we do.

can you elabrate?   Note I was not asking resume-from-low power vs 
init-from-por.  We still get that distinction.

How do these drivers work today when we kexec?

The reason I'm asking is its hard to tell the first kernel what 
happened.  We can say "we powered off, and we were restarted", but it 
becomes much harder when each device may or may not have a driver in 
the save kernel if we have to differentate for each device if it was 
initialized and later quiesced by the jump kernel during save or never 
touched.  And we need to tell the resume from hybernate code "i touched 
it" "no i didn't" and "we resumed from s4" "no it was from s5".

This is why I've been proposing that we don't create the suspend image 
with devices in the low power state, but only in a quiesced state 
similar to the initial state.


I'm proposing a sequence like:

(1) start allocating pinned memory to reduce saved image size
(2) allocate and map blocks to save maximum image (we know how much ram 
is not in 1, so the max size)
(3) tell drivers we are going to suspend.   userspace is still running, 
swaping still active, etc.  now is the time to allocate memory to save 
device state.
(4) do what we want to slow down userspace making requests (ie run 
freezer today)
(5) call drivers while still scheduling with interrupts "save 
oppertunitiy".  From this point, any new request should be queued or 
the process put on a wait queue.
(6) suspend timers, turn off interrupts
(7) call drivers with interrupts off (final save)
(8) jump to other kernel to save the image
(9) call drivers to transition to low power
(10) finish operations to platform suspend on hybernate
(11) call drivers to resume, telling them if from suspend-to-ram or 
suspend-to-disk, possibly in two stages (interrupts off no scheduling 
and interrupts on scheduling allowed)
(12) unfreeze processes, kill the the thread holding the extra memroy 
used to reserve

So I'm asking what needs to happen in 9.  If we have to turn interrupts 
on and schedule, that's ok.  If the low power state is the initial 
state then fine.

Note that in 11, we could further differentate "from image restore in 
S4" and "from image restore in S5", and "from failed image save", but 
what needs to happen differently?


I'm guessing that the work that will take some time is seperating the 
go to low power from quiesce operations for snapshot, as it sounds like 
this is done with one driver call today?  Making this separation will 
give us our driver audit :-), but only if we decide on the requiements 
before the start.

miton


  reply	other threads:[~2007-07-20 19:09 UTC|newest]

Thread overview: 220+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-15 12:33 Rafael J. Wysocki
2007-07-15 12:51 ` Nigel Cunningham
2007-07-15 12:58 ` Dr. David Alan Gilbert
2007-07-15 22:38   ` Rafael J. Wysocki
2007-07-15 22:27     ` david
2007-07-17 17:40       ` Dr. David Alan Gilbert
2007-07-17 17:49         ` david
2007-07-29  6:53     ` Vojtech Pavlik
2007-07-29  9:56       ` Rafael J. Wysocki
2007-08-05 19:56       ` encrypted hibernation (was Re: Hibernation considerations) Pavel Machek
2007-08-11 23:43         ` Dr. David Alan Gilbert
2007-08-12 22:12           ` Rafael J. Wysocki
2007-08-18 19:37             ` Dr. David Alan Gilbert
2007-08-21  7:29               ` Pavel Machek
2007-08-13  2:30           ` Michael Chang
2007-08-13  4:53             ` alon.barlev
2007-07-15 15:10 ` Hibernation considerations Al Boldi
2007-07-15 15:35   ` jimmy bahuleyan
2007-07-15 17:40     ` Al Boldi
2007-07-15 16:29   ` Alan Stern
2007-07-15 17:40     ` Al Boldi
2007-07-15 23:28       ` Alan Stern
2007-07-15 23:58         ` david
2007-07-16  5:02         ` Al Boldi
2007-07-16  6:49           ` david
2007-07-16 13:32             ` Al Boldi
2007-07-17  4:33               ` david
2007-07-17 12:08                 ` Al Boldi
2007-07-17 14:18                   ` Rafael J. Wysocki
2007-07-17 15:23                   ` david
2007-07-16 14:53           ` Alan Stern
2007-07-16 16:51             ` Al Boldi
2007-07-17  4:37               ` david
2007-07-15 19:52     ` david
2007-07-15 20:13 ` david
2007-07-15 22:47   ` Rafael J. Wysocki
2007-07-15 22:42     ` david
2007-07-15 23:15       ` Alan Stern
2007-07-15 23:38         ` Nigel Cunningham
2007-07-16 14:15           ` Alan Stern
2007-07-16 15:25             ` Rafael J. Wysocki
2007-07-15 23:41         ` david
2007-07-16 14:21           ` Alan Stern
2007-07-17  4:45             ` david
2007-07-17 14:15               ` Alan Stern
2007-07-17 14:40                 ` Rafael J. Wysocki
2007-07-17 15:29                   ` david
2007-07-17 16:02                     ` Rafael J. Wysocki
2007-07-17 17:06                       ` david
2007-07-17 19:50                         ` Rafael J. Wysocki
2007-07-17 20:18                           ` david
2007-07-17 20:39                             ` Jeremy Maitin-Shepard
2007-07-17 20:39                               ` david
2007-07-17 20:58                               ` Rafael J. Wysocki
2007-07-17 20:57                             ` Rafael J. Wysocki
2007-07-17 20:53                               ` david
2007-07-17 21:37                                 ` Rafael J. Wysocki
2007-07-17 21:42                                   ` david
2007-07-17 21:53                                     ` Jeremy Maitin-Shepard
2007-07-21 10:25                             ` Pavel Machek
2007-07-21 15:35                               ` Jeremy Maitin-Shepard
2007-07-21 17:56                                 ` Pavel Machek
2007-07-21 19:35                                   ` david
2007-07-21 19:49                                     ` Pavel Machek
2007-07-21 22:14                                       ` david
2007-08-01 16:58                             ` Stefan Seyfried
2007-07-17 20:24                           ` Jeremy Maitin-Shepard
2007-07-17 20:44                             ` david
2007-07-17 21:00                             ` Rafael J. Wysocki
2007-07-17 16:09                   ` Jeremy Maitin-Shepard
2007-07-17 19:54                     ` Rafael J. Wysocki
2007-07-17 18:32                   ` Alan Stern
2007-07-17 20:17                     ` Rafael J. Wysocki
2007-07-17 20:34                       ` david
2007-07-17 20:54                         ` Jeremy Maitin-Shepard
2007-07-17 21:04                           ` david
2007-07-17 21:23                         ` Rafael J. Wysocki
2007-07-17 21:17                           ` david
2007-07-17 21:27                             ` Jeremy Maitin-Shepard
2007-07-17 21:27                               ` david
2007-07-17 21:54                                 ` Rafael J. Wysocki
2007-07-17 21:45                               ` Rafael J. Wysocki
2007-07-17 21:43                             ` Rafael J. Wysocki
2007-07-17 20:34                       ` Jeremy Maitin-Shepard
2007-07-17 20:37                         ` david
2007-07-17 20:56                           ` Jeremy Maitin-Shepard
2007-07-17 21:06                             ` david
2007-07-17 21:40                               ` Rafael J. Wysocki
2007-07-17 21:24                           ` Rafael J. Wysocki
2007-07-17 21:11                         ` Rafael J. Wysocki
2007-07-17 20:27                     ` david
2007-07-17 21:20                       ` Rafael J. Wysocki
     [not found]                         ` <ea7a437ca4038d408ac544bbc3c2434a@bga.com>
2007-07-19 17:31                           ` [linux-pm] " david
2007-07-20 14:24                             ` Milton Miller
2007-07-20 15:44                               ` david
2007-07-19 20:28                           ` Rafael J. Wysocki
2007-07-19 23:07                             ` david
2007-07-20 11:17                               ` Rafael J. Wysocki
2007-07-20 15:35                                 ` david
2007-07-20 16:15                                   ` Alan Stern
2007-07-20 21:46                                     ` Rafael J. Wysocki
2007-07-20 16:56                                 ` Milton Miller
2007-07-20 17:31                                   ` Jeremy Maitin-Shepard
2007-07-20 21:30                                     ` Rafael J. Wysocki
2007-07-20 19:26                                   ` david
2007-07-20 21:28                                   ` Rafael J. Wysocki
2007-07-20 21:33                                     ` Jeremy Maitin-Shepard
2007-07-20 22:19                                       ` Rafael J. Wysocki
     [not found]                               ` <20070720152744.GH20529@grifter.jdc.home>
2007-07-20 15:36                                 ` david
2007-07-20 21:43                                   ` Rafael J. Wysocki
2007-07-20 21:39                                     ` david
2007-07-20 22:22                                       ` Rafael J. Wysocki
2007-07-20 22:39                                         ` david
2007-07-20 16:08                             ` Milton Miller
2007-07-20 16:20                               ` Alan Stern
2007-07-20 17:32                                 ` Milton Miller
2007-07-20 18:17                                   ` Alan Stern
2007-07-20 19:08                                     ` Milton Miller [this message]
2007-07-20 19:37                                       ` Alan Stern
2007-07-20 20:03                                     ` Oliver Neukum
2007-07-20 20:12                                       ` Alan Stern
2007-07-20 21:35                                         ` Oliver Neukum
2007-07-20 22:25                                           ` Alan Stern
2007-07-23 14:23                                             ` Oliver Neukum
2007-07-23 20:05                                               ` Towards eliminating the freezer Alan Stern
2007-07-24  8:21                                                 ` Oliver Neukum
2007-07-24 14:27                                                   ` Alan Stern
2007-07-24  9:33                                                 ` Rafael J. Wysocki
2007-07-24 14:29                                                   ` Alan Stern
2007-07-24 15:24                                                     ` Rafael J. Wysocki
2007-07-24 16:06                                                       ` Alan Stern
2007-07-24 19:20                                                         ` Rafael J. Wysocki
2007-07-24 20:24                                                           ` Alan Stern
2007-07-24 21:14                                                             ` Rafael J. Wysocki
2007-07-24 22:14                                                               ` Alan Stern
2007-07-25 12:23                                                                 ` Rafael J. Wysocki
2007-08-01  9:34                                             ` [linux-pm] Re: Hibernation considerations Pavel Machek
2007-08-03  3:50                                               ` david
2007-07-20 20:31                                 ` david
2007-07-20 21:24                                   ` Alan Stern
2007-07-20 21:34                                     ` david
2007-07-20 22:15                                       ` Rafael J. Wysocki
2007-07-20 21:37                                     ` Jeremy Maitin-Shepard
2007-07-20 22:35                                       ` Alan Stern
2007-07-20 22:43                                         ` david
2007-07-21  5:21                                           ` Nigel Cunningham
2007-07-21 14:10                                           ` Alan Stern
2007-07-22  3:43                                             ` david
2007-07-22 16:00                                               ` Alan Stern
2007-07-22 21:50                                                 ` david
2007-07-23 15:19                                                   ` Alan Stern
2007-07-23 19:01                                                     ` david
2007-07-23 20:22                                                       ` Alan Stern
2007-07-24 13:26                                                         ` Huang, Ying
2007-07-24 14:50                                                           ` Alan Stern
2007-07-20 22:48                                         ` Jeremy Maitin-Shepard
2007-07-20 21:02                               ` Rafael J. Wysocki
2007-07-21 11:44                                 ` Miklos Szeredi
2007-07-21 12:43                                   ` Nigel Cunningham
2007-07-21 13:56                                     ` Alan Stern
2007-07-21 16:13                                     ` Jeremy Maitin-Shepard
2007-07-21 18:12                                       ` Miklos Szeredi
2007-07-21 19:20                                         ` Rafael J. Wysocki
2007-08-01  9:22                                           ` Pavel Machek
2007-08-02 17:02                                             ` Rafael J. Wysocki
2007-07-21 22:21                                         ` Nigel Cunningham
2007-07-21 22:16                                       ` Nigel Cunningham
2007-07-22 15:26                                         ` Alan Stern
2007-07-22 16:27                                           ` Miklos Szeredi
2007-07-22 20:09                                             ` Alan Stern
2007-07-22 21:54                                               ` david
2007-07-22 22:42                                           ` Nigel Cunningham
2007-07-22 23:09                                             ` Rafael J. Wysocki
2007-07-22 23:18                                               ` Nigel Cunningham
2007-07-23  0:04                                             ` Paul Mackerras
2007-07-23  3:11                                               ` Nigel Cunningham
2007-07-23 15:23                                                 ` Alan Stern
2007-07-23 21:55                                                   ` Nigel Cunningham
2007-07-23 22:10                                                     ` Rafael J. Wysocki
2007-07-23  5:31                                             ` david
2007-07-23 10:24                                             ` Miklos Szeredi
2007-07-23 12:08                                               ` Rafael J. Wysocki
2007-07-23 12:14                                                 ` Miklos Szeredi
2007-07-23 12:27                                                   ` Rafael J. Wysocki
2007-07-23 12:31                                                   ` Oliver Neukum
2007-07-23 13:08                                                     ` Miklos Szeredi
2007-07-23 14:01                                                       ` Rafael J. Wysocki
2007-07-23 14:01                                                         ` Miklos Szeredi
2007-07-23 19:08                                                     ` david
2007-08-01  9:19                                     ` Pavel Machek
     [not found]                         ` <40fa2626aff7b6b590ad6aa4737fc873@bga.com>
2007-07-20 14:48                           ` Huang, Ying
2007-07-20 15:48                             ` david
2007-07-22  2:17                               ` Huang, Ying
2007-07-22  2:32                                 ` david
2007-07-20 21:34                             ` Rafael J. Wysocki
2007-07-17 22:38                       ` Alan Stern
2007-07-17 22:37                         ` david
2007-07-18 14:29                           ` Alan Stern
2007-07-18 14:47                             ` Rafael J. Wysocki
2007-07-20  4:40                               ` Al Boldi
2007-07-20 10:59                                 ` Rafael J. Wysocki
2007-07-21 10:17               ` Pavel Machek
2007-07-15 23:22       ` Rafael J. Wysocki
2007-07-15 23:49         ` david
2007-07-16 12:06           ` Rafael J. Wysocki
     [not found]             ` <20070716123849.GC14212@grifter.jdc.home>
2007-07-16 15:29               ` Rafael J. Wysocki
2007-07-17  4:28                 ` david
2007-07-17 10:42                   ` Matthew Garrett
2007-07-17 15:19                     ` david
2007-07-18  2:18                       ` Matthew Garrett
2007-07-18  3:54                         ` david
2007-07-18 11:10                           ` Matthew Garrett
2007-07-18 12:56                             ` david
2007-07-15 23:17   ` Alan Stern
2007-07-15 23:53     ` david
2007-07-16  5:18       ` Jeremy Maitin-Shepard
2007-07-15 20:35 ` Cornelius Riemenschneider
2007-07-15 19:46   ` david
2007-07-16  0:51 ` Matthew Garrett
2007-07-16  0:51   ` david

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=fe998950b9d5ad317d5c1f5ff4e21ac9@bga.com \
    --to=miltonm@bga.com \
    --cc=david@lang.hm \
    --cc=jbms@cmu.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=rjw@sisk.pl \
    --cc=stern@rowland.harvard.edu \
    --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

Powered by JetHome