Commit 438e2ce6 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Linus Torvalds

freezer: measure freezing time

Measure the time of the freezing of tasks, even if it doesn't fail.
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b842ee57
...@@ -168,6 +168,11 @@ static int try_to_freeze_tasks(int freeze_user_space) ...@@ -168,6 +168,11 @@ static int try_to_freeze_tasks(int freeze_user_space)
struct task_struct *g, *p; struct task_struct *g, *p;
unsigned long end_time; unsigned long end_time;
unsigned int todo; unsigned int todo;
struct timeval start, end;
s64 elapsed_csecs64;
unsigned int elapsed_csecs;
do_gettimeofday(&start);
end_time = jiffies + TIMEOUT; end_time = jiffies + TIMEOUT;
do { do {
...@@ -194,6 +199,11 @@ static int try_to_freeze_tasks(int freeze_user_space) ...@@ -194,6 +199,11 @@ static int try_to_freeze_tasks(int freeze_user_space)
break; break;
} while (todo); } while (todo);
do_gettimeofday(&end);
elapsed_csecs64 = timeval_to_ns(&end) - timeval_to_ns(&start);
do_div(elapsed_csecs64, NSEC_PER_SEC / 100);
elapsed_csecs = elapsed_csecs64;
if (todo) { if (todo) {
/* This does not unfreeze processes that are already frozen /* This does not unfreeze processes that are already frozen
* (we have slightly ugly calling convention in that respect, * (we have slightly ugly calling convention in that respect,
...@@ -201,10 +211,9 @@ static int try_to_freeze_tasks(int freeze_user_space) ...@@ -201,10 +211,9 @@ static int try_to_freeze_tasks(int freeze_user_space)
* but it cleans up leftover PF_FREEZE requests. * but it cleans up leftover PF_FREEZE requests.
*/ */
printk("\n"); printk("\n");
printk(KERN_ERR "Freezing of %s timed out after %d seconds " printk(KERN_ERR "Freezing of tasks failed after %d.%02d seconds "
"(%d tasks refusing to freeze):\n", "(%d tasks refusing to freeze):\n",
freeze_user_space ? "user space " : "tasks ", elapsed_csecs / 100, elapsed_csecs % 100, todo);
TIMEOUT / HZ, todo);
show_state(); show_state();
read_lock(&tasklist_lock); read_lock(&tasklist_lock);
do_each_thread(g, p) { do_each_thread(g, p) {
...@@ -215,6 +224,9 @@ static int try_to_freeze_tasks(int freeze_user_space) ...@@ -215,6 +224,9 @@ static int try_to_freeze_tasks(int freeze_user_space)
task_unlock(p); task_unlock(p);
} while_each_thread(g, p); } while_each_thread(g, p);
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
} else {
printk("(elapsed %d.%02d seconds) ", elapsed_csecs / 100,
elapsed_csecs % 100);
} }
return todo ? -EBUSY : 0; return todo ? -EBUSY : 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment