]> git.hungrycats.org Git - linux/commitdiff
[PATCH] sched: improved cpu_load rounding
authorAndrew Morton <akpm@osdl.org>
Sat, 15 May 2004 03:12:44 +0000 (20:12 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 15 May 2004 03:12:44 +0000 (20:12 -0700)
From: Nick Piggin <nickpiggin@yahoo.com.au>

"Siddha, Suresh B" <suresh.b.siddha@intel.com> noticed a problem in the
cpu_load averaging where the integer truncation could sometimes cause cpu_load
to never quite reach its target.

I'm not sure that you could demonstrate a real world problem, but I quite
like this fix.

kernel/sched.c

index e2b7e89d709d636d282ddaf86f4868626c61297f..808730b68d7a0c5e116eb1cbbe1a6f448892eae7 100644 (file)
@@ -1854,6 +1854,13 @@ static void rebalance_tick(int this_cpu, runqueue_t *this_rq,
        /* Update our load */
        old_load = this_rq->cpu_load;
        this_load = this_rq->nr_running * SCHED_LOAD_SCALE;
+       /*
+        * Round up the averaging division if load is increasing. This
+        * prevents us from getting stuck on 9 if the load is 10, for
+        * example.
+        */
+       if (this_load > old_load)
+               old_load++;
        this_rq->cpu_load = (old_load + this_load) / 2;
 
        for_each_domain(this_cpu, sd) {