Skip to content

Commit 083383a

Browse files
rafaeljwgregkh
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]>
1 parent 0d508ce commit 083383a

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
@@ -239,8 +239,19 @@ static unsigned int get_typical_interval(struct menu_device *data)
239239
* This can deal with workloads that have long pauses interspersed
240240
* with sporadic activity with a bunch of short pauses.
241241
*/
242-
if ((divisor * 4) <= INTERVALS * 3)
242+
if (divisor * 4 <= INTERVALS * 3) {
243+
/*
244+
* If there are sufficiently many data points still under
245+
* consideration after the outliers have been eliminated,
246+
* returning without a prediction would be a mistake because it
247+
* is likely that the next interval will not exceed the current
248+
* maximum, so return the latter in that case.
249+
*/
250+
if (divisor >= INTERVALS / 2)
251+
return max;
252+
243253
return UINT_MAX;
254+
}
244255

245256
thresh = max - 1;
246257
goto again;

0 commit comments

Comments
 (0)