[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJZ5v0iTR-0mbODbYPjbNcS-xx7AxF48ZtKrcqv--v_knY9xNg@mail.gmail.com>
Date: Mon, 20 Oct 2025 21:04:20 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: zzhwaxy <zhangzihuan@...inos.cn>
Cc: "Rafael J . Wysocki" <rafael@...nel.org>, Viresh Kumar <viresh.kumar@...aro.org>,
zhenglifeng <zhenglifeng1@...wei.com>, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1] cpufreq: preserve freq_table_sorted across suspend/hibernate
On Sat, Oct 11, 2025 at 9:24 AM zzhwaxy <zhangzihuan@...inos.cn> wrote:
>
> From: Zihuan Zhang <zhangzihuan@...inos.cn>
>
> During S3/S4 suspend and resume, cpufreq policies are not freed or
> recreated; the freq_table and policy structure remain intact. However,
> set_freq_table_sorted() currently resets policy->freq_table_sorted to
> UNSORTED unconditionally, which is unnecessary since the table order
> does not change across suspend/resume.
>
> This patch adds a check to skip validation if policy->freq_table_sorted
> is already ASCENDING or DESCENDING. This avoids unnecessary traversal
> of the frequency table on S3/S4 resume or repeated online events,
> reducing overhead while preserving correctness.
>
> Signed-off-by: Zihuan Zhang <zhangzihuan@...inos.cn>
> ---
> drivers/cpufreq/cpufreq.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 852e024facc3..4a27f6cb07d3 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1421,9 +1421,12 @@ static int cpufreq_policy_online(struct cpufreq_policy *policy,
> * If there is a problem with its frequency table, take it
> * offline and drop it.
> */
> - ret = cpufreq_table_validate_and_sort(policy);
> - if (ret)
> - goto out_offline_policy;
> + if (policy->freq_table_sorted != CPUFREQ_TABLE_SORTED_ASCENDING &&
> + policy->freq_table_sorted != CPUFREQ_TABLE_SORTED_DESCENDING) {
> + ret = cpufreq_table_validate_and_sort(policy);
> + if (ret)
> + goto out_offline_policy;
> + }
>
> /* related_cpus should at least include policy->cpus. */
> cpumask_copy(policy->related_cpus, policy->cpus);
> --
Applied as 6.19 material, thanks!
Powered by blists - more mailing lists