Thread (8 messages) 8 messages, 3 authors, 14d ago

Re: [PATCH v4 1/2] arm64: topology: fix arch_freq_get_on_cpu() overflow above 4.19 GHz

From: Peter Zijlstra <peterz@infradead.org>
Date: 2026-09-17 16:24:15
Also in: driver-core, linux-pm, lkml

On Thu, Sep 17, 2026 at 05:55:44PM +0200, Dietmar Eggemann wrote:
On 17.09.26 17:32, Peter Zijlstra wrote:
quoted
On Thu, Sep 17, 2026 at 02:51:11PM +0200, Oleg Keri wrote:
[...]
quoted
quoted
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help