public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: ncunningham@cyclades.com
Cc: Linux-pm mailing list <linux-pm@lists.osdl.org>,
	Pavel Machek <pavel@ucw.cz>
Subject: Re: Re: freeze_processes questions
Date: Wed, 6 Apr 2005 08:41:54 +0200	[thread overview]
Message-ID: <200504060841.54490.rjw@sisk.pl> (raw)
In-Reply-To: <1112742641.3757.58.camel@desktop.cunningham.myip.net.au>

[-- Attachment #1: Type: text/plain, Size: 3613 bytes --]

Hi,

On Wednesday, 6 of April 2005 01:10, Nigel Cunningham wrote:
> Hi.
> 
> On Wed, 2005-04-06 at 08:57, Pavel Machek wrote:
> > Hi!
> > 
> > > > > 2) We can try to force uninterruptible tasks to get their "signals" anyway using
> > > > > wake_up_state() directly on them (which I don't like as much).
> > > > 
> > > > They are probably uninterruptible for a reason...
> > > > 
> > > > If something is staying in UNINTERRUPTIBLE for more than 1 second, it
> > > > is going to cause problems elsewhere, anyway. Do you see that happening?
> > > 
> > > Probably.  Please see, for example, this message sent to l-k:
> > > 
> > > http://marc.theaimsgroup.com/?l=linux-kernel&m=111268969510393&w=2
> > 
> > ...hmm, perhaps kseriod needs suspend/resume support, or something;

It seems that anything compiled in (ie not as a module) which ends up in
call_usermodehelper() during boot is likely to need this kind of handling.

> > but that does not mean we should handle *all* uninterruptible tasks
> > that way.
> > 
> > > I can easily trigger a similar behavior with an uninterruptible task and I
> > > have some problems with freezing tasks on SMP that smell like this too.
> > > 
> > > If we are going to ignore uninterruptible tasks, I'd propose to set PF_FREEZE
> > > and TIF_SIGPENDING for them without counting them as "todo" in
> > 
> > You can't just ignore uninterruptible tasks, sorry.
> 
> I don't think Rafael is suggesting ignoring them.

Words, words ... ;-)

> He's suggesting what I'm already doing:
> - Signal so they enter the freezer if they leave the state;
> - Don't count them when deciding whether freezing failed;
> - Handle the case where they don't leave the state until post resume (I
> let them enter the refrigerator, but have code in there to check whether
> the freezer is still on).

Yup.  Actaully, I think of something like this (tested once):

--- old/kernel/power/process.c	2005-04-06 08:30:47.000000000 +0200
+++ new/kernel/power/process.c	2005-04-06 08:31:31.000000000 +0200
@@ -18,6 +18,7 @@
  */
 #define TIMEOUT	(6 * HZ)
 
+static int refrigerator_disabled;
 
 static inline int freezeable(struct task_struct * p)
 {
@@ -47,9 +48,12 @@ void refrigerator(unsigned long flag)
 	recalc_sigpending(); /* We sent fake signal, clean it up */
 	spin_unlock_irq(&current->sighand->siglock);
 
-	current->flags |= PF_FROZEN;
-	while (current->flags & PF_FROZEN)
-		schedule();
+	if (!refrigerator_disabled) {
+		current->flags |= PF_FROZEN;
+		while (current->flags & PF_FROZEN)
+			schedule();
+	}
+
 	pr_debug("%s left refrigerator\n", current->comm);
 	current->state = save;
 }
@@ -62,6 +66,7 @@ int freeze_processes(void)
 	struct task_struct *g, *p;
 	
 	printk( "Stopping tasks: " );
+	refrigerator_disabled = 0;
 	start_time = jiffies;
 	do {
 		todo = 0;
@@ -72,6 +77,9 @@ int freeze_processes(void)
 				continue;
 			if (p->flags & PF_FROZEN)
 				continue;
+			if ((p->flags & PF_FREEZE) &&
+			    (p->state == TASK_UNINTERRUPTIBLE))
+			    	continue;
 
 			/* FIXME: smp problem here: we may not access other process' flags
 			   without locking */
@@ -100,6 +108,7 @@ void thaw_processes(void)
 	struct task_struct *g, *p;
 
 	printk( "Restarting tasks..." );
+	refrigerator_disabled = 1;
 	read_lock(&tasklist_lock);
 	do_each_thread(g, p) {
 		if (!freezeable(p))

>
> In this way, I handle kseriod and anything else uninterruptible without
> any problems.

Exactly. :-)

Greets,
Rafael


-- 
- Would you tell me, please, which way I ought to go from here?
- That depends a good deal on where you want to get to.
		-- Lewis Carroll "Alice's Adventures in Wonderland"

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



  reply	other threads:[~2005-04-06  6:41 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-05  9:20 freeze_processes questions Rafael J. Wysocki
2005-04-05  9:27 ` Pavel Machek
2005-04-05  9:53   ` Rafael J. Wysocki
2005-04-05 18:02     ` Rafael J. Wysocki
2005-04-05 18:17       ` Alan Stern
2005-04-05 18:33         ` Rafael J. Wysocki
2005-04-05 20:37       ` Pavel Machek
2005-04-05 22:46         ` Rafael J. Wysocki
2005-04-05 22:57           ` Pavel Machek
2005-04-05 23:10             ` Nigel Cunningham
2005-04-06  6:41               ` Rafael J. Wysocki [this message]
2005-04-06 19:06               ` Alan Stern
2005-04-06 20:52                 ` Rafael J. Wysocki
2005-04-06 21:03                   ` Alan Stern
2005-04-06 21:26                     ` David Brownell
2005-04-06 21:17                   ` Pavel Machek
2005-04-06 21:35                     ` Rafael J. Wysocki
2005-04-06 22:07                       ` Nigel Cunningham
2005-04-06 22:41                         ` Rafael J. Wysocki
2005-04-07 14:41                           ` Alan Stern
2005-04-07 17:17                             ` Rafael J. Wysocki
2005-04-07 14:43                         ` Alan Stern
2005-04-07 17:26                           ` Rafael J. Wysocki
2005-04-07  9:11                       ` Pavel Machek
2005-04-07 12:29                         ` Rafael J. Wysocki
2005-04-07 12:47                           ` Nigel Cunningham
2005-04-07 14:36                           ` Alan Stern
2005-04-07 18:03                             ` Rafael J. Wysocki
2005-04-07 20:00                               ` Alan Stern
2005-04-07 20:59                                 ` Rafael J. Wysocki
2005-04-07 22:09                                   ` Alan Stern
2005-04-08  6:20                                   ` Pavel Machek
2005-04-08  9:13                                     ` Rafael J. Wysocki
2005-04-07 21:03                                 ` Rafael J. Wysocki
2005-04-08  6:23                                   ` Pavel Machek
2005-04-08 11:23                                     ` Rafael J. Wysocki
2005-04-11 23:59                                       ` Pavel Machek
2005-04-27  9:30                                       ` Li Shaohua
2005-04-27  9:53                                         ` Nigel Cunningham
2005-04-28  4:48                                           ` Li Shaohua
2005-04-28  5:05                                             ` Nigel Cunningham
2005-04-28  5:21                                               ` Li Shaohua
2005-04-28  5:49                                                 ` Nigel Cunningham
2005-04-28  6:01                                                   ` Li Shaohua
2005-04-28  6:21                                                     ` Nigel Cunningham
2005-04-28  8:15                                                   ` Pavel Machek
2005-04-28  8:14                                             ` Pavel Machek
2005-04-28 15:19                                               ` Stefan Seyfried
2005-04-28 18:47                                                 ` Pavel Machek
2005-04-08  7:20                               ` Pavel Machek
2005-04-06 21:34               ` David Brownell
2005-04-06 22:03                 ` Nigel Cunningham
2005-04-06 22:20                   ` David Brownell
2005-04-07  9:09                 ` Pavel Machek
2005-04-08  6:23               ` Pavel Machek
2005-04-08  7:18                 ` Nigel Cunningham

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=200504060841.54490.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=linux-pm@lists.osdl.org \
    --cc=ncunningham@cyclades.com \
    --cc=pavel@ucw.cz \
    /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