public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Oliver Neukum <oliver@neukum.org>
Cc: Oleg Nesterov <oleg@tv-sign.ru>,
	Alan Stern <stern@rowland.harvard.edu>,
	linux-kernel@vger.kernel.org,
	Nigel Cunningham <nigel@nigel.suspend2.net>
Subject: Re: [RFC][PATCH -mm] Freezer: Handle uninterruptible tasks
Date: Sun, 8 Jul 2007 01:08:08 +0200	[thread overview]
Message-ID: <200707080108.09783.rjw@sisk.pl> (raw)
In-Reply-To: <200707070100.17413.rjw@sisk.pl>

On Saturday, 7 July 2007 01:00, Rafael J. Wysocki wrote:
> On Saturday, 7 July 2007 00:38, Oliver Neukum wrote:
> > Am Freitag, 6. Juli 2007 schrieb Oleg Nesterov:
> > > Rafael J. Wysocki wrote:
> > > >
> > > > This patch makes the freezer skip uninterruptible user space tasks (ie. such
> > > > that have an mm of their own) when counting the tasks to be frozen.  As a
> > > > result, these tasks have the TIF_FREEZE and TIF_SIGPENDING flags set, but the
> > > > freezer doesn't wait for them to enter the refrigerator.  Nevertheless, they
> > > > will enter the refrigerator as soon as they change their state.
> > > 
> > > A small correction: they will enter the refrigerator on return to user-space.
> > 
> > That is too late. We would need them to go to sleep as soon as they are
> > woken up. This does not matter if they are in uninterruptible sleep due to
> > fuse deadlocking, as they won't be woken up, but it kills the other cases.
> 
> I'm sorry I can't write anything more about that right now, I'll write more
> tomorrow.
> 
> For now, I can only say that I have reasons to believe that the other cases
> are not likely to "leak" through the freezer.

OK, sorry for the delay.

The first reason is that a similar approach had been used by suspend2 for
quite some time without any visible adverse effects.  Of course this is not
a proof, but it means that the undesirable conditions are not easy to trigger
(if at all possible).

Next, if an uninterruptible task A waits on a mutex (or semaphore), then there
is a task B that holds it.  This task may be a kernel thread or a user space
process.  In the latter case it may also be uninterruptible, but then we can 
consider that task instead of A, so assume that B is interruptible.  In that
case, however, B is also freezable, but before it's frozen, it must release the
mutex.  In that case A will become freezable before B is frozen and the freezer
will have a chance to start to count A.  Thus, in that case A won't "leak"
through the freezer in the uninterruptible state.

Now, if B is a kernel thread, it might hold the mutex longer than the freezer
is running, but it has to have a reason for that.  Namely, I think that in
practice this can only happen if the resource protected by the lock is
unavailable.  In that case, task A may potentially cause problems to happen
if the resource becomes available during the suspend or resume at exactly
the right moment (eg. when .suspend() that task A may interfere with is being
executed).  IMO, this is unlikely.

I think that this also applies to the situation in which an uninterruptible task
waits for an event to occur (like a completion).  Namely, if the event waited
for by the task doesn't occur relatively quickly (like within a few scheduling
cycles), then it's likely not to occur throughout the entire suspend/resume
cycle.

This doesn't mean that no problems will happen no matter what, but at least
they are much less likely to happend than in the case when we remove the
freezer entirely without doing anything about the drivers before.

Greetings,
Rafael


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

  reply	other threads:[~2007-07-07 23:01 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-06 20:26 [RFC][PATCH -mm] Freezer: Handle uninterruptible tasks Oleg Nesterov
2007-07-06 22:38 ` Oliver Neukum
2007-07-06 23:00   ` Rafael J. Wysocki
2007-07-07 23:08     ` Rafael J. Wysocki [this message]
2007-07-06 22:56 ` Rafael J. Wysocki
2007-07-06 23:46   ` Nigel Cunningham
  -- strict thread matches above, loose matches on Subject: below --
2007-07-06  8:12 Rafael J. Wysocki
2007-07-06 15:01 ` Alan Stern
2007-07-07 23:08   ` Rafael J. Wysocki
2007-07-08 12:09     ` Pavel Machek
2007-07-08 13:55       ` Rafael J. Wysocki
2007-07-09  4:21       ` Jeremy Maitin-Shepard
2007-07-09 14:45         ` Alan Stern
2007-07-09 15:36           ` Jeremy Maitin-Shepard
2007-07-08 18:37     ` Pavel Machek
2007-07-07  7:50 ` Pavel Machek
2007-07-07  9:13   ` Nigel Cunningham
2007-07-07 11:31     ` Pavel Machek
2007-07-07 20:44       ` Rafael J. Wysocki

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=200707080108.09783.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nigel@nigel.suspend2.net \
    --cc=oleg@tv-sign.ru \
    --cc=oliver@neukum.org \
    --cc=stern@rowland.harvard.edu \
    /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