From: "zhenglifeng (A)" <zhenglifeng1@huawei.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: <catalin.marinas@arm.com>, <will@kernel.org>,
<viresh.kumar@linaro.org>, <beata.michalska@arm.com>,
<sudeep.holla@arm.com>, <linux-arm-kernel@lists.infradead.org>,
<linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linuxarm@huawei.com>, <jonathan.cameron@huawei.com>,
<vincent.guittot@linaro.org>, <yangyicong@hisilicon.com>,
<zhanjie9@hisilicon.com>, <lihuisong@huawei.com>,
<yubowen8@huawei.com>, <linhongye@h-partners.com>
Subject: Re: [PATCH v3 2/3] cpufreq: Add a new function to get cpufreq policy without checking if the CPU is online
Date: Tue, 5 Aug 2025 21:32:45 +0800 [thread overview]
Message-ID: <7586dd30-74b5-4e23-9ee2-bb82d3cb8bd4@huawei.com> (raw)
In-Reply-To: <CAJZ5v0h3XKXAGHSrx50vt1Aho3uchiJ2kjQa7qCM8jCr03YKTA@mail.gmail.com>
On 2025/8/5 20:57, Rafael J. Wysocki wrote:
> On Tue, Aug 5, 2025 at 11:34 AM Lifeng Zheng <zhenglifeng1@huawei.com> wrote:
>>
>> cpufreq_cpu_get_raw() gets cpufreq policy only if the CPU is in
>> policy->cpus mask, which means the CPU is already online. But in some
>> cases, the policy is needed before the CPU is added to cpus mask. Add a
>> function to get the policy in these cases.
>>
>> Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
>> ---
>> drivers/cpufreq/cpufreq.c | 11 +++++++++++
>> include/linux/cpufreq.h | 1 +
>> 2 files changed, 12 insertions(+)
>>
>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>> index fc7eace8b65b..2de76a072893 100644
>> --- a/drivers/cpufreq/cpufreq.c
>> +++ b/drivers/cpufreq/cpufreq.c
>> @@ -198,6 +198,17 @@ struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu)
>> }
>> EXPORT_SYMBOL_GPL(cpufreq_cpu_get_raw);
>>
>> +struct cpufreq_policy *cpufreq_cpu_get_raw_no_check(unsigned int cpu)
>
> This is not a particularly nice name. Maybe call it cpufreq_cpu_policy()?
Thanks for giving a better one.
>
>> +{
>> + struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu);
>> +
>> + if (policy)
>> + return policy;
>> +
>> + return NULL;
>
> This could just be a one-liner with this statement in the function body:
>
> return per_cpu(cpufreq_cpu_data, cpu);
>
> Can't it?
>
> In which case it can be called in all places reading cpufreq_cpu_data
> for a given CPU.
Yes, it can be done in one line. Thanks.
>
>> +}
>> +EXPORT_SYMBOL_GPL(cpufreq_cpu_get_raw_no_check);
>> +
>> unsigned int cpufreq_generic_get(unsigned int cpu)
>> {
>> struct cpufreq_policy *policy = cpufreq_cpu_get_raw(cpu);
>> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
>> index 95f3807c8c55..02ad8173dc10 100644
>> --- a/include/linux/cpufreq.h
>> +++ b/include/linux/cpufreq.h
>> @@ -205,6 +205,7 @@ struct cpufreq_freqs {
>>
>> #ifdef CONFIG_CPU_FREQ
>> struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu);
>> +struct cpufreq_policy *cpufreq_cpu_get_raw_no_check(unsigned int cpu);
>> struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu);
>> void cpufreq_cpu_put(struct cpufreq_policy *policy);
>> #else
>> --
>
next prev parent reply other threads:[~2025-08-05 13:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-05 9:33 [PATCH v3 0/3] arm64: topology: Setup AMU FIE for online CPUs only Lifeng Zheng
2025-08-05 9:33 ` [PATCH v3 1/3] arm64: topology: Set scale freq source only for the CPUs that have not been set before Lifeng Zheng
2025-08-05 9:33 ` [PATCH v3 2/3] cpufreq: Add a new function to get cpufreq policy without checking if the CPU is online Lifeng Zheng
2025-08-05 12:57 ` Rafael J. Wysocki
2025-08-05 13:32 ` zhenglifeng (A) [this message]
2025-08-05 9:33 ` [PATCH v3 3/3] arm64: topology: Setup AMU FIE for online CPUs only Lifeng Zheng
2025-08-06 9:55 ` Beata Michalska
2025-08-13 10:17 ` zhenglifeng (A)
2025-08-13 11:08 ` Beata Michalska
2025-08-06 13:45 ` kernel test robot
2025-08-06 13:45 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7586dd30-74b5-4e23-9ee2-bb82d3cb8bd4@huawei.com \
--to=zhenglifeng1@huawei.com \
--cc=beata.michalska@arm.com \
--cc=catalin.marinas@arm.com \
--cc=jonathan.cameron@huawei.com \
--cc=lihuisong@huawei.com \
--cc=linhongye@h-partners.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=rafael@kernel.org \
--cc=sudeep.holla@arm.com \
--cc=vincent.guittot@linaro.org \
--cc=viresh.kumar@linaro.org \
--cc=will@kernel.org \
--cc=yangyicong@hisilicon.com \
--cc=yubowen8@huawei.com \
--cc=zhanjie9@hisilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®