Re: [PATCH -mm 3/3] Freezer: Measure freezing time

2007-08-01 Thread Andrew Morton
On Wed, 1 Aug 2007 23:36:39 +0200
"Rafael J. Wysocki" <[EMAIL PROTECTED]> wrote:

> + do_gettimeofday();
> + elapsed_csecs64 = timeval_to_ns() - timeval_to_ns();
> + do_div(elapsed_csecs64, NSEC_PER_SEC / 100);
> + elapsed_csecs = elapsed_csecs64;

I'd have thought that we had enough timeval library code by now to
not need to open-code things like this.



No, it seems that we don't.  So people keep on open-coding the same
thing, or inventing private code which shouldn't be.



What the hell is all that stuff doing in there?
-
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/


[PATCH -mm 3/3] Freezer: Measure freezing time

2007-08-01 Thread Rafael J. Wysocki
From: Rafael J. Wysocki <[EMAIL PROTECTED]>

Measure the time of the freezing of tasks, even if it doesn't fail.

Signed-off-by: Rafael J. Wysocki <[EMAIL PROTECTED]>
Acked-by: Pavel Machek <[EMAIL PROTECTED]>
---
 kernel/power/process.c |   18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

Index: linux-2.6.23-rc1/kernel/power/process.c
===
--- linux-2.6.23-rc1.orig/kernel/power/process.c2007-07-31 
23:00:43.0 +0200
+++ linux-2.6.23-rc1/kernel/power/process.c 2007-07-31 23:00:52.0 
+0200
@@ -190,6 +190,11 @@ static int try_to_freeze_tasks(int freez
struct task_struct *g, *p;
unsigned long end_time;
unsigned int todo;
+   struct timeval start, end;
+   s64 elapsed_csecs64;
+   unsigned int elapsed_csecs;
+
+   do_gettimeofday();
 
end_time = jiffies + TIMEOUT;
refrigerator_called = 0;
@@ -226,6 +231,11 @@ static int try_to_freeze_tasks(int freez
break;
} while (todo);
 
+   do_gettimeofday();
+   elapsed_csecs64 = timeval_to_ns() - timeval_to_ns();
+   do_div(elapsed_csecs64, NSEC_PER_SEC / 100);
+   elapsed_csecs = elapsed_csecs64;
+
if (todo) {
/* This does not unfreeze processes that are already frozen
 * (we have slightly ugly calling convention in that respect,
@@ -233,10 +243,9 @@ static int try_to_freeze_tasks(int freez
 * but it cleans up leftover PF_FREEZE requests.
 */
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",
-   freeze_user_space ? "user space " : "tasks ",
-   TIMEOUT / HZ, todo);
+   elapsed_csecs / 100, elapsed_csecs % 100, todo);
show_state();
read_lock(_lock);
do_each_thread(g, p) {
@@ -247,6 +256,9 @@ static int try_to_freeze_tasks(int freez
task_unlock(p);
} while_each_thread(g, p);
read_unlock(_lock);
+   } else {
+   printk("(elapsed %d.%02d seconds) ", elapsed_csecs / 100,
+   elapsed_csecs % 100);
}
 
return todo ? -EBUSY : 0;
-
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/


[PATCH -mm 3/3] Freezer: Measure freezing time

2007-08-01 Thread Rafael J. Wysocki
From: Rafael J. Wysocki [EMAIL PROTECTED]

Measure the time of the freezing of tasks, even if it doesn't fail.

Signed-off-by: Rafael J. Wysocki [EMAIL PROTECTED]
Acked-by: Pavel Machek [EMAIL PROTECTED]
---
 kernel/power/process.c |   18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

Index: linux-2.6.23-rc1/kernel/power/process.c
===
--- linux-2.6.23-rc1.orig/kernel/power/process.c2007-07-31 
23:00:43.0 +0200
+++ linux-2.6.23-rc1/kernel/power/process.c 2007-07-31 23:00:52.0 
+0200
@@ -190,6 +190,11 @@ static int try_to_freeze_tasks(int freez
struct task_struct *g, *p;
unsigned long end_time;
unsigned int todo;
+   struct timeval start, end;
+   s64 elapsed_csecs64;
+   unsigned int elapsed_csecs;
+
+   do_gettimeofday(start);
 
end_time = jiffies + TIMEOUT;
refrigerator_called = 0;
@@ -226,6 +231,11 @@ static int try_to_freeze_tasks(int freez
break;
} 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) {
/* This does not unfreeze processes that are already frozen
 * (we have slightly ugly calling convention in that respect,
@@ -233,10 +243,9 @@ static int try_to_freeze_tasks(int freez
 * but it cleans up leftover PF_FREEZE requests.
 */
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,
-   freeze_user_space ? user space  : tasks ,
-   TIMEOUT / HZ, todo);
+   elapsed_csecs / 100, elapsed_csecs % 100, todo);
show_state();
read_lock(tasklist_lock);
do_each_thread(g, p) {
@@ -247,6 +256,9 @@ static int try_to_freeze_tasks(int freez
task_unlock(p);
} while_each_thread(g, p);
read_unlock(tasklist_lock);
+   } else {
+   printk((elapsed %d.%02d seconds) , elapsed_csecs / 100,
+   elapsed_csecs % 100);
}
 
return todo ? -EBUSY : 0;
-
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/


Re: [PATCH -mm 3/3] Freezer: Measure freezing time

2007-08-01 Thread Andrew Morton
On Wed, 1 Aug 2007 23:36:39 +0200
Rafael J. Wysocki [EMAIL PROTECTED] wrote:

 + 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;

I'd have thought that we had enough timeval library code by now to
not need to open-code things like this.

looks around

No, it seems that we don't.  So people keep on open-coding the same
thing, or inventing private code which shouldn't be.

notices net/dccp/dccp.h

What the hell is all that stuff doing in there?
-
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/