summaryrefslogtreecommitdiff
path: root/kernel/sched/core.c
diff options
context:
space:
mode:
authorJoonwoo Park <joonwoop@codeaurora.org>2016-06-10 16:16:19 -0700
committerKyle Yan <kyan@codeaurora.org>2016-06-21 15:10:56 -0700
commit14ac5ed8b89b45207345f6e31c47d196a824e7ee (patch)
tree98c571ded2d93a6f305801149ede48f1f350a505 /kernel/sched/core.c
parentc07e88c80f44d27752ca9c4ea36840742c835027 (diff)
sched: fix overflow in scaled execution time calculation
Task execution time in nanoseconds and CPU cycle counters are large enough to cause overflow when we multiply both. Avoid overflow by calculating frequency separately. Change-Id: I076d9ecd27cb1c1f11578f009ebe1a19c1619454 Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Diffstat (limited to 'kernel/sched/core.c')
-rw-r--r--kernel/sched/core.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 839925a3da7e..263c15b0312e 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1941,9 +1941,10 @@ static inline u64 scale_exec_time(u64 delta, struct rq *rq)
{
int cpu = cpu_of(rq);
int sf;
+ u32 freq;
- delta = DIV64_U64_ROUNDUP(delta * rq->cc.cycles,
- max_possible_freq * rq->cc.time);
+ freq = cpu_cycles_to_freq(rq->cc.cycles, rq->cc.time);
+ delta = DIV64_U64_ROUNDUP(delta * freq, max_possible_freq);
sf = DIV_ROUND_UP(cpu_efficiency(cpu) * 1024, max_possible_efficiency);
delta *= sf;