public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Li Shaohua <shaohua.li@intel.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>, Pavel Machek <pavel@ucw.cz>,
	Nigel Cunningham <ncunningham@linuxmail.org>
Cc: Linux-pm mailing list <linux-pm@lists.osdl.org>
Subject: Re: Re: freeze_processes questions
Date: Wed, 27 Apr 2005 17:30:41 +0800	[thread overview]
Message-ID: <1114594241.12809.37.camel@sli10-desk.sh.intel.com> (raw)
In-Reply-To: <200504081323.51164.rjw@sisk.pl>

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

Hi,
Sorry for raising the problem again after a long time. I got some
reports about ' xxx not stopped' at suspend time. The general cause is
one task is waiting for another task which has been into refrigerator
first. Report an error and stop suspend can't solve the problem. After
the task's dependent task is released from refrigerator, the task itself
will soon go into refrigerator and will never be waked up. 
Nigel's refrigerator patch half solves the problem. It distinct kernel
tasks and user tasks, so can solve the dependence between kernel tasks
and user tasks, but can't solve the user tasks dependence. Right, Nigel?
Below is a proposal method to solve the issue. Assume task A depends on
task B. Task B is frozen first. When we find task A can't be frozen
after a long time, we thaw all tasks and let task A continue (task A has
gotten a freeze signal so it will soon go into refrigerator) and then we
freeze other tasks again. In theory, this can solve all task dependence
(sure can't solve the circled dependence) if the retry times are enough
big, but cost maybe too high. Looks it help my case (syslogd can't be
stopped because it's waitting for kjournald). Any idea?

Thanks,
Shaohua



---

 linux-2.6.11-root/kernel/power/process.c |   36 +++++++++++++++++++++++++++----
 1 files changed, 32 insertions(+), 4 deletions(-)

diff -puN kernel/power/process.c~freeze_process_order kernel/power/process.c
--- linux-2.6.11/kernel/power/process.c~freeze_process_order	2005-04-27 15:39:38.014090112 +0800
+++ linux-2.6.11-root/kernel/power/process.c	2005-04-27 17:02:37.884034808 +0800
@@ -16,7 +16,8 @@
 /* 
  * Timeout for stopping processes
  */
-#define TIMEOUT	(6 * HZ)
+#define TIMEOUT	(3 * HZ)
+#define RETRY (2)
 
 
 static inline int freezeable(struct task_struct * p)
@@ -54,12 +55,34 @@ void refrigerator(unsigned long flag)
 	current->state = save;
 }
 
+static void freeze_processes_failure(void)
+{
+	struct task_struct *g, *p;
+
+	/* thaw frozen processes and let process which received a frozen signal
+	 * but was waitting for other process go.
+	 */
+	read_lock(&tasklist_lock);
+	do_each_thread(g, p) {
+		if (!freezeable(p))
+			continue;
+		if (p->flags & PF_FROZEN) {
+			p->flags &= ~PF_FROZEN;
+			wake_up_process(p);
+		}
+	} while_each_thread(g, p);
+	read_unlock(&tasklist_lock);
+
+	yield();
+}
+
 /* 0 = success, else # of processes that we failed to stop */
 int freeze_processes(void)
 {
        int todo;
        unsigned long start_time;
 	struct task_struct *g, *p;
+	int retry_times = 1;
 	
 	printk( "Stopping tasks: " );
 	start_time = jiffies;
@@ -86,9 +109,14 @@ int freeze_processes(void)
 		read_unlock(&tasklist_lock);
 		yield();			/* Yield is okay here */
 		if (time_after(jiffies, start_time + TIMEOUT)) {
-			printk( "\n" );
-			printk(KERN_ERR " stopping tasks failed (%d tasks remaining)\n", todo );
-			return todo;
+			if (retry_times >= RETRY) {
+				printk( "\n" );
+				printk(KERN_ERR " stopping tasks failed (%d tasks remaining)\n", todo );
+				return todo;
+			}
+			retry_times ++;
+			start_time = jiffies;
+ 			freeze_processes_failure();
 		}
 	} while(todo);
 	
_



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



  parent reply	other threads:[~2005-04-27  9:30 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
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 [this message]
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=1114594241.12809.37.camel@sli10-desk.sh.intel.com \
    --to=shaohua.li@intel.com \
    --cc=linux-pm@lists.osdl.org \
    --cc=ncunningham@linuxmail.org \
    --cc=pavel@ucw.cz \
    --cc=rjw@sisk.pl \
    /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