Intel FSGSBASE Linux Support Revived For A Performance Boost On Intel/AMD Processors
One of Microsoft's Linux kernel hacker, Sasha Levin, has taken up the patches in trying to get the mainlined with Intel seemingly not in a rush to get the patches merged that have been sent out a few times in recent years. He explained with the revised patches:
Currently a user process that wishes to read or write the FS/GS base must make a system call. But recent X86 processors have added new instructions for use in 64-bit mode that allow direct access to the FS and GS segment base addresses. The operating system controls whether applications can use these instructions with a %cr4 control bit.
In addition to benefits to applications, performance improvements to the OS context switch code are possible by making use of these instructions. A third party reported out promising performance numbers out of their initial benchmarking of the previous version of this patch series.
We were the ones last year benchmarking the Linux FS/GS BASE patches and at the time did find them to indeed help the performance in various workloads. I'll be testing these newer patches soon. In those benchmarks from last year, the patches provided around a 3% performance boost in tested workloads.
FSGSBASE support is found on Intel CPUs going back to Ivy Bridge. On the AMD side the support is there at least for Zen. The presence of the capability can be found by checking for "fsgsbase" within /proc/cpuinfo.
Here's to hoping these performance-helping patches will get reviewed and ready for inclusion in Linux 5.8, especially given these patches help in particular for workloads previously hurt by the Spectre/Meltdown/SWAPGS mitigation patches.
With this tenth revision to the FSGSBASE patches, the code is re-based against Linux 5.7-rc1 and various workarounds applied. Stay tuned for benchmarks.