From: Beata Michalska <beata.michalska@arm.com>
To: Ionela Voinescu <ionela.voinescu@arm.com>
Cc: Lifeng Zheng <zhenglifeng1@huawei.com>,
catalin.marinas@arm.com, will@kernel.org, rafael@kernel.org,
viresh.kumar@linaro.org, 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,
zhangpengjie2@huawei.com, linhongye@h-partners.com
Subject: Re: [PATCH v5 3/3] arm64: topology: Setup AMU FIE for online CPUs only
Date: Fri, 5 Sep 2025 09:31:03 +0200 [thread overview]
Message-ID: <aLqRt0K2-UH8cOcI@arm.com> (raw)
In-Reply-To: <aLVJdy3M1NRBR5LF@arm.com>
Hi Ionela,
On Mon, Sep 01, 2025 at 08:29:26AM +0100, Ionela Voinescu wrote:
> Hi,
>
> On Tuesday 19 Aug 2025 at 15:29:31 (+0800), Lifeng Zheng wrote:
> > When boot with maxcpu=1 restrict, and LPI(Low Power Idle States) is on,
> > only CPU0 will go online. The support AMU flag of CPU0 will be set but the
> > flags of other CPUs will not. This will cause AMU FIE set up fail for CPU0
> > when it shares a cpufreq policy with other CPU(s). After that, when other
> > CPUs are finally online and the support AMU flags of them are set, they'll
> > never have a chance to set up AMU FIE, even though they're eligible.
> >
> > To solve this problem, the process of setting up AMU FIE needs to be
> > modified as follows:
> >
> > 1. Set up AMU FIE only for the online CPUs.
> >
> > 2. Try to set up AMU FIE each time a CPU goes online and do the
> > freq_counters_valid() check. If this check fails, clear scale freq source
> > of all the CPUs related to the same policy, in case they use different
> > source of the freq scale.
> >
> > At the same time, this change also be applied to cpufreq when calling
> > arch_set_freq_scale.
> >
> > Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
> > ---
> > arch/arm64/kernel/topology.c | 54 ++++++++++++++++++++++++++++++++++--
> > drivers/cpufreq/cpufreq.c | 4 +--
> > 2 files changed, 54 insertions(+), 4 deletions(-)
> >
> [..]
> >
> > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > index 78ca68ea754d..d1890a2af1af 100644
> > --- a/drivers/cpufreq/cpufreq.c
> > +++ b/drivers/cpufreq/cpufreq.c
> > @@ -417,7 +417,7 @@ void cpufreq_freq_transition_end(struct cpufreq_policy *policy,
> >
> > cpufreq_notify_post_transition(policy, freqs, transition_failed);
> >
> > - arch_set_freq_scale(policy->related_cpus,
> > + arch_set_freq_scale(policy->cpus,
> > policy->cur,
> > arch_scale_freq_ref(policy->cpu));
> >
> > @@ -2219,7 +2219,7 @@ unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy,
> > return 0;
> >
> > policy->cur = freq;
> > - arch_set_freq_scale(policy->related_cpus, freq,
> > + arch_set_freq_scale(policy->cpus, freq,
> > arch_scale_freq_ref(policy->cpu));
>
> I think it might be good to keep these calls to arch_set_freq_scale() for
> all related CPUs and not only online ones. This can result in CPUs coming
> out of hotplug with a wrong scale factor, because while they were out, any
> frequency transitions of the policy only modified the scale factor of
> online CPUs. When they come out of hotplug, arch_set_freq_scale() will not
> be called for them until there's a new frequency transition.
>
> I understand that if this is not changed to only pass online CPUs,
> supports_scale_freq_counters() will now fail when called in
> topology_set_freq_scale() for scenarios when only some CPUs in a policy
> are online - e.g. the scenario in your commit message. But I think a
> simple change in supports_scale_freq_counters() that instead checks that
> at least one CPU in the policy supports AMU-based FIE, instead of all,
> is a better fix that does not break the cpufreq-based FIE. If at least
> one CPU is marked as supporting AMUs for FIE we know that the AMU setup
> path is in progress and we should bail out of
> topology_set_freq_scale()/arch_set_freq_scale().
>
Thank you for pointing that out - that indeed might be an issue, and the
solution you have suggested should do the trick.
---
BR
Beata
> Hope it helps,
> Ionela.
>
> > cpufreq_stats_record_transition(policy, freq);
> >
> > --
> > 2.33.0
> >
> >
prev parent reply other threads:[~2025-09-05 7:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-19 7:29 [PATCH v5 0/3] arm64: topology: Setup AMU FIE for online CPUs only Lifeng Zheng
2025-08-19 7:29 ` [PATCH v5 1/3] arm64: topology: Set scale freq source only for the CPUs that have not been set before Lifeng Zheng
2025-08-20 9:22 ` Beata Michalska
2025-08-30 4:08 ` Jie Zhan
2025-08-19 7:29 ` [PATCH v5 2/3] cpufreq: Add a new function to get cpufreq policy without checking if the CPU is online Lifeng Zheng
2025-08-19 19:05 ` Rafael J. Wysocki
2025-08-20 1:50 ` zhenglifeng (A)
2025-08-30 4:11 ` Jie Zhan
2025-08-19 7:29 ` [PATCH v5 3/3] arm64: topology: Setup AMU FIE for online CPUs only Lifeng Zheng
2025-08-20 9:21 ` Beata Michalska
2025-08-30 10:20 ` Jie Zhan
2025-09-01 7:29 ` Ionela Voinescu
2025-09-05 7:31 ` Beata Michalska [this message]
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=aLqRt0K2-UH8cOcI@arm.com \
--to=beata.michalska@arm.com \
--cc=catalin.marinas@arm.com \
--cc=ionela.voinescu@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=zhangpengjie2@huawei.com \
--cc=zhanjie9@hisilicon.com \
--cc=zhenglifeng1@huawei.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