From nobody Tue Dec 16 20:15:33 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 A26E6134A3; Tue, 16 Jan 2024 10:08:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Iin3idrR"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="IP5KSt3E" Date: Tue, 16 Jan 2024 10:08:20 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1705399701; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/Awifqxg6eOBMIPHwm/f2jqMJMZMe9tEsWAtoE0BA5w=; b=Iin3idrR5MZ/nYHs+cYEsV+nEIlY6DHvv2qPF2ngONsM98z0snV5Y2/CfdNjbcpNLu480W qdntxcOkNVC5Yhx6bGrnqpSRO2E6arjUNGDhL2AfTnu30764nYzgnBEpWRLuQDNc/xWGzT mBMjciieIvAaxgrTgxajtDziN69N7D2DiOKWF3WqdN0ComW2ucwVuhgVvSEYFLnmfYC4+O q8NY/vbl3qBPeGZfBi9QZKqKSsc1weB0RrnQIfIvxy77GozjPoC9cNbUjYkJ/Pscd4k4JV jv/5AryD7oG8OCJqCLA7zHi3scL5x9ad0FbLldIX63omB9BJ8pP0qhmvXkqHWA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1705399701; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/Awifqxg6eOBMIPHwm/f2jqMJMZMe9tEsWAtoE0BA5w=; b=IP5KSt3ELERRE2YEvC1Ydl8wwWpVpWNiLC0dT6a1jo7G/ywSa/YSKcO5bWzk1jSmF4zA4o 4VzZtEmakW8noeDA== From: "tip-bot2 for Vincent Guittot" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] sched/fair: Fix frequency selection for non-invariant case Cc: Linus Torvalds , Wyes Karny , Vincent Guittot , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240114183600.135316-1-vincent.guittot@linaro.org> References: <20240114183600.135316-1-vincent.guittot@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170539970061.398.16662091173685476681.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the sched/urgent branch of tip: Commit-ID: e37617c8e53a1f7fcba6d5e1041f4fd8a2425c27 Gitweb: https://git.kernel.org/tip/e37617c8e53a1f7fcba6d5e1041f4fd8a= 2425c27 Author: Vincent Guittot AuthorDate: Sun, 14 Jan 2024 19:36:00 +01:00 Committer: Ingo Molnar CommitterDate: Tue, 16 Jan 2024 10:41:25 +01:00 sched/fair: Fix frequency selection for non-invariant case Linus reported a ~50% performance regression on single-threaded workloads on his AMD Ryzen system, and bisected it to: 9c0b4bb7f630 ("sched/cpufreq: Rework schedutil governor performance estim= ation") When frequency invariance is not enabled, get_capacity_ref_freq(policy) is supposed to return the current frequency and the performance margin applied by map_util_perf(), enabling the utilization to go above the maximum compute capacity and to select a higher frequency than the current = one. After the changes in 9c0b4bb7f630, the performance margin was applied earlier in the path to take into account utilization clampings and we couldn't get a utilization higher than the maximum compute capacity, and the CPU remained 'stuck' at lower frequencies. To fix this, we must use a frequency above the current frequency to get a chance to select a higher OPP when the current one becomes fully used. Apply the same margin and return a frequency 25% higher than the current one in order to switch to the next OPP before we fully use the CPU at the current one. [ mingo: Clarified the changelog. ] Fixes: 9c0b4bb7f630 ("sched/cpufreq: Rework schedutil governor performance = estimation") Reported-by: Linus Torvalds Bisected-by: Linus Torvalds Reported-by: Wyes Karny Signed-off-by: Vincent Guittot Signed-off-by: Ingo Molnar Tested-by: Wyes Karny Link: https://lore.kernel.org/r/20240114183600.135316-1-vincent.guittot@lin= aro.org --- kernel/sched/cpufreq_schedutil.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedu= til.c index 95c3c09..eece624 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -133,7 +133,11 @@ unsigned long get_capacity_ref_freq(struct cpufreq_pol= icy *policy) if (arch_scale_freq_invariant()) return policy->cpuinfo.max_freq; =20 - return policy->cur; + /* + * Apply a 25% margin so that we select a higher frequency than + * the current one before the CPU is fully busy: + */ + return policy->cur + (policy->cur >> 2); } =20 /**