* [PATCH] arch_topology: init capacity_freq_ref to 0
@ 2024-08-27 15:48 Ionela Voinescu
2025-02-17 15:01 ` Ionela Voinescu
2025-02-17 21:32 ` Catalin Marinas
0 siblings, 2 replies; 4+ messages in thread
From: Ionela Voinescu @ 2024-08-27 15:48 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, sudeep.holla, catalin.marinas,
vincent.guittot, beata.michalska
Cc: rafael, viresh.kumar, dietmar.eggemann, pierre.gondois
It's useful to have capacity_freq_ref initialized to 0 for users of
arch_scale_freq_ref() to detect when capacity_freq_ref was not
yet set.
The only scenario affected by this change in the init value is when a
cpufreq driver is never loaded. As a result, the only setter of a
cpu scale factor remains the call of topology_normalize_cpu_scale()
from parse_dt_topology(). There we cannot use the value 0 of
capacity_freq_ref so we have to compensate for its uninitialized state.
Signed-off-by: Ionela Voinescu <ionela.voinescu@arm.com>
Signed-off-by: Beata Michalska <beata.michalska@arm.com>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
---
Hi,
This patch was previously part of the patch-set at [1], but we thought
it's best to separate the standalone patches in that set to make
further review easier on the remaining topics.
Based on v6.11-rc5 and tested on Juno with and without a cpufreq driver.
[1] https://lore.kernel.org/lkml/20240603082154.3830591-2-beata.michalska@arm.com/
Thanks,
Ionela.
drivers/base/arch_topology.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 75fcb75d5515..c49ef1a712f4 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -28,7 +28,7 @@
static DEFINE_PER_CPU(struct scale_freq_data __rcu *, sft_data);
static struct cpumask scale_freq_counters_mask;
static bool scale_freq_invariant;
-DEFINE_PER_CPU(unsigned long, capacity_freq_ref) = 1;
+DEFINE_PER_CPU(unsigned long, capacity_freq_ref) = 0;
EXPORT_PER_CPU_SYMBOL_GPL(capacity_freq_ref);
static bool supports_scale_freq_counters(const struct cpumask *cpus)
@@ -293,13 +293,15 @@ void topology_normalize_cpu_scale(void)
capacity_scale = 1;
for_each_possible_cpu(cpu) {
- capacity = raw_capacity[cpu] * per_cpu(capacity_freq_ref, cpu);
+ capacity = raw_capacity[cpu] *
+ (per_cpu(capacity_freq_ref, cpu) ?: 1);
capacity_scale = max(capacity, capacity_scale);
}
pr_debug("cpu_capacity: capacity_scale=%llu\n", capacity_scale);
for_each_possible_cpu(cpu) {
- capacity = raw_capacity[cpu] * per_cpu(capacity_freq_ref, cpu);
+ capacity = raw_capacity[cpu] *
+ (per_cpu(capacity_freq_ref, cpu) ?: 1);
capacity = div64_u64(capacity << SCHED_CAPACITY_SHIFT,
capacity_scale);
topology_set_cpu_scale(cpu, capacity);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] arch_topology: init capacity_freq_ref to 0
2024-08-27 15:48 [PATCH] arch_topology: init capacity_freq_ref to 0 Ionela Voinescu
@ 2025-02-17 15:01 ` Ionela Voinescu
2025-02-17 16:01 ` Sudeep Holla
2025-02-17 21:32 ` Catalin Marinas
1 sibling, 1 reply; 4+ messages in thread
From: Ionela Voinescu @ 2025-02-17 15:01 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, sudeep.holla, catalin.marinas,
vincent.guittot, beata.michalska
Cc: rafael, viresh.kumar, dietmar.eggemann, pierre.gondois
Hi folks,
I just wanted to mention that this patch still applies cleanly on
next-20250217 as well, and it still builds/boots/works as expected.
I've rechecked it given that the patches at [1] seem ready to be picked
up, and those patches depend on this one.
Thanks,
Ionela.
[1] https://lore.kernel.org/lkml/20250131162439.3843071-1-beata.michalska@arm.com/
On Tuesday 27 Aug 2024 at 16:48:18 (+0100), Ionela Voinescu wrote:
> It's useful to have capacity_freq_ref initialized to 0 for users of
> arch_scale_freq_ref() to detect when capacity_freq_ref was not
> yet set.
>
> The only scenario affected by this change in the init value is when a
> cpufreq driver is never loaded. As a result, the only setter of a
> cpu scale factor remains the call of topology_normalize_cpu_scale()
> from parse_dt_topology(). There we cannot use the value 0 of
> capacity_freq_ref so we have to compensate for its uninitialized state.
>
> Signed-off-by: Ionela Voinescu <ionela.voinescu@arm.com>
> Signed-off-by: Beata Michalska <beata.michalska@arm.com>
> Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
>
> Hi,
>
> This patch was previously part of the patch-set at [1], but we thought
> it's best to separate the standalone patches in that set to make
> further review easier on the remaining topics.
>
> Based on v6.11-rc5 and tested on Juno with and without a cpufreq driver.
>
> [1] https://lore.kernel.org/lkml/20240603082154.3830591-2-beata.michalska@arm.com/
>
> Thanks,
> Ionela.
>
> drivers/base/arch_topology.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
> index 75fcb75d5515..c49ef1a712f4 100644
> --- a/drivers/base/arch_topology.c
> +++ b/drivers/base/arch_topology.c
> @@ -28,7 +28,7 @@
> static DEFINE_PER_CPU(struct scale_freq_data __rcu *, sft_data);
> static struct cpumask scale_freq_counters_mask;
> static bool scale_freq_invariant;
> -DEFINE_PER_CPU(unsigned long, capacity_freq_ref) = 1;
> +DEFINE_PER_CPU(unsigned long, capacity_freq_ref) = 0;
> EXPORT_PER_CPU_SYMBOL_GPL(capacity_freq_ref);
>
> static bool supports_scale_freq_counters(const struct cpumask *cpus)
> @@ -293,13 +293,15 @@ void topology_normalize_cpu_scale(void)
>
> capacity_scale = 1;
> for_each_possible_cpu(cpu) {
> - capacity = raw_capacity[cpu] * per_cpu(capacity_freq_ref, cpu);
> + capacity = raw_capacity[cpu] *
> + (per_cpu(capacity_freq_ref, cpu) ?: 1);
> capacity_scale = max(capacity, capacity_scale);
> }
>
> pr_debug("cpu_capacity: capacity_scale=%llu\n", capacity_scale);
> for_each_possible_cpu(cpu) {
> - capacity = raw_capacity[cpu] * per_cpu(capacity_freq_ref, cpu);
> + capacity = raw_capacity[cpu] *
> + (per_cpu(capacity_freq_ref, cpu) ?: 1);
> capacity = div64_u64(capacity << SCHED_CAPACITY_SHIFT,
> capacity_scale);
> topology_set_cpu_scale(cpu, capacity);
> --
> 2.25.1
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] arch_topology: init capacity_freq_ref to 0
2025-02-17 15:01 ` Ionela Voinescu
@ 2025-02-17 16:01 ` Sudeep Holla
0 siblings, 0 replies; 4+ messages in thread
From: Sudeep Holla @ 2025-02-17 16:01 UTC (permalink / raw)
To: Ionela Voinescu
Cc: linux-kernel, linux-arm-kernel, catalin.marinas, vincent.guittot,
beata.michalska, rafael, viresh.kumar, dietmar.eggemann,
pierre.gondois
On Mon, Feb 17, 2025 at 03:01:23PM +0000, Ionela Voinescu wrote:
> Hi folks,
>
> I just wanted to mention that this patch still applies cleanly on
> next-20250217 as well, and it still builds/boots/works as expected.
>
> I've rechecked it given that the patches at [1] seem ready to be picked
> up, and those patches depend on this one.
>
Is there a dependency on [1] ?
Either way, if Catalin is happy to pick it up along with [1], that would
be best and easiest.
If not and there are not dependencies, then we can ask Greg to pick up.
Which means you need to repost with him cc-ed ? Lets wait and see if
Catalin is happy to pick up before reposting though.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arch_topology: init capacity_freq_ref to 0
2024-08-27 15:48 [PATCH] arch_topology: init capacity_freq_ref to 0 Ionela Voinescu
2025-02-17 15:01 ` Ionela Voinescu
@ 2025-02-17 21:32 ` Catalin Marinas
1 sibling, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2025-02-17 21:32 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, sudeep.holla, vincent.guittot,
beata.michalska, Ionela Voinescu
Cc: Will Deacon, rafael, viresh.kumar, dietmar.eggemann,
pierre.gondois
On Tue, 27 Aug 2024 16:48:18 +0100, Ionela Voinescu wrote:
> It's useful to have capacity_freq_ref initialized to 0 for users of
> arch_scale_freq_ref() to detect when capacity_freq_ref was not
> yet set.
>
> The only scenario affected by this change in the init value is when a
> cpufreq driver is never loaded. As a result, the only setter of a
> cpu scale factor remains the call of topology_normalize_cpu_scale()
> from parse_dt_topology(). There we cannot use the value 0 of
> capacity_freq_ref so we have to compensate for its uninitialized state.
>
> [...]
Applied to arm64 (for-next/amuv1-avg-freq), thanks!
[1/1] arch_topology: init capacity_freq_ref to 0
https://git.kernel.org/arm64/c/004b500a9031
--
Catalin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-02-17 21:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-27 15:48 [PATCH] arch_topology: init capacity_freq_ref to 0 Ionela Voinescu
2025-02-17 15:01 ` Ionela Voinescu
2025-02-17 16:01 ` Sudeep Holla
2025-02-17 21:32 ` Catalin Marinas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).