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@ > Index: sched_bsd.c > =================================================================== > RCS file: /cvs/src/sys/kern/sched_bsd.c,v > retrieving revision 1.62 > diff -u -p -r1.62 sched_bsd.c > --- sched_bsd.c 30 Jan 2020 08:51:27 -0000 1.62 > +++ sched_bsd.c 28 May 2020 14:21:25 -0000 > @@ -576,6 +576,8 @@ setperf_auto(void *v) > j = 0; > speedup = 0; > CPU_INFO_FOREACH(cii, ci) { > + if (!cpu_is_online(ci)) > + continue; > total = 0; > for (i = 0; i < CPUSTATES; i++) { > total += ci->ci_schedstate.spc_cp_time[i]; > >