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

Commit dd7886b8 authored by Minsung Kim's avatar Minsung Kim Committed by Amit Pundir
Browse files

cpufreq: interactive: avoid underflow on active time calculation



Check for idle time delta less than elapsed time delta, avoid
underflow computing active time.

Change-Id: I3e4c6ef1ad794eec49ed379c0c50fa727fd6ad28
Signed-off-by: default avatarMinsung Kim <ms925.kim@samsung.com>
parent 4eebb54d
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -325,7 +325,12 @@ static u64 update_load(int cpu)
	now_idle = get_cpu_idle_time(cpu, &now);
	delta_idle = (unsigned int)(now_idle - pcpu->time_in_idle);
	delta_time = (unsigned int)(now - pcpu->time_in_idle_timestamp);

	if (delta_time <= delta_idle)
		active_time = 0;
	else
		active_time = delta_time - delta_idle;

	pcpu->cputime_speedadj += active_time * pcpu->policy->cur;

	pcpu->time_in_idle = now_idle;