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:
parent
0abcce5b1c
commit
57bb1f8bf9
1 changed files with 4 additions and 1 deletions
|
@ -502,7 +502,10 @@ static void __cpufreq_interactive_timer(unsigned long data, bool is_notif)
|
||||||
cputime_speedadj = (u64)sl->prev_load *
|
cputime_speedadj = (u64)sl->prev_load *
|
||||||
ppol->policy->cpuinfo.max_freq;
|
ppol->policy->cpuinfo.max_freq;
|
||||||
do_div(cputime_speedadj, tunables->timer_rate);
|
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 {
|
} else {
|
||||||
now = update_load(i);
|
now = update_load(i);
|
||||||
delta_time = (unsigned int)
|
delta_time = (unsigned int)
|
||||||
|
|
Loading…
Add table
Reference in a new issue