From nobody Sat Dec 27 03:20:15 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 0E5A912E5E; Sat, 23 Dec 2023 16:09:59 +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="eBPWeh7M"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="/DnBW8/O" Date: Sat, 23 Dec 2023 16:09:54 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1703347794; 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=daGgmxq1Q7sIM0XiiBa1w/Df41CqQbVCnY7n5nRIWZU=; b=eBPWeh7M44Hmb5kvmlPIizB6ZtmWWnNzfWvOW+BoWzTbfVepRC0K5tmff0Gb9AMnKmqGnh dXz73Y/EVVydxP+cts+SWwmYcO2SDTHt6H+Ey9DTlWyWWKBwceGf9Ginde578KSJTw9kaN iAKFuMg2nzW9+RsgjEdMZ4jHw9dx/zRuOlheHzuvA7lpgj0ThG9QuEBa2O/ktK3g7WRoCW eopAsa/2CAM2TcvD/dt3S9V+mUJASWUMVx6rspejmHLsVGF/SEw3ZTVtKE047PU/cV5Jtf BAJQml/3blnIRX+ggPbibTIjiGS5JxxZQlDPgL4mv00KatPK0Q1qNwObNpNQYA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1703347794; 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=daGgmxq1Q7sIM0XiiBa1w/Df41CqQbVCnY7n5nRIWZU=; b=/DnBW8/OoEeiWKl1004zAdHKWIBIhsjXDYCuEXnmLyRTcfR+SipNa3VM9gjtexiqAs0TDh uWsqbqxPkwNzxeBQ== 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/core] cpufreq/schedutil: Use a fixed reference frequency Cc: Vincent Guittot , Ingo Molnar , Lukasz Luba , Dietmar Eggemann , "Rafael J. Wysocki" , Viresh Kumar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231211104855.558096-4-vincent.guittot@linaro.org> References: <20231211104855.558096-4-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: <170334779405.398.10634104096869499211.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/core branch of tip: Commit-ID: b3edde44e5d4504c23a176819865cd603fd16d6c Gitweb: https://git.kernel.org/tip/b3edde44e5d4504c23a176819865cd603= fd16d6c Author: Vincent Guittot AuthorDate: Mon, 11 Dec 2023 11:48:51 +01:00 Committer: Ingo Molnar CommitterDate: Sat, 23 Dec 2023 15:52:35 +01:00 cpufreq/schedutil: Use a fixed reference frequency cpuinfo.max_freq can change at runtime because of boost as an example. This implies that the value could be different than the one that has been used when computing the capacity of a CPU. The new arch_scale_freq_ref() returns a fixed and coherent reference frequency that can be used when computing a frequency based on utilization. Use this arch_scale_freq_ref() when available and fallback to policy otherwise. Signed-off-by: Vincent Guittot Signed-off-by: Ingo Molnar Tested-by: Lukasz Luba Reviewed-by: Lukasz Luba Reviewed-by: Dietmar Eggemann Acked-by: Rafael J. Wysocki Acked-by: Viresh Kumar Link: https://lore.kernel.org/r/20231211104855.558096-4-vincent.guittot@lin= aro.org --- kernel/sched/cpufreq_schedutil.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedu= til.c index 4ee8ad7..95c3c09 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -115,6 +115,28 @@ static void sugov_deferred_update(struct sugov_policy = *sg_policy) } =20 /** + * get_capacity_ref_freq - get the reference frequency that has been used = to + * correlate frequency and compute capacity for a given cpufreq policy. We= use + * the CPU managing it for the arch_scale_freq_ref() call in the function. + * @policy: the cpufreq policy of the CPU in question. + * + * Return: the reference CPU frequency to compute a capacity. + */ +static __always_inline +unsigned long get_capacity_ref_freq(struct cpufreq_policy *policy) +{ + unsigned int freq =3D arch_scale_freq_ref(policy->cpu); + + if (freq) + return freq; + + if (arch_scale_freq_invariant()) + return policy->cpuinfo.max_freq; + + return policy->cur; +} + +/** * get_next_freq - Compute a new frequency for a given cpufreq policy. * @sg_policy: schedutil policy object to compute the new frequency for. * @util: Current CPU utilization. @@ -140,9 +162,9 @@ static unsigned int get_next_freq(struct sugov_policy *= sg_policy, unsigned long util, unsigned long max) { struct cpufreq_policy *policy =3D sg_policy->policy; - unsigned int freq =3D arch_scale_freq_invariant() ? - policy->cpuinfo.max_freq : policy->cur; + unsigned int freq; =20 + freq =3D get_capacity_ref_freq(policy); freq =3D map_util_freq(util, freq, max); =20 if (freq =3D=3D sg_policy->cached_raw_freq && !sg_policy->need_freq_updat= e)