From: Sumit Gupta <sumitg@nvidia.com>
To: Will Deacon <will@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>,
catalin.marinas@arm.com, zhanjie9@hisilicon.com,
zhenglifeng1@huawei.com, viresh.kumar@linaro.org,
rafael@kernel.org, beata.michalska@arm.com,
pierre.gondois@arm.com, ionela.voinescu@arm.com,
linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org,
treding@nvidia.com, jonathanh@nvidia.com, bbasu@nvidia.com,
sumitg@nvidia.com
Subject: Re: [PATCH v2] arm64: topology: Fix false warning in counters_read_on_cpu() for same-CPU reads
Date: Thu, 26 Feb 2026 16:47:33 +0530 [thread overview]
Message-ID: <f52750d7-cb23-4a10-bc87-67232524dd28@nvidia.com> (raw)
In-Reply-To: <aZ90u4HrDh1N7ylK@willie-the-truck>
Hi Will,
On 26/02/26 03:46, Will Deacon wrote:
> External email: Use caution opening links or attachments
>
>
> On Wed, Feb 25, 2026 at 05:08:03PM +0530, Sumit Gupta wrote:
>> On 24/02/26 23:25, Marc Zyngier wrote:
>>> But I'm more concerned by the overall pattern of doing these things in
>>> random contexts. Going back to the original patch (997c021abc6e) that
>>> states:
>>>
>>> "However, this deferred update mechanism is unnecessary and introduces extra
>>> overhead for non-PCC register spaces (e.g. System Memory or FFH), where
>>> accessing the regs won't sleep and can be safely performed from the tick
>>> context."
>>>
>>> Clearly, the AMU registers cannot be arbitrarily accessed without
>>> blocking when accessed from one CPU to another, so either this
>>> function is never called in a cross-cpu context (and the warning
>>> should be removed), or the premises of this change are wrong.
>>>
>>> Which one is it?
>> The function is also called in cross-CPU contexts, but only from
>> process context (get_rate, sysfs show) with IRQs enabled and
>> calling smp_call_function_single() is safe. In the tick path,
>> cppc_scale_freq_tick() uses per_cpu(cppc_freq_inv, smp_processor_id()).
>> So we always read the current CPU's counters and no cross-CPU access.
>>
>> The premise of 997c021abc6e applies to same-CPU accesses only:
>> Reading the local CPU's AMU regs does not sleep and is safe from
>> tick context.
>> The irqs_disabled() WARN is still needed to guard against unsafe
>> cross-CPU calls. This also returns '-EPERM' unlike the WARN inside
>> smp_call_function_single(). So we fail instead of risking deadlock.
> Hmm, so why isn't this structured such as:
>
> if (irqs_disabled()) {
> /* XXX: Explain the tick case */
> if (WARN_ON_ONCE(cpu != smp_processor_id()))
> return -EPERM;
> func(val);
> } else {
> smp_call_function_single(cpu, func, val, 1);
> }
>
> return 0;
>
> That way, the irqs-enabled case remains the same and doesn't need to
> mess with preemption.
>
> Will
I will do the change in v3 as suggested.
Thankyou
Sumit Gupta
prev parent reply other threads:[~2026-02-26 11:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 9:27 Sumit Gupta
2026-02-24 17:55 ` Marc Zyngier
2026-02-25 11:38 ` Sumit Gupta
2026-02-25 22:16 ` Will Deacon
2026-02-26 11:17 ` Sumit Gupta [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=f52750d7-cb23-4a10-bc87-67232524dd28@nvidia.com \
--to=sumitg@nvidia.com \
--cc=bbasu@nvidia.com \
--cc=beata.michalska@arm.com \
--cc=catalin.marinas@arm.com \
--cc=ionela.voinescu@arm.com \
--cc=jonathanh@nvidia.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=maz@kernel.org \
--cc=pierre.gondois@arm.com \
--cc=rafael@kernel.org \
--cc=treding@nvidia.com \
--cc=viresh.kumar@linaro.org \
--cc=will@kernel.org \
--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
all inboxes | Powered by JetHome®