Fix process freezer: thaw processes if something goes wrong and do not
spin in schedule().

Signed-off-by: Pavel Machek <[EMAIL PROTECTED]>

---
commit 5d655d6e10c2a7ab291ee24b467fb167828f508a
tree 8dfa9668e66e7006de7f0107698356718beb1e37
parent 847ddd5de8a88b2d47e759bc94186a77140bc673
author <[EMAIL PROTECTED](none)> Mon, 22 Aug 2005 10:48:24 +0200
committer <[EMAIL PROTECTED](none)> Mon, 22 Aug 2005 10:48:24 +0200

 kernel/power/process.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/kernel/power/process.c b/kernel/power/process.c
--- a/kernel/power/process.c
+++ b/kernel/power/process.c
@@ -38,7 +38,6 @@ void refrigerator(void)
           processes around? */
        long save;
        save = current->state;
-       current->state = TASK_UNINTERRUPTIBLE;
        pr_debug("%s entered refrigerator\n", current->comm);
        printk("=");
 
@@ -47,8 +46,10 @@ void refrigerator(void)
        recalc_sigpending(); /* We sent fake signal, clean it up */
        spin_unlock_irq(&current->sighand->siglock);
 
-       while (frozen(current))
+       while (frozen(current)) {
+               current->state = TASK_UNINTERRUPTIBLE;
                schedule();
+       }
        pr_debug("%s left refrigerator\n", current->comm);
        current->state = save;
 }
@@ -80,13 +81,28 @@ int freeze_processes(void)
                } while_each_thread(g, p);
                read_unlock(&tasklist_lock);
                yield();                        /* Yield is okay here */
-               if (time_after(jiffies, start_time + TIMEOUT)) {
+               if (todo && time_after(jiffies, start_time + TIMEOUT)) {
                        printk( "\n" );
                        printk(KERN_ERR " stopping tasks failed (%d tasks 
remaining)\n", todo );
-                       return todo;
+                       break;
                }
        } while(todo);
 
+       if (todo) {
+               read_lock(&tasklist_lock);
+               do_each_thread(g, p)
+                       if (freezing(p)) {
+                               pr_debug("  clean up: %s\n", p->comm);
+                               p->flags &= ~PF_FREEZE;
+                               spin_lock_irqsave(&p->sighand->siglock, flags);
+                               recalc_sigpending_tsk(p);
+                               spin_unlock_irqrestore(&p->sighand->siglock, 
flags);
+                       }
+               while_each_thread(g, p);
+               read_unlock(&tasklist_lock);
+               return todo;
+       }
+
        printk( "|\n" );
        BUG_ON(in_atomic());
        return 0;

-- 
if you have sharp zaurus hardware you don't need... you know my address
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to