login
Header Space

 
 

Re: [PATCH] Remove process freezer from suspend to RAM pathway

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Alan Stern <stern@...>
Cc: Kyle Moffett <mrmacman_g4@...>, Nigel Cunningham <nigel@...>, Pavel Machek <pavel@...>, Rafael J. Wysocki <rjw@...>, Matthew Garrett <mjg59@...>, <linux-kernel@...>, <linux-pm@...>
Date: Saturday, July 7, 2007 - 12:06 am

> > so the suspend process will wait for it.  When binding  

Why would it ? Just make it fail, maybe with some kind of -ERETRY... Or
it can spin with the lock not held if it want. That's a detail really.


No. The freezer will hide some of those problems under the carpet, but
not solve the basic issue which is the driver should be solid. Period.

The freezer is a flawed concept in the first place. If you go back to
square one, what is the basic idea of it ? I'll basically expose the
idea and go down all of the path I have in mind where it stops working
and becomes an incredibly difficult thing that in the end doesn't even
solve all the problems it's supposed to.

So first thing first...

I want a quiescent system with no new "IO requests" (whatever that mean
in the context of drivers) issued to avoid races during suspend/resume.

That sounds like a nice idea. Yeah. Sounds... only. Problem is. How do
you define that quiescent system ? First idea is ... let's stop
userland. There are various ways of doing that, but the freezer hooking
into the signal code is not necessarily a bad one.

No, I'm purposefully putting aside all the cases where the above doesn't
work (user process in the kernel in some uninterruptible wait, etc...),
which are the first big setback imho... our simple idea is suddenly not
so simple anymore, but we can bring those back later.

Now, there is still a problem... kernel threads. In fact, there is no
fundamental distinction between a kernel thread and a user process...
one has an MM and the other doesn't but as far as we are concerned, it's
the same. Kernel threads can issues IOs, or like khubd, detect devices,
plug/unplug them, etc etc.... all over the place.

Easy answer that comes to mind -> freeze them too. Heh, but kernel
threads don't do signals, so we end up with all those try_to_freeze().
Then what about the fact that drivers may need those kernel threads to
proceed ? Some drivers queue up their IO requests to a kernel thread to
process them and suspend() might need to flush those down, issue a
couple more such as "spin down disks" before that kernel thread can
actually be frozen... Hrm.. maybe not all of them then.

But how do you decide ? What defines that a kernel can issue an IO ? In
fact, if you look closely, anything doing kmalloc(...,GFP_KERNEL) for
example can trigger an IO... implicitely, via the VM pushing things out.
And that's just one example.

In some case, those same threads that may need to be kept non-frozen are
-also- the ones that will potentially submit new IOs or bring in new
devices.

And then, there is keventd ... what do you do about work queues ? You
have everybody pouring things at workqueues... some of these things may
well hit your driver, some may not. Same goes in some cases with
interrupt time stuff, such as timers or tasklets.. think about
networking.

In the end, the nice idea that "threads/tasks cause requests, so we just
stop them" basically falls appart. Half of the kernel can cause a driver
to be hit somewhere and a given time, it can be from a thread context,
directly caused by userland, or from some timer due to some subsystem
having a keepalive thing ticking in or whatever else.

Now, we go back to the previous issue of what do we do about
uninterruptible sleep... You want to abort suspend because, for example,
somethign called a driver that does an msleep(200) or so ? Are you aware
that 99% of laptop users close their laptops and shove it in the bag not
even waiting for the disk to spin down ? And you want suspend to abort
because some random "happen all the time" even such as a process being
somewhere temporarily in uninterruptible state in the kernel ?

So let's say we freeze them from within the scheduler even when they are
uininterruptible.. ouch... you just caused the deadlocks we talked about
before. While without a freezer, suspend() can at least rely on the fact
that it can wait for processes that have such pending locked constructs
waiting will ultimately wakeupm and wait for them (or even explicitely
wake them), it can't if they've been frozen. So what was a perfectly
solvable moderate driver synchronisation issue becomes a deadlock
nightmare.

And those are just example. During this discussion, we also brought the
example of FUSE which is a big stab at the whole freezer concept. And
I'm sure we can find more everyday.

Face it, we should seriously look into doing suspend/resume without a
freezer. I even tend to think that we could do STD that way too, in
fact, while Linus is right saying it's a different problem than STR, we
could even probably re-use some of the STR infrastructure in some
hackish way, still without a freezer. We could have ways to block page
cache writeout, for example, to prevent new post-snapshot dirty data
from hitting the platter, and use direct BIOs for writeout. That's just
an example.

Ben.


-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Remove process freezer from suspend to RAM pathway, Matthew Garrett, (Tue Jul 3, 12:29 am)
Re: sysrq-t dumps of s2ram/fuse deadlock, Jeremy Maitin-Shepard, (Wed Jul 11, 9:45 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Tue Jul 3, 1:48 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Tue Jul 3, 3:19 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Tue Jul 3, 5:14 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Thu Jul 5, 6:46 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Thu Jul 5, 7:20 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Thu Jul 5, 11:54 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Fri Jul 6, 12:41 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sat Jul 7, 12:06 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sat Jul 7, 8:48 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 1:14 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 5:20 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Mon Jul 9, 6:05 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Mon Jul 9, 5:13 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Mon Jul 9, 5:33 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 8:33 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 9:32 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 5:03 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 5:54 pm)
Re: hibernation/snapshot design, Jeremy Maitin-Shepard, (Mon Jul 9, 11:23 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 1:19 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Thu Jul 5, 11:59 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Fri Jul 6, 11:44 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sat Jul 7, 8:42 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 12:39 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 5:21 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Mon Jul 9, 5:14 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sat Jul 7, 8:40 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Fri Jul 6, 5:03 am)
The big suspend mess, Adrian Bunk, (Wed Jul 4, 6:19 pm)
Re: [linux-pm] The big suspend mess, Alan Stern, (Thu Jul 5, 10:14 am)
Re: The big suspend mess, Pavel Machek, (Wed Jul 4, 8:27 pm)
Re: The big suspend mess, Adrian Bunk, (Wed Jul 4, 9:22 pm)
Re: The big suspend mess, Rafael J. Wysocki, (Thu Jul 5, 8:18 am)
Re: The big suspend mess, Paul Mackerras, (Wed Jul 4, 8:53 pm)
Re: The big suspend mess, Pavel Machek, (Thu Jul 5, 5:32 am)
Re: The big suspend mess, Gabriel C, (Thu Jul 5, 6:29 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Rafael J. Wysocki, (Wed Jul 4, 10:30 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Tue Jul 3, 5:35 pm)
Re: removing refrigerator does not help with s2ram vs. fuse ..., Rafael J. Wysocki, (Thu Jul 5, 10:28 am)
Re: removing refrigerator does not help with s2ram vs. fuse ..., Rafael J. Wysocki, (Thu Jul 5, 10:41 am)
Re: removing refrigerator does not help with s2ram vs. fuse ..., Rafael J. Wysocki, (Thu Jul 5, 11:04 am)
Re: removing refrigerator does not help with s2ram vs. fuse ..., Rafael J. Wysocki, (Thu Jul 5, 11:27 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Benjamin Herrenschmidt, (Thu Jul 5, 6:59 pm)
Re: malicious filesystems (was Re: [linux-pm] Re: [PATCH] Re..., Rafael J. Wysocki, (Sun Jul 8, 10:06 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Benjamin Herrenschmidt, (Thu Jul 5, 7:05 pm)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Jeremy Maitin-Shepard, (Thu Jul 5, 11:59 pm)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Benjamin Herrenschmidt, (Fri Jul 6, 4:59 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Benjamin Herrenschmidt, (Fri Jul 6, 10:44 pm)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Benjamin Herrenschmidt, (Sat Jul 7, 8:50 pm)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Benjamin Herrenschmidt, (Fri Jul 6, 10:46 pm)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Rafael J. Wysocki, (Thu Jul 5, 10:14 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Benjamin Herrenschmidt, (Thu Jul 5, 6:38 pm)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Rafael J. Wysocki, (Thu Jul 5, 10:02 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Rafael J. Wysocki, (Thu Jul 5, 10:09 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Jeremy Maitin-Shepard, (Thu Jul 5, 12:06 pm)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Rafael J. Wysocki, (Thu Jul 5, 10:59 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Rafael J. Wysocki, (Tue Jul 3, 11:22 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Rafael J. Wysocki, (Tue Jul 3, 10:51 am)