[PATCH v4 1/2] arm64: topology: fix arch_freq_get_on_cpu() overflow above 4.19 GHz
Peter Zijlstra
peterz at infradead.org
Thu Sep 17 09:24:09 PDT 2026
On Thu, Sep 17, 2026 at 05:55:44PM +0200, Dietmar Eggemann wrote:
> On 17.09.26 17:32, Peter Zijlstra wrote:
> > On Thu, Sep 17, 2026 at 02:51:11PM +0200, Oleg Keri wrote:
>
> [...]
> >> 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)
> >
> > This might not be a very good generic helper, since it relies on either
> > of the variables to be u64 for correctness.
>
> So moving it to a static inline function instead?
>
> static inline u64 cap_scale(u64 value, u64 scale)
> {
> return value * scale >> SCHED_CAPACITY_SHIFT;
> }
Yes, that would be much better defined.
More information about the linux-arm-kernel
mailing list