Linux 5.20 With AMD Zen Will Prefer MWAIT Over HALT As An HPC Optimization
Intel CPUs going back to the Core 2 days have preferred MWAIT over HALT (HLT) for the C1 code in the Linux kernel. The Monitor Wait "MWAIT" instruction can be used for power management purposes to hint that the processor can enter a specified target C state while waiting for an event or a MONITOR'ed store operation to complete. Usage of MWAIT is intended to be more efficient than the HALT instruction, which AMD CPUs on Linux continue using when not relying on the kernel's idle driver. AMD Zen CPUs though do support MWAIT for more efficient handling (or going back to K10 does support MWAIT but not MWAIT C1 support until Zen 1).
This week now that the Linux 5.19 merge window has passed, the patch has been picked up by TIP's x86/cpu branch. In turn that work should wind up being submitted to the mainline kernel for the Linux 5.20 cycle later this summer. This benefits all generations of AMD Zen processors going back to the original Zen 1 CPU models.
For those like HPC users that disable global C-states / opt for BIOS performance profiles, this change to prefer MWAIT C1 over HALT should yield nice improvements to the exit latency. This change doesn't affect Intel Linux users with the kernel for many years and going back to the Core 2 CPU days already preferring MWAIT. Those wanting to compare or test old behavior can boot the kernel with "idle=nomwait" as a kernel command line parameter to use HALT (HLT) instead.