cpuidle: teo: Rework most recent idle duration values treatment
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 2 Jun 2021 18:17:18 +0000 (20:17 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 11 Jun 2021 16:36:45 +0000 (18:36 +0200)
commit77577558f25d40b82fba98673cf31ca16ba41d34
treeb4658c02e825dc44db9eb9ce58b3b6da41c11558
parentc410a9a142f152006c21a858d734a9f868bc90a6
cpuidle: teo: Rework most recent idle duration values treatment

The TEO (Timer Events Oriented) cpuidle governor uses several most
recent idle duration values for a given CPU to refine the idle state
selection in case the previous long-term trends have not been
followed recently and a new trend appears to be forming.  That is
done by computing the average of the most recent idle duration
values falling below the time till the next timer event ("sleep
length"), provided that they are the majority of the most recent
idle duration values taken into account, and using it as the new
expected idle duration value.

However, idle state selection based on that value may not be optimal,
because the average does not really indicate which of the idle states
with target residencies less than or equal to it is likely to be the
best fit.

Thus, instead of computing the average, make the governor carry out
computations based on the distribution of the most recent idle
duration values among the bins corresponding to different idle
states.  Namely, if the majority of the most recent idle duration
values taken into consideration are less than the current sleep
length (which means that the CPU is likely to wake up early), find
the idle state closest to the "candidate" one "matching" the sleep
length whose target residency is less than or equal to the majority
of the most recent idle duration values that have fallen below the
current sleep length (which means that it is likely to be "shallow
enough" this time).

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpuidle/governors/teo.c