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 A098C321433; Tue, 26 Aug 2025 13:09:40 +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=1756213780; cv=none; b=EswigQkxHo914B3/ks8wZuCbIlbWorIo/QFjd7K6LlYkCZTz9j5+3spEgiP4573Jm7TtUuwF06/1k89IT9lGksNH6xQ58IuhF7fEhwqOTq9UChuleR268rgTIqjupVRyMmqCz5G2qM35F1JRFVxv1DFp8n5sfOj6ylMxSu8fqlc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756213780; c=relaxed/simple; bh=nAUxEYUxanzilZeodStjU+WPvbXwerUi22eJYSPqGiM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lB8Cbr68DcTe41yIx5a1ij9PInv71aT/2yaqh+vuwRiBuqxzsdz18bBHQGSOX6bdDdi2MEfxWFgOvnTdZnmsFTWCCQ9BTO9aP0xkUjJXknmqADOM2e06jyyhButseshtcQvAzZC2IU20ZUrjMeJ0LFuRuT3jO/NABvb2NUDlHPw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Nox4rPcg; 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="Nox4rPcg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31447C4CEF1; Tue, 26 Aug 2025 13:09:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1756213780; bh=nAUxEYUxanzilZeodStjU+WPvbXwerUi22eJYSPqGiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nox4rPcgOevCW/VA+JIzbCSXjV4mM789MCaMLMT0BJXGk1B8nuXWFauocJvZNDuQM axKhVoEL8JivktuXcCf74dbZ9VTuh3arR+D2Yltmgo+Z5L9mosbYpz3/14/0zuIfJR jh7UyUq7Bi8gFAw9YdoWCEQ5jwjefzFM/tH/qtOs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vincent Guittot , Ingo Molnar , Pierre Gondois , Sudeep Holla , Viresh Kumar , Wentao Guan Subject: [PATCH 6.6 475/587] cpufreq/cppc: Set the frequency used for computing the capacity Date: Tue, 26 Aug 2025 13:10:24 +0200 Message-ID: <20250826111005.051829599@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250826110952.942403671@linuxfoundation.org> References: <20250826110952.942403671@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vincent Guittot commit 5477fa249b56c59c3baa1b237bf083cffa64c84a upstream. Save the frequency associated to the performance that has been used when initializing the capacity of CPUs. Also, cppc cpufreq driver can register an artificial energy model. In such case, it needs the frequency for this compute capacity. Signed-off-by: Vincent Guittot Signed-off-by: Ingo Molnar Tested-by: Pierre Gondois Acked-by: Sudeep Holla Acked-by: Viresh Kumar Link: https://lore.kernel.org/r/20231211104855.558096-7-vincent.guittot@linaro.org Stable-dep-of: e37617c8e53a ("sched/fair: Fix frequency selection for non-invariant case") Signed-off-by: Wentao Guan Signed-off-by: Greg Kroah-Hartman --- drivers/base/arch_topology.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -349,6 +349,7 @@ bool __init topology_parse_cpu_capacity( void topology_init_cpu_capacity_cppc(void) { + u64 capacity, capacity_scale = 0; struct cppc_perf_caps perf_caps; int cpu; @@ -365,6 +366,10 @@ void topology_init_cpu_capacity_cppc(voi (perf_caps.highest_perf >= perf_caps.nominal_perf) && (perf_caps.highest_perf >= perf_caps.lowest_perf)) { raw_capacity[cpu] = perf_caps.highest_perf; + capacity_scale = max_t(u64, capacity_scale, raw_capacity[cpu]); + + per_cpu(capacity_freq_ref, cpu) = cppc_perf_to_khz(&perf_caps, raw_capacity[cpu]); + pr_debug("cpu_capacity: CPU%d cpu_capacity=%u (raw).\n", cpu, raw_capacity[cpu]); continue; @@ -375,7 +380,15 @@ void topology_init_cpu_capacity_cppc(voi goto exit; } - topology_normalize_cpu_scale(); + for_each_possible_cpu(cpu) { + capacity = raw_capacity[cpu]; + capacity = div64_u64(capacity << SCHED_CAPACITY_SHIFT, + capacity_scale); + topology_set_cpu_scale(cpu, capacity); + pr_debug("cpu_capacity: CPU%d cpu_capacity=%lu\n", + cpu, topology_get_cpu_scale(cpu)); + } + schedule_work(&update_topology_flags_work); pr_debug("cpu_capacity: cpu_capacity initialization done\n");