Linux 4.17 Getting A Fix That May Help AMD Systems Conserve Power When Idling
Besides other promising Linux 4.17 power saving improvements, a separate fix was queued today for potentially helping AMD systems conserve power.
An AMD engineer noticed that with the existing Linux kernel code, using the MWAIT instruction is supported and used but on AMD CPUs but does not allow deeper c-states than C1 with current-generation hardware. The MWAIT x86 instruction is used as a hint for letting the processor enter a CPU-specific optimized state.
So with the kernel code up until now, on AMD CPUs it could forgo entering some of the deeper power-saving states. But with this simple patch, that's no longer the case.
The good news is this patch is also copied for the Linux kernel stable series too so should be appearing in the various maintained branches soon rather than having to wait for Linux 4.17.
It will be interesting to see the impact on power-savings for AMD Zen systems as a result of this change. The pull request of the x86 patches today notes it does "prevent excessive power consumption" but does not provide any specifics, but I'll be testing it shortly on Linux Git.
An AMD engineer noticed that with the existing Linux kernel code, using the MWAIT instruction is supported and used but on AMD CPUs but does not allow deeper c-states than C1 with current-generation hardware. The MWAIT x86 instruction is used as a hint for letting the processor enter a CPU-specific optimized state.
So with the kernel code up until now, on AMD CPUs it could forgo entering some of the deeper power-saving states. But with this simple patch, that's no longer the case.
Recent AMD systems support using MWAIT for C1 state. However, MWAIT will not allow deeper cstates than C1 on current systems.
play_dead() expects to use the deepest state available. The deepest state available on AMD systems is reached through SystemIO or HALT. If MWAIT is available, it is preferred over the other methods, so the CPU never reaches the deepest possible state.
Don't try to use MWAIT to play_dead() on AMD systems. Instead, use CPUIDLE to enter the deepest state advertised by firmware. If CPUIDLE is not available then fallback to HALT.
The good news is this patch is also copied for the Linux kernel stable series too so should be appearing in the various maintained branches soon rather than having to wait for Linux 4.17.
It will be interesting to see the impact on power-savings for AMD Zen systems as a result of this change. The pull request of the x86 patches today notes it does "prevent excessive power consumption" but does not provide any specifics, but I'll be testing it shortly on Linux Git.
22 Comments