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: <368c8a9f-b137-47a9-9468-ebeb04d4bab5@arm.com>
Date:   Wed, 18 Oct 2023 12:21:52 +0100
From:   Lukasz Luba <lukasz.luba@....com>
To:     Vincent Guittot <vincent.guittot@...aro.org>
Cc:     conor.dooley@...rochip.com, suagrfillet@...il.com,
        linux-pm@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        vschneid@...hat.com, bsegall@...gle.com, dietmar.eggemann@....com,
        juri.lelli@...hat.com, peterz@...radead.org, rafael@...nel.org,
        gregkh@...uxfoundation.org, ajones@...tanamicro.com,
        linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org,
        sudeep.holla@....com, ionela.voinescu@....com,
        viresh.kumar@...aro.org, mgorman@...e.de, palmer@...belt.com,
        will@...nel.org, bristot@...hat.com, lftan@...nel.org,
        rostedt@...dmis.org, linux@...linux.org.uk,
        paul.walmsley@...ive.com, aou@...s.berkeley.edu, mingo@...hat.com,
        catalin.marinas@....com, pierre.gondois@....com
Subject: Re: [PATCH v2 4/6] cpufreq/schedutil: use a fixed reference frequency



On 10/9/23 11:36, Vincent Guittot wrote:
> 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 <vincent.guittot@...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_schedutil.c
> index 4492608b7d7f..1fa7e74add8f 100644
> --- a/kernel/sched/cpufreq_schedutil.c
> +++ b/kernel/sched/cpufreq_schedutil.c
> @@ -114,6 +114,28 @@ static void sugov_deferred_update(struct sugov_policy *sg_policy)
>   	}
>   }
>   
> +/**
> + * cpufreq_get_capacity_ref_freq - get the reference frequency of a given CPU that
> + * has been used to correlate frequency and compute capacity.
> + * @policy: the cpufreq policy of the CPU in question.
> + * @use_current: Fallback to current freq instead of policy->cpuinfo.max_freq.
> + *
> + * 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 = arch_scale_freq_ref(policy->cpu);
> +
> +	if (freq)
> +		return freq;

Looks good, for the platforms having this inline function returning 0,
this will be optimized out.

> +
> +	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.
> @@ -140,10 +162,10 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy,
>   				  unsigned long util, unsigned long max)
>   {
>   	struct cpufreq_policy *policy = sg_policy->policy;
> -	unsigned int freq = arch_scale_freq_invariant() ?
> -				policy->cpuinfo.max_freq : policy->cur;
> +	unsigned int freq;
>   
>   	util = map_util_perf(util);
> +	freq = get_capacity_ref_freq(policy);
>   	freq = map_util_freq(util, freq, max);
>   
>   	if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update)


Reviewed-by: Lukasz Luba <lukasz.luba@....com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ