Skip to content

Commit 85975da

Browse files
committed
cpuidle: menu: Avoid discarding useful information
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]
1 parent 8de7606 commit 85975da

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
@@ -190,8 +190,19 @@ static unsigned int get_typical_interval(struct menu_device *data)
190190
* This can deal with workloads that have long pauses interspersed
191191
* with sporadic activity with a bunch of short pauses.
192192
*/
193-
if ((divisor * 4) <= INTERVALS * 3)
193+
if (divisor * 4 <= INTERVALS * 3) {
194+
/*
195+
* If there are sufficiently many data points still under
196+
* consideration after the outliers have been eliminated,
197+
* returning without a prediction would be a mistake because it
198+
* is likely that the next interval will not exceed the current
199+
* maximum, so return the latter in that case.
200+
*/
201+
if (divisor >= INTERVALS / 2)
202+
return max;
203+
194204
return UINT_MAX;
205+
}
195206

196207
/* Update the thresholds for the next round. */
197208
if (avg - min > max - avg)

0 commit comments

Comments
 (0)