[PATCH] [1/4] SCHED: cache task_hot result

From: Andi Kleen
Date: Wed Nov 12 2008 - 07:28:09 EST



Minor scheduler optimization: cache the result of task_hot() in
can migrate task instead of computing it three times.

Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>

---
kernel/sched.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

Index: linux-2.6.28-rc4-test/kernel/sched.c
===================================================================
--- linux-2.6.28-rc4-test.orig/kernel/sched.c 2008-11-10 08:50:24.000000000 +0100
+++ linux-2.6.28-rc4-test/kernel/sched.c 2008-11-12 12:32:52.000000000 +0100
@@ -2907,6 +2907,8 @@
struct sched_domain *sd, enum cpu_idle_type idle,
int *all_pinned)
{
+ int hot;
+
/*
* We do not migrate tasks that are:
* 1) running (obviously), or
@@ -2930,10 +2932,11 @@
* 2) too many balance attempts have failed.
*/

- if (!task_hot(p, rq->clock, sd) ||
- sd->nr_balance_failed > sd->cache_nice_tries) {
+ hot = task_hot(p, rq->clock, sd);
+
+ if (!hot || sd->nr_balance_failed > sd->cache_nice_tries) {
#ifdef CONFIG_SCHEDSTATS
- if (task_hot(p, rq->clock, sd)) {
+ if (hot) {
schedstat_inc(sd, lb_hot_gained[idle]);
schedstat_inc(p, se.nr_forced_migrations);
}
@@ -2941,7 +2944,7 @@
return 1;
}

- if (task_hot(p, rq->clock, sd)) {
+ if (hot) {
schedstat_inc(p, se.nr_failed_migrations_hot);
return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/