[PATCH] sched: Improve readability in update_cpu_load() code

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Gautham R Shenoy
Date: Thursday, May 15, 2008 - 6:04 am

Author: Gautham R Shenoy <ego@in.ibm.com>
Date:   Thu May 15 17:55:49 2008 +0530

    sched: Improve readability in update_cpu_load() code
    
    Currently the cpu_load[i] is calculated as:
    	this_rq->cpu_load[i] = (old_load*(scale-1) + new_load) >> i;
    
    However, since scale = 2^i, this can be simplified as:
    	this_rq->cpu_load[i] = old_load + ((new_load - old_load) >> i);
    
    Makes it easier to read.
    Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>

diff --git a/kernel/sched.c b/kernel/sched.c
index 2d7d8f1..e1a6985 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2921,7 +2921,7 @@ static void update_cpu_load(struct rq *this_rq)
 		 */
 		if (new_load > old_load)
 			new_load += scale-1;
-		this_rq->cpu_load[i] = (old_load*(scale-1) + new_load) >> i;
+		this_rq->cpu_load[i] = old_load + ((new_load - old_load) >> i);
 	}
 }
 
-- 
Thanks and Regards
gautham
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] sched: Improve readability in update_cpu_load() code, Gautham R Shenoy, (Thu May 15, 6:04 am)
Re: [PATCH] sched: Improve readability in update_cpu_load( ..., Srivatsa Vaddagiri, (Thu May 15, 7:52 am)
Re: [PATCH] sched: Improve readability in update_cpu_load( ..., Srivatsa Vaddagiri, (Thu May 15, 8:02 am)
Re: [PATCH] sched: Improve readability in update_cpu_load( ..., Gautham R Shenoy, (Thu May 15, 10:11 am)