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 81AB6221558; Mon, 2 Jun 2025 14:33:03 +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=1748874783; cv=none; b=rE+k3jzLSzA1cfmEJ9srdgke5Q96JWnO8I+b8sOSO/wjCgpZKObJXzL2Q6kOnc8nEBr2XT1Pk60MvKv9+Zd+2jd/4xtq5Qka9qkO0DEc3qQmmL2SF8mm1ODvImefp3AGBTmmKwECo3K/FI0FT0DlaIsIs//1QzF4PXoMXQjKHhI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748874783; c=relaxed/simple; bh=U1/zH4LKtcvupLFMSM6tme45y/mYSyUsCmedwBemPs8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FVNZuIxWjjfQr8G2T+SgOk1pk4ZKX9xqGvstZMJYERVy9jf0uXYnS7SRk1HtUovnRxtEtuZ0flbPS5Fik680VVlhhJOaqnjU/m5AQtKJaKuxfHgemhF5MSNcZAjzRYrkFpQ+/8wzEADLvk+6MUJDrJ/gX7RGvUFcUfnszdfSgrM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Kwcsckds; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Kwcsckds" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3E6BC4CEEB; Mon, 2 Jun 2025 14:33:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1748874783; bh=U1/zH4LKtcvupLFMSM6tme45y/mYSyUsCmedwBemPs8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KwcsckdssgDAyAzZxV/SkijpBCIlnN3IO3CpN7CGfgGFOXj0DyV9Q2d2qAT6Sg7vx nnCMVYWN6EyeWnan/TK9gJ73h8kX+wjJWgQdlNFzmfMMS0/Xe01LqnB1PNk14Dk6Hk z1C+CRCtZYtepfoByJrc3MgyaH/U5GMaG6TM+K0Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Rafael J. Wysocki" , Artem Bityutskiy , Christian Loehle , Aboorva Devarajan , Sasha Levin Subject: [PATCH 5.4 133/204] cpuidle: menu: Avoid discarding useful information Date: Mon, 2 Jun 2025 15:47:46 +0200 Message-ID: <20250602134300.878922057@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250602134255.449974357@linuxfoundation.org> References: <20250602134255.449974357@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ 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 e5a5d0c8d66b1..bb7288f6adbf6 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -259,8 +259,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