From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB27A2BF3F2; Mon, 5 May 2025 22:48:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746485310; cv=none; b=HZCeOh++DDVmFmSvOhHy4ESBJ31d8iyGdxwZLlgqf9ogwqrhB3U/f/b21kVo70/rXzdKzHNs8PFFGGQPUznc1mQ4eBmHNrSn/cmvIYjgpHFHT4FJvgX2qAcBqMixq3ev3bgC6dcTxoC/0eU1EwWZ4HDVxi4bWuyOY9FAHLkjHGk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746485310; c=relaxed/simple; bh=sA5+9iikc4LH5jdFJudKdSamGAlkuDYDKiR3L7gqSEk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gLsIxUswSkYCyckYPoONVeJduPZ4yLDWEekE64ATFKWopMgPInyqjUzolZLfnsGdX2sguMnoo2+iaEjOQ5Stxdn/Wbe1HmKAxhEas1/yomGzOTJb5Qco2okDo3VVKdSu+KX89WVA3ohWRcgCRB5ib9/U8Z8C4TPlprVK+2PcsPQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=c7PEjqW8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="c7PEjqW8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAC1EC4CEED; Mon, 5 May 2025 22:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746485308; bh=sA5+9iikc4LH5jdFJudKdSamGAlkuDYDKiR3L7gqSEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c7PEjqW8eBVx2wyOtXYNXjA0iHAQqbSZ17WMihJ8tggzULfpJK5Fkc+PLy/PqGNF1 bJnxQr6qbSsVRxb7iAH3Z1h1ID1TCtAnvvefmvpW5hSI/oY+zMJ9IsHhEm+c84vajV 3YrElnXzLU+IyZnblVSiufoUv6z3mC2g9i8I674j1Riu+5fEvt5WScbXdiGeW5Af3o Wn9y9tvguzmQliq1sKZ0I/HdDkQ8fZYgzc0+r0RddnJ0q+3Iltug859GCjFKqigQuh pBPOlOxEBGhZmo4mgagZnse2zF9FjpHbwPHcNpnBEWeRi51Pgr9z0LEGunMmqh+OD7 pPp1btXBg7MiQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Rafael J. Wysocki" , Artem Bityutskiy , Christian Loehle , Aboorva Devarajan , Sasha Levin , rafael@kernel.org, daniel.lezcano@linaro.org, linux-pm@vger.kernel.org Subject: [PATCH AUTOSEL 6.12 260/486] cpuidle: menu: Avoid discarding useful information Date: Mon, 5 May 2025 18:35:36 -0400 Message-Id: <20250505223922.2682012-260-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250505223922.2682012-1-sashal@kernel.org> References: <20250505223922.2682012-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.12.26 Content-Transfer-Encoding: 8bit From: "Rafael J. Wysocki" [ 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 Reported-by: Artem Bityutskiy Tested-by: Artem Bityutskiy Reviewed-by: Christian Loehle Tested-by: Christian Loehle Tested-by: Aboorva Devarajan Link: https://patch.msgid.link/7770672.EvYhyI6sBW@rjwysocki.net Signed-off-by: Sasha Levin --- 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 f3c9d49f0f2a5..97ffadc7e57a6 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -239,8 +239,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