Linux 6.3 To Squeeze A Bit More Performance Out Of AMD Zen 4 CPUs
As I wrote about earlier this week, Linux 6.3 is positioned to support AMD Zen 4's Automatic IBRS feature. AMD's Linux enablement code around Automatic IBRS has been undergoing review the past few months and now via TIP's x96/cpu Git branch is to be sent in next month for the Linux 6.3 merge window. I've run some preliminary benchmarks of the Automatic IBRS support on Zen 4 and it's looking positive for further enhancing the performance of AMD's new Ryzen 7000 series and EPYC 9004 series processors.
As explained in prior articles, the Automatic IBRS (Indirect branch Restricted Speculation) is a new feature with Zen 4 processors that is similar to Intel's existing Enhanced IBRS (eIBRS) support found on recent generations of their Core and Xeon processors. Automatic/Enhanced IBRS allows for lower-overhead Spectre V2 mitigations compared to the existing return trampolines "Retpolines" technique used currently on AMD processors up to this point. Zen 3 and prior is still with Retpolines and Zen 4 up to now has been using Retpolines as the default Spectre V2 mitigation path, but starting with the Linux 6.3 kernel will instead default to Automatic IBRS.
AMD briefly touched on Automatic IBRS as part of their new security features during the Zen 4 launch, but didn't talk about it at length. It wasn't even until early November when finally the initial Linux patches arrived for dealing with Auto IBRS. With this being a known, planned feature of Zen 4 it's sad that AMD waited until weeks after the Ryzen 7000 series launched before even posting the Linux kernel patches -- and months later before the patches are queued and now set to be introduced for Linux 6.3. The 6.3 merge window opens up in mid-February while the stable Linux 6.3 kernel release should be out in April.
For this AMD Zen 4 feature that AMD acknowledges "provides greater performance", it's sad to see it take so long post-launch for it to be readied for the mainline Linux kernel. Especially as the likes of Ubuntu 23.04 will likely default to Linux 6.2 rather than 6.3, so at least as out-of-the-box kernels on non-rolling-release Linux distributions are concerned, some AMD Zen 4 users might not see this until Linux distribution releases in the second half of 2023... And longer for LTS/enterprise users unless these patches get ultimately back-ported to stable series.
The seven patches for this Automatic IBRS enablement in the Linux kernel is touching just about 80 lines of code (including for propagating Auto IBRS for KVM guests) and relying too on existing code paths setup for the Intel eIBRS functionality. So it's just a bit frustrating that AMD wasn't able to time this work to come out sooner or (ideally) even ahead of launch. With Intel long-shipping eIBRS, AMD revealing "Auto IBRS" pre launch for Zen 4 wouldn't have been anything dramatic but helps out a little bit in the performance department.
Automatic IBRS is able to help slightly improve the performance for workloads with high kernel interactivity and impacted by Spectre V2 mitigations / Retpolines. This lower-overhead handling than Retpolines mitigation can be particularly beneficial for server workloads that tend to be more involved than conventional desktop applications, so Automatic IBRS is especially good news for AMD 4th Gen EPYC "Genoa" servers.