cpufreq: interactive: Fix potential divide-by-zero operation

prev_load could be zero if no active time is registered for a CPU
within a sampling period. Fix potential divide-by-zero issue when
calculating new load percentage.

Change-Id: I8ad118f5b6b94a410ec59eb5ce939b9467e921c7
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
Signed-off-by: Hanumath Prasad <hpprasad@codeaurora.org>
This commit is contained in:
Junjie Wu 2015-12-02 10:38:50 -08:00 committed by David Keitel
parent 0abcce5b1c
commit 57bb1f8bf9

View file

@ -502,7 +502,10 @@ static void __cpufreq_interactive_timer(unsigned long data, bool is_notif)
cputime_speedadj = (u64)sl->prev_load *
ppol->policy->cpuinfo.max_freq;
do_div(cputime_speedadj, tunables->timer_rate);
new_load_pct = sl->new_task_load * 100 / sl->prev_load;
new_load_pct = 0;
if (sl->prev_load)
new_load_pct = sl->new_task_load * 100 /
sl->prev_load;
} else {
now = update_load(i);
delta_time = (unsigned int)