From: "Rafael J. Wysocki" rafael.j.wysocki@intel.com
mainline inclusion from mainline-v5.5-rc1 commit: b6495b7 category: bugfix bugzilla: 38291 CVE: NA
-------------------------------------------------
One purpose of the computations in teo_update() is to determine whether or not the (saved) time till the next timer event and the measured idle duration fall into the same "bin", so avoid using values that include the cpuidle overhead to obtain the latter.
Signed-off-by: Rafael J. Wysocki rafael.j.wysocki@intel.com
Conflicts: drivers/cpuidle/governors/teo.c [wangxiongfeng: fix conflicts caused by skipping the following commit when we backport feature TEO. c1d51f6 cpuidle: Use nanoseconds as the unit of time ]
Signed-off-by: Xiongfeng Wang wangxiongfeng2@huawei.com Reviewed-by: Hanjun Guo guohanjun@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/cpuidle/governors/teo.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c index db24fa7df458..c7ac2ed4dd3c 100644 --- a/drivers/cpuidle/governors/teo.c +++ b/drivers/cpuidle/governors/teo.c @@ -133,7 +133,14 @@ static void teo_update(struct cpuidle_driver *drv, struct cpuidle_device *dev) } else { unsigned int lat = drv->states[cpu_data->last_state].exit_latency;
- measured_us = ktime_to_us(cpu_data->time_span_ns); + /* + * The computations below are to determine whether or not the + * (saved) time till the next timer event and the measured idle + * duration fall into the same "bin", so use last_residency_ns + * for that instead of time_span_ns which includes the cpuidle + * overhead. + */ + measured_us = dev->last_residency; /* * The delay between the wakeup and the first instruction * executed by the CPU is not likely to be worst-case every