Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c4989b5 authored by Junjie Wu's avatar Junjie Wu Committed by Stephen Boyd
Browse files

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: default avatarJunjie Wu <junjiew@codeaurora.org>
Signed-off-by: default avatarHanumath Prasad <hpprasad@codeaurora.org>
Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
parent 433ed997
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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)