Linux 5.20 With AMD Zen Will Prefer MWAIT Over HALT As An HPC Optimization

Written by Michael Larabel in AMD on 9 June 2022 at 06:45 AM EDT. 2 Comments
AMD
Earlier this year was an AMD Linux patch to prefer using MWAIT rather than HALT for cases where the CPU idle driver isn't being used. Using MWAIT can lead to significant improvements for the exit latency and now for the Linux 5.20 cycle later this year that change is expected to land.

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.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week