On Thu, 28 May 2020 11:43:07 -0400
Bryan Steele <bry...@gmail.com>:

> On Thu, May 28, 2020 at 04:29:19PM +0200, Solene Rapenne wrote:
> > the macro CPU_INFO_FOREACH loop over every CPU but the frequency
> > algorithm will raise frequency if one cpu usage goes over a
> > threshold but also if the sum of cpu usage goes over another
> > threshold.
> > 
> > In the current case, if you have offline cpu (because of hw.smt=0),
> > the total will still sum all the idle cpu and it's unlikely that
> > the total threshold is ever reached before the per cpu one.
> > 
> > so, this diff skip offline cpus in the loop (robert@ gave me the big
> > clue to use cpu_is_online in the loop)  
> 
> Thanks for finding this solene! Nice work.
> 
> I've been aware of some issues on AMD with the automatic frequency
> scaling and haven't been able to narrow them down. This may not solve
> all of them, but does appear to improve things on Ryzen CPUs which
> have many cores/threads and no BIOS knob to disable SMT.
> 
> Assuming others agree with the approach..
> 
> ok brynet@

I think this should help CPU with a lot of cores. If I got the
algorithm right this is doing this:

if 1 cpu has idle < 25% then scale up
OR
if sum cpu idle < 33% then scale up

when it scales up, it will bump a ticker to 5 and set perf to 100% and
check again in the next 100ms. Everytime the loop doesn't need to scale
up (but is still at 100% freq) it decrement the ticket. Once the ticket
is 0 or less, then the frequency goes to minimum.

with the current state, if you have offline cpu, you can never go under
50% of the total idle. So the only way to scale up is to have 1 CPU
with less than 25% idle.

It's a lot of magic numbers without explanation here. I'm curious if
this could be improved. I guess that changing them would tip the
balance between responsiveness and battery saving.

Reply via email to