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>
This commit is contained in:
Joonwoo Park 2016-06-10 16:16:19 -07:00 committed by Kyle Yan
parent c07e88c80f
commit 14ac5ed8b8

View file

@ -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;