cpufreq: interactive governor drops bits in time calculation
authorChris Redpath <chris.redpath@arm.com>
Mon, 17 Jun 2013 17:36:56 +0000 (18:36 +0100)
committerAmit Pundir <amit.pundir@linaro.org>
Mon, 10 Apr 2017 07:42:16 +0000 (13:12 +0530)
Keep time calculation in 64-bit throughout. If we have long times
between idle calculations this can result in deltas > 32 bits
which causes incorrect load percentage calculations and selecting
the wrong frequencies if we truncate here.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
drivers/cpufreq/cpufreq_interactive.c

index f2929e62882074b7ca8fd03b607d2018b5e3db8a..889c9b8b2237d5da4325d515e0f5f0ee41c249d3 100644 (file)
@@ -312,13 +312,13 @@ static u64 update_load(int cpu)
                pcpu->policy->governor_data;
        u64 now;
        u64 now_idle;
-       unsigned int delta_idle;
-       unsigned int delta_time;
+       u64 delta_idle;
+       u64 delta_time;
        u64 active_time;
 
        now_idle = get_cpu_idle_time(cpu, &now, tunables->io_is_busy);
-       delta_idle = (unsigned int)(now_idle - pcpu->time_in_idle);
-       delta_time = (unsigned int)(now - pcpu->time_in_idle_timestamp);
+       delta_idle = (now_idle - pcpu->time_in_idle);
+       delta_time = (now - pcpu->time_in_idle_timestamp);
 
        if (delta_time <= delta_idle)
                active_time = 0;