This article is more than 1 year old
Removing an obsolete AMD fix makes Linux kernel 6 quicker
Performance-killing workaround rediscovered after 20 years
An ancient fix for power management issues on AMD systems has been reducing Linux's performance since 2002. Now it's gone.
One of the joys of modern silicon chips is that power management is vitally important. It hasn't been about saving power or extending battery life since the 20th century. Processor vendors survive by selling us more and more transistors, solely on the basis that most of them are turned off most of the time – otherwise the chips would rapidly incinerate themselves, no matter how good their cooling.
This requires sophisticated interfaces between the OS and the hardware, and way back in 1996, a new standard called ACPI (Advanced Configuration and Power Interface) replaced the positively stone age APM (Advanced Power Management) from the Windows 3 era.
It was still a fancy new feature when The Reg reported on Linux on Itanic in 1999, and a worrying security issue in 2006. It's long been a problem for Linux because PC vendors mainly test against the industry-standard OS, which remains Windows. In 2003, Linus Torvalds – famed for his diplomacy – said:
ACPI is a complete design disaster in every way. But we're kind of stuck with it. If any Intel people are listening to this and you had anything to do with ACPI, shoot yourself now, before you reproduce.
This was a year after the Linux kernel gained ACPI support, and around then, a bug was found with some AMD Athlon machines that used VIA chipsets. When the kernel sent the STPCLK#
signal to switch a CPU core to idle (although of course there was only one core in those days), the problematic machines took a while for it to happen, and so the kernel developers added some dummy I/O read instructions, just so that the processor wouldn't continue working when it was meant to be stopping. It improved compatibility and power management.
The problem is, as AMD engineer K Prateek Nayak found recently, that Linux still does it on AMD processors. He found the issue while studying the kernel's behavior with AMD's "Instruction-Based Sampling" toolkit. The issue it fixes is long gone, as are any 2002 Athlon PCs in production, we suspect.
- Is it a bird? Is it Microsoft Office? No, it's Onlyoffice: Version 7.2 released
- Serious surfer? How to browse like a pro on Firefox
- A match made in heaven: systemd comes to Windows Subsystem for Linux
- GNOME hits 43: Welcome To Guadalajara
The result has been a hasty patch by Intel's Dave Hansen, which doesn't remove the workaround but limits it to Intel chips, where it shouldn't cause any problem as they use a different method to switch to idle.
Hansen explains:
This workaround is very painful on modern systems. The"inl()" can take thousands of cycles.
His patch links to some benchmark numbers, but the bottom line is that the minimum throughput increases by about 14 times, and the mean throughput by just over a half.
Although kernel 6.0 is due on Sunday, the patch has already been accepted and should be included. It will be interesting to find out how much difference it makes in real-world performance.
In an era where mitigations for modern CPU problems can reduce performance by 70 per cent – although if you like to live dangerously, you can turn them off – removing obsolete fixes to give some speed back is very welcome indeed. ®