cpu_capacity initially reflects the maximum possible capacity of a CPU.
Thermal pressure on a CPU means this maximum possible capacity is
unavailable due to thermal events. This patch subtracts the average
thermal pressure for a CPU from its maximum possible capacity so that
cpu_capacity reflects the remaining maximum capacity.
Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lkml.kernel.org/r/20200222005213.3873-8-thara.gopinath@linaro.org
        if (unlikely(irq >= max))
                return 1;
 
+       /*
+        * avg_rt.util_avg and avg_dl.util_avg track binary signals
+        * (running and not running) with weights 0 and 1024 respectively.
+        * avg_thermal.load_avg tracks thermal pressure and the weighted
+        * average uses the actual delta max capacity(load).
+        */
        used = READ_ONCE(rq->avg_rt.util_avg);
        used += READ_ONCE(rq->avg_dl.util_avg);
+       used += thermal_load_avg(rq);
 
        if (unlikely(used >= max))
                return 1;