From: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Oleg Keri <okerixx@gmail.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Sumit Gupta <sumitg@nvidia.com>,
Prasanna Kumar T S M <ptsm@linux.microsoft.com>,
Beata Michalska <beata.michalska@arm.com>,
Russell King <linux@armlinux.org.uk>,
Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>,
Sudeep Holla <sudeep.holla@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
driver-core@lists.linux.dev, linux-pm@vger.kernel.org,
jonathan.cameron@oss.qualcomm.com, sibi.sankar@oss.qualcomm.com
Subject: Re: [PATCH v3 1/2] arm64: topology: fix arch_freq_get_on_cpu() overflow above 4.19 GHz
Date: Wed, 16 Sep 2026 12:52:33 +0200 [thread overview]
Message-ID: <55538466-2203-42ec-a0bd-b743c04a3b38@arm.com> (raw)
In-Reply-To: <20260910063440.4677-2-okerixx@gmail.com>
On 10.09.26 08:34, Oleg Keri wrote:
[...]
> diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
> index d28438f8b83f..0eca321ff113 100644
> --- a/arch/arm64/kernel/topology.c
> +++ b/arch/arm64/kernel/topology.c
> @@ -245,8 +245,7 @@ int arch_freq_get_on_cpu(int cpu)
> * (see amu_scale_freq_tick for details)
> */
> scale = arch_scale_freq_capacity(cpu);
> - freq = scale * arch_scale_freq_ref(cpu);
> - freq >>= SCHED_CAPACITY_SHIFT;
> + freq = (scale * arch_scale_freq_ref(cpu)) >> SCHED_CAPACITY_SHIFT;
> return freq;
> }
In task scheduler code we use cap_scale(v, s) for CPU capacity related
scaling.
We could move its definition from private task scheduler include file
kernel/sched/sched.h to include/linux/topology.h to be able to use it
also outside the task scheduler?
Only compile tested on arm64 and x86.
-->8--
diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
index 0eca321ff113..180a7aa97752 100644
--- a/arch/arm64/kernel/topology.c
+++ b/arch/arm64/kernel/topology.c
@@ -186,7 +186,6 @@ int arch_freq_get_on_cpu(int cpu)
struct amu_cntr_sample *amu_sample;
unsigned int start_cpu = cpu;
unsigned long last_update;
- unsigned int freq = 0;
u64 scale;
if (!amu_fie_cpu_supported(cpu) || !arch_scale_freq_ref(cpu))
@@ -245,8 +244,7 @@ int arch_freq_get_on_cpu(int cpu)
* (see amu_scale_freq_tick for details)
*/
scale = arch_scale_freq_capacity(cpu);
- freq = (scale * arch_scale_freq_ref(cpu)) >> SCHED_CAPACITY_SHIFT;
- return freq;
+ return cap_scale(arch_scale_freq_ref(cpu), scale);
}
static void amu_fie_setup(const struct cpumask *cpus)
diff --git a/include/linux/topology.h b/include/linux/topology.h
index 709a2dcf4c73..0a4ee12a98d5 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -351,4 +351,6 @@ static inline unsigned long
topology_get_cpu_scale(int cpu)
void topology_set_cpu_scale(unsigned int cpu, unsigned long capacity);
+#define cap_scale(v, s) ((v)*(s) >> SCHED_CAPACITY_SHIFT)
+
#endif /* _LINUX_TOPOLOGY_H */
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 6c3ad70e58b8..45796fccdc84 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -236,8 +236,6 @@ static inline int task_has_dl_policy(struct
task_struct *p)
return dl_policy(p->policy);
}
-#define cap_scale(v, s) ((v)*(s) >> SCHED_CAPACITY_SHIFT)
-
static inline void update_avg(u64 *avg, u64 sample)
{
s64 diff = sample - *avg;
next prev parent reply other threads:[~2026-09-16 10:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 6:34 [PATCH v3 0/2] arm64/cpufreq: report and track frequencies above 4.19 GHz Oleg Keri
2026-09-10 6:34 ` [PATCH v3 1/2] arm64: topology: fix arch_freq_get_on_cpu() overflow " Oleg Keri
2026-09-14 7:04 ` Beata Michalska
2026-09-16 10:52 ` Dietmar Eggemann [this message]
2026-09-16 11:23 ` Oleg Keri
2026-09-17 10:01 ` Dietmar Eggemann
2026-09-10 6:34 ` [PATCH v3 2/2] cpufreq: update capacity_freq_ref when the boost state changes Oleg Keri
2026-09-17 9:57 ` Dietmar Eggemann
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=55538466-2203-42ec-a0bd-b743c04a3b38@arm.com \
--to=dietmar.eggemann@arm.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=beata.michalska@arm.com \
--cc=catalin.marinas@arm.com \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=jonathan.cameron@oss.qualcomm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=mark.rutland@arm.com \
--cc=okerixx@gmail.com \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=ptsm@linux.microsoft.com \
--cc=rafael@kernel.org \
--cc=sibi.sankar@oss.qualcomm.com \
--cc=sudeep.holla@kernel.org \
--cc=sumitg@nvidia.com \
--cc=viresh.kumar@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox