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: <CAJZ5v0gSVd05e+Wtx9WuxW1ETAt=_z9pAyyg7oQzKD4LhrA89Q@mail.gmail.com>
Date: Mon, 7 Apr 2025 20:46:37 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: "Rafael J. Wysocki" <rjw@...ysocki.net>, 
	Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>
Cc: Linux PM <linux-pm@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org>, 
	Viresh Kumar <viresh.kumar@...aro.org>, Mario Limonciello <mario.limonciello@....com>, 
	Sudeep Holla <sudeep.holla@....com>
Subject: Re: [PATCH v1 05/10] cpufreq: intel_pstate: Rearrange max frequency
 updates handling code

On Fri, Mar 28, 2025 at 9:58 PM Rafael J. Wysocki <rjw@...ysocki.net> wrote:
>
> From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
>
> Rename __intel_pstate_update_max_freq() to intel_pstate_update_max_freq()
> and move the cpufreq policy reference counting and locking into it (and
> implement the locking with the recently introduced cpufreq policy "write"
> locking guard).
>
> No intentional functional impact.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>

Hi Srinivas,

If you have any concerns regarding this patch, please let me know.

> ---
>  drivers/cpufreq/intel_pstate.c |   52 +++++++++++++----------------------------
>  1 file changed, 17 insertions(+), 35 deletions(-)
>
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -1353,9 +1353,16 @@
>                 cpufreq_update_policy(cpu);
>  }
>
> -static void __intel_pstate_update_max_freq(struct cpudata *cpudata,
> -                                          struct cpufreq_policy *policy)
> +static bool intel_pstate_update_max_freq(struct cpudata *cpudata)
>  {
> +       struct cpufreq_policy *policy __free(put_cpufreq_policy);
> +
> +       policy = cpufreq_cpu_get(cpudata->cpu);
> +       if (!policy)
> +               return false;
> +
> +       guard(cpufreq_policy_write)(policy);
> +
>         if (hwp_active)
>                 intel_pstate_get_hwp_cap(cpudata);
>
> @@ -1363,44 +1370,24 @@
>                         cpudata->pstate.max_freq : cpudata->pstate.turbo_freq;
>
>         refresh_frequency_limits(policy);
> +
> +       return true;
>  }
>
>  static void intel_pstate_update_limits(unsigned int cpu)
>  {
> -       struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpu);
> -       struct cpudata *cpudata;
> -
> -       if (!policy)
> -               return;
> -
> -       cpudata = all_cpu_data[cpu];
> -
> -       __intel_pstate_update_max_freq(cpudata, policy);
> -
> -       /* Prevent the driver from being unregistered now. */
> -       mutex_lock(&intel_pstate_driver_lock);
> +       struct cpudata *cpudata = all_cpu_data[cpu];
>
> -       cpufreq_cpu_release(policy);
> -
> -       hybrid_update_capacity(cpudata);
> -
> -       mutex_unlock(&intel_pstate_driver_lock);
> +       if (intel_pstate_update_max_freq(cpudata))
> +               hybrid_update_capacity(cpudata);
>  }
>
>  static void intel_pstate_update_limits_for_all(void)
>  {
>         int cpu;
>
> -       for_each_possible_cpu(cpu) {
> -               struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpu);
> -
> -               if (!policy)
> -                       continue;
> -
> -               __intel_pstate_update_max_freq(all_cpu_data[cpu], policy);
> -
> -               cpufreq_cpu_release(policy);
> -       }
> +       for_each_possible_cpu(cpu)
> +               intel_pstate_update_max_freq(all_cpu_data[cpu]);
>
>         mutex_lock(&hybrid_capacity_lock);
>
> @@ -1840,13 +1827,8 @@
>  {
>         struct cpudata *cpudata =
>                 container_of(to_delayed_work(work), struct cpudata, hwp_notify_work);
> -       struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpudata->cpu);
> -
> -       if (policy) {
> -               __intel_pstate_update_max_freq(cpudata, policy);
> -
> -               cpufreq_cpu_release(policy);
>
> +       if (intel_pstate_update_max_freq(cpudata)) {
>                 /*
>                  * The driver will not be unregistered while this function is
>                  * running, so update the capacity without acquiring the driver
>
>
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ