From dbd548aed7e2657b1ec16e2b1b6adb43642ea8b3 Mon Sep 17 00:00:00 2001 From: Joonwoo Park Date: Mon, 12 Jan 2015 17:13:45 -0800 Subject: sched: fix rounding error on scaled execution time calculation It's found that the scaled execution time can be less than its actual time due to rounding errors. The HMP scheduler accumulates scaled execution time of tasks to determine if tasks are in need of up-migration. But the rounding error prevents the HMP scheduler from accumulating 100% load which prevents us from ever reaching an up-migrate of 100%. Fix rounding error by rounding quotient up. CRs-fixed: 759041 Change-Id: Ie4d9693593cc3053a292a29078aa56e6de8a2d52 Signed-off-by: Joonwoo Park --- kernel/sched/core.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'kernel') diff --git a/kernel/sched/core.c b/kernel/sched/core.c index aee448df0f41..eb6480b51d93 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1288,8 +1288,12 @@ static inline u64 scale_exec_time(u64 delta, struct rq *rq) rq->max_freq < rq->max_possible_freq))) cur_freq = rq->max_possible_freq; - delta = div64_u64(delta * cur_freq, max_possible_freq); - sf = (rq->efficiency * 1024) / max_possible_efficiency; + /* round up div64 */ + delta = div64_u64(delta * cur_freq + max_possible_freq - 1, + max_possible_freq); + + sf = DIV_ROUND_UP(rq->efficiency * 1024, max_possible_efficiency); + delta *= sf; delta >>= 10; @@ -2332,7 +2336,8 @@ unsigned long capacity_scale_cpu_freq(int cpu) */ static inline unsigned long load_scale_cpu_efficiency(int cpu) { - return (1024 * max_possible_efficiency) / cpu_rq(cpu)->efficiency; + return DIV_ROUND_UP(1024 * max_possible_efficiency, + cpu_rq(cpu)->efficiency); } /* @@ -2342,7 +2347,7 @@ static inline unsigned long load_scale_cpu_efficiency(int cpu) */ static inline unsigned long load_scale_cpu_freq(int cpu) { - return (1024 * max_possible_freq) / cpu_rq(cpu)->max_freq; + return DIV_ROUND_UP(1024 * max_possible_freq, cpu_rq(cpu)->max_freq); } static int compute_capacity(int cpu) -- cgit v1.2.3