Re: Re: freeze_processes questions

Rafael J. Wysocki
2005-04-08T09:13:40Z

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

Hi,

On Friday, 8 of April 2005 08:20, Pavel Machek wrote:
> Hi!
>
]--snip--[
>
> As we allow resume to be called from userland, other refrigerator is
> not really an option. We could insert mdelay before resume, or some
> equivalent trick...

I have an idea (provided we can disable/enable usermodehelper as in the
Dmitry's patch):

--- old/kernel/power/process.c 2005-04-06 08:30:47.000000000 +0200
+++ new/kernel/power/process.c 2005-04-08 11:11:23.000000000 +0200
@@ -62,6 +62,26 @@ int freeze_processes(void)
struct task_struct *g, *p;

printk( "Stopping tasks: " );
+ usermodehelper_disable();
+ yield();
+ start_time = jiffies;
+ do {
+ todo = 0;
+ read_lock(&tasklist_lock);
+ do_each_thread(g, p)
+ if (!(p->flags & PF_NOFREEZE) &&
+ (p->state == TASK_UNINTERRUPTIBLE))
+ todo++;
+ while_each_thread(g, p);
+ read_unlock(&tasklist_lock);
+ yield();
+ if (time_after(jiffies, start_time + TIMEOUT)) {
+ printk( "\n" );
+ printk(KERN_ERR " stopping tasks faliled (%d unstoppable tasks)\n",
+ todo);
+ return todo;
+ }
+ } while(todo);
start_time = jiffies;
do {
todo = 0;
@@ -100,6 +120,7 @@ void thaw_processes(void)
struct task_struct *g, *p;

printk( "Restarting tasks..." );
+ usermodehelper_enable();
read_lock(&tasklist_lock);
do_each_thread(g, p) {
if (!freezeable(p))

It's not bullet-proof, but should be enough to handle the
"freeze-during-resume" case ...

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"