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] [day] [month] [year] [list]
Message-ID: <CAJZ5v0iwyvdiuiKhXh79jwQe=1G+=mohrdtnSo2f8+s6-KZWjg@mail.gmail.com>
Date: Fri, 19 Sep 2025 23:23:19 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Yaxiong Tian <tianyaxiong@...inos.cn>
Cc: srinivas.pandruvada@...ux.intel.com, lenb@...nel.org, rafael@...nel.org, 
	viresh.kumar@...aro.org, linux-pm@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] cpufreq: intel_pstate: Use likely() optimization in intel_pstate_sample()

On Fri, Sep 12, 2025 at 9:35 AM Yaxiong Tian <tianyaxiong@...inos.cn> wrote:
>
> The comment above the condition `if (cpu->last_sample_time)` clearly
> indicates that the branch is taken for the vast majority of invocations
> after the first sample in a cycle. The first sample is a one-time
> initialization case.
>
> Add likely() hint to the condition to improve branch prediction for
> this performance-critical path in intel_pstate_sample().
>
> Signed-off-by: Yaxiong Tian <tianyaxiong@...inos.cn>
> ---
>  drivers/cpufreq/intel_pstate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
> index 2519eb527468..d540f2ab9a52 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -2531,7 +2531,7 @@ static inline bool intel_pstate_sample(struct cpudata *cpu, u64 time)
>          * that sample.time will always be reset before setting the utilization
>          * update hook and make the caller skip the sample then.
>          */
> -       if (cpu->last_sample_time) {
> +       if (likely(cpu->last_sample_time)) {
>                 intel_pstate_calc_avg_perf(cpu);
>                 return true;
>         }
> --

Applied as 6.18 material, thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ