Le 06/07/2018 à 21:47, Maxime Villard a écrit :
I guess we should do both; use "monitor" when possible, and in the places that are still required to use "pause", use a lower BACKOFF_MIN (set at boot time, depending on the cpu model) to compensate for the increased CPU latency.
Here are two patches [1] [2]. We reduce the backoff values for PAUSE, and use MWAIT instead when possible. The code for MWAIT is not very beautiful, because we need to pass the condition, and therefore we need a macro. And we do a 64bit mwait, while the value could actually be smaller. I've benchmarked the latency of PAUSE on a Kabylake (Core i5). It seems that Kabylake indeed has the same latency, because on average PAUSE takes ~136 cycles, which matches the 140c documented for Skylake. The reason for the uncertainty, is that the Kabylake microarchitecture is an optimization of Skylake, but it's not documented whether the increased latency is present (as inherited from Skylake); it looks like it is. I guess we'll have to add manually the CPU models in probe_intel_slowpause(). I don't have a lot of conviction down there... If you could measure the performance difference with the patches applied, that would be nice. Maxime [1] http://m00nbsd.net/garbage/idle/slowpause.diff [2] http://m00nbsd.net/garbage/idle/spinwmait.diff
