summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoonwoo Park <joonwoop@codeaurora.org>2015-01-12 17:13:45 -0800
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-23 20:01:37 -0700
commitdbd548aed7e2657b1ec16e2b1b6adb43642ea8b3 (patch)
treede7c8a7addd8f0af754775450739c91674e913a4
parente1e5891538e59dc86915c424a5bc132f2acc5a44 (diff)
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 <joonwoop@codeaurora.org>
-rw-r--r--kernel/sched/core.c13
1 files changed, 9 insertions, 4 deletions
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)