Skip to content

Commit 4cc6de0

Browse files
rafaeljwopsiff
authored andcommitted
cpuidle: menu: Avoid discarding useful information
[ Upstream commit 85975da ] When giving up on making a high-confidence prediction, get_typical_interval() always returns UINT_MAX which means that the next idle interval prediction will be based entirely on the time till the next timer. However, the information represented by the most recent intervals may not be completely useless in those cases. Namely, the largest recent idle interval is an upper bound on the recently observed idle duration, so it is reasonable to assume that the next idle duration is unlikely to exceed it. Moreover, this is still true after eliminating the suspected outliers if the sample set still under consideration is at least as large as 50% of the maximum sample set size. Accordingly, make get_typical_interval() return the current maximum recent interval value in that case instead of UINT_MAX. Signed-off-by: Rafael J. Wysocki <[email protected]> Reported-by: Artem Bityutskiy <[email protected]> Tested-by: Artem Bityutskiy <[email protected]> Reviewed-by: Christian Loehle <[email protected]> Tested-by: Christian Loehle <[email protected]> Tested-by: Aboorva Devarajan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 3cd2aa93674ee9e6cb711d81c0486ade690f98fc)
1 parent 3b66606 commit 4cc6de0

File tree

1 file changed

+12
-1
lines changed
  • drivers/cpuidle/governors

1 file changed

+12
-1
lines changed

drivers/cpuidle/governors/menu.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,19 @@ static unsigned int get_typical_interval(struct menu_device *data)
246246
* This can deal with workloads that have long pauses interspersed
247247
* with sporadic activity with a bunch of short pauses.
248248
*/
249-
if ((divisor * 4) <= INTERVALS * 3)
249+
if (divisor * 4 <= INTERVALS * 3) {
250+
/*
251+
* If there are sufficiently many data points still under
252+
* consideration after the outliers have been eliminated,
253+
* returning without a prediction would be a mistake because it
254+
* is likely that the next interval will not exceed the current
255+
* maximum, so return the latter in that case.
256+
*/
257+
if (divisor >= INTERVALS / 2)
258+
return max;
259+
250260
return UINT_MAX;
261+
}
251262

252263
thresh = max - 1;
253264
goto again;

0 commit comments

Comments
 (0)