Messages in this thread Patch in this message | | | From | Andi Kleen <> | Subject | [PATCH REPOST] [1/3] SCHED: cache task_hot result | Date | Sat, 15 Nov 2008 14:38:00 +0100 (CET) |
| |
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@linux.intel.com>
--- 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; }
| |