From: Catalin Marinas <catalin.marinas@arm.com>
To: Oleg Keri <okerixx@gmail.com>
Cc: Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Prasanna Kumar T S M <ptsm@linux.microsoft.com>,
Beata Michalska <beata.michalska@arm.com>,
Sumit Gupta <sumitg@nvidia.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Peter Zijlstra <peterz@infradead.org>,
Vincent Guittot <vincent.guittot@linaro.org>,
Ananthu C V <ananthu.cv@oss.qualcomm.com>,
linux-pm@vger.kernel.org
Subject: Re: [PATCH v6] arm64: topology: fix arch_freq_get_on_cpu() overflow above 4.19 GHz
Date: Wed, 23 Sep 2026 15:47:34 +0100 [thread overview]
Message-ID: <arPmhnU-pkGpaD4-@arm.com> (raw)
In-Reply-To: <20260923125604.2482-1-okerixx@gmail.com>
On Wed, Sep 23, 2026 at 02:56:04PM +0200, Oleg Keri wrote:
> arch_freq_get_on_cpu() computes the product of the frequency scale and
> the reference frequency as a u64, but assigns it to an unsigned int
> before shifting it back down:
>
> freq = scale * arch_scale_freq_ref(cpu);
> freq >>= SCHED_CAPACITY_SHIFT;
>
> The product is truncated to 32 bits before the shift, so the result
> wraps once arch_scale_freq_ref() exceeds 2^32 / SCHED_CAPACITY_SCALE,
> i.e. 4194304 kHz.
>
> On a Snapdragon X2 Elite (Glymur) laptop, whose boost OPP is 4723200
> kHz, cpuinfo_avg_freq reports 524283 kHz instead of ~4723200 kHz while
> the CPU demonstrably runs at the boost frequency: a fixed workload
> completes in 1.72 s at the 4723200 kHz OPP versus 2.01 s at 4032000
> kHz, matching the 1.171 frequency ratio.
>
> Shift the u64 product and narrow only at the return.
>
> Fixes: 16d1e27475f6 ("arm64: Provide an AMU-based version of arch_freq_get_on_cpu")
> Signed-off-by: Oleg Keri <okerixx@gmail.com>
> ---
> Changes in v6:
> - Drop the cap_scale() change. As a u64 static inline in a shared
> header it would cost future 32-bit callers a 64-bit multiply that the
> macro did not (Will); the truncation is the unsigned int temporary, so
> drop that and leave kernel/sched untouched. Will's Ack on v5 not
> carried since the arm64 hunk changed.
> - v5: https://lore.kernel.org/all/20260917182059.2851-1-okerixx@gmail.com/
I assume Dietmar and Will's acks still stand. I can add them from v5
(let me know if you disagree).
--
Catalin
next prev parent reply other threads:[~2026-09-23 14:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 12:56 [PATCH v6] arm64: topology: fix arch_freq_get_on_cpu() overflow above 4.19 GHz Oleg Keri
2026-09-23 14:47 ` Catalin Marinas [this message]
2026-09-24 8:29 ` Oleg Keri
2026-09-24 10:31 ` Will Deacon
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=arPmhnU-pkGpaD4-@arm.com \
--to=catalin.marinas@arm.com \
--cc=ananthu.cv@oss.qualcomm.com \
--cc=beata.michalska@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=okerixx@gmail.com \
--cc=peterz@infradead.org \
--cc=ptsm@linux.microsoft.com \
--cc=sumitg@nvidia.com \
--cc=vincent.guittot@linaro.org \
--cc=will@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.