[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250505231817.2697367-66-sashal@kernel.org>
Date: Mon, 5 May 2025 19:17:29 -0400
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
Artem Bityutskiy <artem.bityutskiy@...ux.intel.com>,
Christian Loehle <christian.loehle@....com>,
Aboorva Devarajan <aboorvad@...ux.ibm.com>,
Sasha Levin <sashal@...nel.org>,
rafael@...nel.org,
daniel.lezcano@...aro.org,
linux-pm@...r.kernel.org
Subject: [PATCH AUTOSEL 5.10 066/114] cpuidle: menu: Avoid discarding useful information
From: "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>
[ Upstream commit 85975daeaa4d6ec560bfcd354fc9c08ad7f38888 ]
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 <rafael.j.wysocki@...el.com>
Reported-by: Artem Bityutskiy <artem.bityutskiy@...ux.intel.com>
Tested-by: Artem Bityutskiy <artem.bityutskiy@...ux.intel.com>
Reviewed-by: Christian Loehle <christian.loehle@....com>
Tested-by: Christian Loehle <christian.loehle@....com>
Tested-by: Aboorva Devarajan <aboorvad@...ux.ibm.com>
Link: https://patch.msgid.link/7770672.EvYhyI6sBW@rjwysocki.net
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
drivers/cpuidle/governors/menu.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index b0a7ad566081a..a95cc8f024fde 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -249,8 +249,19 @@ static unsigned int get_typical_interval(struct menu_device *data,
* This can deal with workloads that have long pauses interspersed
* with sporadic activity with a bunch of short pauses.
*/
- if ((divisor * 4) <= INTERVALS * 3)
+ if (divisor * 4 <= INTERVALS * 3) {
+ /*
+ * If there are sufficiently many data points still under
+ * consideration after the outliers have been eliminated,
+ * returning without a prediction would be a mistake because it
+ * is likely that the next interval will not exceed the current
+ * maximum, so return the latter in that case.
+ */
+ if (divisor >= INTERVALS / 2)
+ return max;
+
return UINT_MAX;
+ }
thresh = max - 1;
goto again;
--
2.39.5
Powered by blists - more mailing lists