freezer: replace msleep with usleep_delay for sleep time of <20mS

usleep_delay() works more accurately for sleep time of <20mS.
All tasks can easily be frozen in under 10 ms, switch to using
an initial 1 ms sleep followed by exponential backoff until 8 ms.

Change-Id: Id932d7dbefe9c59eded33aa87cdb3cb8b581efa2
Signed-off-by: Sravan Kumar Ambapuram <asravan@codeaurora.org>
This commit is contained in:
Sravan Kumar Ambapuram
2014-02-26 13:10:57 +05:30
parent 83165d009a
commit 3d50715f62
+6 -2
View File
@@ -35,6 +35,7 @@ static int try_to_freeze_tasks(bool user_only)
u64 elapsed_csecs64;
unsigned int elapsed_csecs;
bool wakeup = false;
int sleep_usecs = USEC_PER_MSEC;
do_gettimeofday(&start);
@@ -81,9 +82,12 @@ static int try_to_freeze_tasks(bool user_only)
/*
* We need to retry, but first give the freezing tasks some
* time to enter the regrigerator.
* time to enter the refrigerator. Start with an initial
* 1 ms sleep followed by exponential backoff until 8 ms.
*/
msleep(10);
usleep_range(sleep_usecs / 2, sleep_usecs);
if (sleep_usecs < 8 * USEC_PER_MSEC)
sleep_usecs *= 2;
}
do_gettimeofday(&end);