From: Minsung Kim Date: Tue, 23 Apr 2013 13:32:01 +0000 (+0900) Subject: cpufreq: interactive: avoid underflow on active time calculation X-Git-Tag: firefly_0821_release~4090^2~567 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3ab74abdc30faaaa49eae6ae233769b092ec3378;p=firefly-linux-kernel-4.4.55.git 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: Minsung Kim --- diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c index b4d12b266c64..7303f50a1180 100644 --- a/drivers/cpufreq/cpufreq_interactive.c +++ b/drivers/cpufreq/cpufreq_interactive.c @@ -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); - active_time = delta_time - delta_idle; + + 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;