lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKfTPtBpb-A011icfitvvAY8Z7pSt-cTmQ-TMsWG_3_sREuEmg@mail.gmail.com>
Date: Mon, 8 Apr 2024 10:35:53 +0200
From: Vincent Guittot <vincent.guittot@...aro.org>
To: Beata Michalska <beata.michalska@....com>
Cc: linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org, 
	ionela.voinescu@....com, vanshikonda@...amperecomputing.com, 
	sudeep.holla@....com, will@...nel.org, catalin.marinas@....com, 
	sumitg@...dia.com, yang@...amperecomputing.com, lihuisong@...wei.com
Subject: Re: [PATCH v4 1/4] arch_topology: init capacity_freq_ref to 0

On Fri, 5 Apr 2024 at 15:33, Beata Michalska <beata.michalska@....com> wrote:
>
> From: Ionela Voinescu <ionela.voinescu@....com>
>
> 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@....com>
> Signed-off-by: Beata Michalska <beata.michalska@....com>

Reviewed-by: Vincent Guittot <vincent.guittot@...aro.org>


> ---
>  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 024b78a0cfc1..7d4c92cd2bad 100644
> --- a/drivers/base/arch_topology.c
> +++ b/drivers/base/arch_topology.c
> @@ -27,7 +27,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)
> @@ -292,13 +292,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
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ