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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <fb86128f-2134-61d2-f34b-1b610e3f406d@huawei.com>
Date:   Mon, 15 May 2023 18:31:12 +0800
From:   "liwei (GF)" <liwei391@...wei.com>
To:     Zeng Heng <zengheng4@...wei.com>
CC:     <weiyongjun1@...wei.com>, <linux-pm@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <xiexiuqi@...wei.com>,
        <linux-acpi@...r.kernel.org>, <wangxiongfeng2@...wei.com>,
        <lenb@...nel.org>, <viresh.kumar@...aro.org>, <rafael@...nel.org>
Subject: Re: [PATCH 1/2] cpufreq: CPPC: keep target core awake when reading
 its cpufreq rate



On 2023/5/15 18:00, Zeng Heng wrote:
> As ARM AMU's document says, all counters are subject to any changes
> in clock frequency, including clock stopping caused by the WFI and WFE
> instructions.
> 
> Therefore, using smp_call_function_single() to trigger target CPU to
> read self's AMU counters, which ensures the counters are working
> properly during calculation.
> 
> Signed-off-by: Zeng Heng <zengheng4@...wei.com>
> ---
>  drivers/cpufreq/cppc_cpufreq.c | 30 ++++++++++++++++--------------
>  1 file changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
> index 022e3555407c..169af7ff9a2a 100644
> --- a/drivers/cpufreq/cppc_cpufreq.c
> +++ b/drivers/cpufreq/cppc_cpufreq.c
> @@ -837,29 +837,31 @@ static int cppc_perf_from_fbctrs(struct cppc_cpudata *cpu_data,
>  	return (reference_perf * delta_delivered) / delta_reference;
>  }
>  
> +static void cppc_get_perf_ctrs_smp(void *val)
> +{
> +	int cpu = smp_processor_id();
> +	struct cppc_perf_fb_ctrs *fb_ctrs = val;
> +
> +	cppc_get_perf_ctrs(cpu, fb_ctrs);
> +
> +	udelay(2); /* 2usec delay between sampling */
> +
> +	cppc_get_perf_ctrs(cpu, fb_ctrs + 1);
> +}
> +
>  static unsigned int cppc_cpufreq_get_rate(unsigned int cpu)
>  {
> -	struct cppc_perf_fb_ctrs fb_ctrs_t0 = {0}, fb_ctrs_t1 = {0};
> +	struct cppc_perf_fb_ctrs fb_ctrs[2] = {0};
>  	struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
>  	struct cppc_cpudata *cpu_data = policy->driver_data;
>  	u64 delivered_perf;
> -	int ret;
>  
>  	cpufreq_cpu_put(policy);
>  
> -	ret = cppc_get_perf_ctrs(cpu, &fb_ctrs_t0);
> -	if (ret)
> -		return ret;
> -
> -	udelay(2); /* 2usec delay between sampling */
> -
> -	ret = cppc_get_perf_ctrs(cpu, &fb_ctrs_t1);
> -	if (ret)
> -		return ret;
> -
> -	delivered_perf = cppc_perf_from_fbctrs(cpu_data, &fb_ctrs_t0,
> -					       &fb_ctrs_t1);
> +	smp_call_function_single(cpu, cppc_get_perf_ctrs_smp, fb_ctrs, 1);

cppc_get_perf_ctrs() may call down_write(), while the callback for smp_call_function_single()
should be non-blocking, you can use smp_call_on_cpu() instead.

>  
> +	delivered_perf = cppc_perf_from_fbctrs(cpu_data, fb_ctrs,
> +					       fb_ctrs + 1);
>  	return cppc_cpufreq_perf_to_khz(cpu_data, delivered_perf);
>  }
>  

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ