Skip to content

Commit

Permalink
PM / freezer: Don't get over-anxious while waiting
Browse files Browse the repository at this point in the history
Freezing isn't exactly the most latency sensitive operation and
there's no reason to burn cpu cycles and power waiting for it to
complete.  msleep(10) instead of yield().  This should improve
reliability of emergency hibernation.

[rjw: Modified the comment next to the msleep(10).]

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
  • Loading branch information
Tejun Heo authored and Rafael J. Wysocki committed Oct 28, 2009
1 parent 964fe08 commit be404f0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions kernel/power/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <linux/module.h>
#include <linux/syscalls.h>
#include <linux/freezer.h>
#include <linux/delay.h>

/*
* Timeout for stopping processes
Expand Down Expand Up @@ -41,7 +42,7 @@ static int try_to_freeze_tasks(bool sig_only)
do_gettimeofday(&start);

end_time = jiffies + TIMEOUT;
do {
while (true) {
todo = 0;
read_lock(&tasklist_lock);
do_each_thread(g, p) {
Expand All @@ -62,10 +63,15 @@ static int try_to_freeze_tasks(bool sig_only)
todo++;
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
yield(); /* Yield is okay here */
if (time_after(jiffies, end_time))
if (!todo || time_after(jiffies, end_time))
break;
} while (todo);

/*
* We need to retry, but first give the freezing tasks some
* time to enter the regrigerator.
*/
msleep(10);
}

do_gettimeofday(&end);
elapsed_csecs64 = timeval_to_ns(&end) - timeval_to_ns(&start);
Expand Down

0 comments on commit be404f0

Please sign in to comment.