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 101FB3C01; Tue, 27 May 2025 17:35:55 +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=1748367355; cv=none; b=Xwi/XuBpKRFRiaIYZ0vvNSdJqLup0/+23YDBo6CwUCj5TP4D0jUgU03eLkhQlByT+2I7HYGeEiFYeYYYitU9EHx/N5qYXVccsIQEU2dopE/mcgZ+PaiZ/7hf1St6pcZuJgNg5LLzk5/S9UO1r8GIoaGA7QVsPxRdfZxaqH1eArs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748367355; c=relaxed/simple; bh=/gkIIJJK+D+54mJX6/NXDPg43L6JyEVdz1vejA4Dzks=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aRXbpbbnSuhrJ/fOHAOm8qdbmlJ1tWq75RpGsoxfQNjjtnZorScV7kstvzTfsKMj5PXmDzyHByAUwbIw/YMT/Bzvd9qT2GIYuDYi2MMpZzI9eoTYK6Wn0A5brqLFOYdq0ilk91khjkM+jjLsCiXTw0ss3xSy8TVpUyw0hNYAO6Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=D9w/jdYc; 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="D9w/jdYc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EA14C4CEE9; Tue, 27 May 2025 17:35:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1748367354; bh=/gkIIJJK+D+54mJX6/NXDPg43L6JyEVdz1vejA4Dzks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D9w/jdYcX5sexdncy0SIN/mc9xwrIHBxvu6G7CWqv6gQA6OqPGiaVT/N5AsFAxeJK KAzc5tirDW6zdQEJnwczFCgR5WyRAdOurhMnTQ5e78ALZaUxQwdDna8PzhK98meP0J 906RT01rEtyO5rl7NXzAtjTwQpxKKWgV9bNXlW68= 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 6.14 361/783] cpuidle: menu: Avoid discarding useful information Date: Tue, 27 May 2025 18:22:38 +0200 Message-ID: <20250527162527.784011854@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250527162513.035720581@linuxfoundation.org> References: <20250527162513.035720581@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.14-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 28363bfa3e4c9..42b77d820d0fb 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -192,8 +192,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