News: 1664289006

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

Removing an obsolete AMD fix makes Linux kernel 6 quicker

(2022/09/27)


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.

[1]

It was still a fancy new feature when The Reg [2]reported on Linux on Itanic in 1999, and a [3]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 – [4]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 [5]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" [6]toolkit . The issue it fixes is long gone, as are any 2002 Athlon PCs in production, we suspect.

[7]Is it a bird? Is it Microsoft Office? No, it's Onlyoffice: Version 7.2 released

[8]Serious surfer? How to browse like a pro on Firefox

[9]A match made in heaven: systemd comes to Windows Subsystem for Linux

[10]GNOME hits 43: Welcome To Guadalajara

The result has been a hasty [11]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 [12]kernel 6.0 is due on Sunday , the patch has already been [13]accepted and should be included. It will be interesting to find out how much difference it makes in real-world performance.

[14]

In an era where mitigations for modern CPU problems [15]can reduce performance by 70 per cent – although if you like to live dangerously, [16]you can turn them off – removing obsolete fixes to give some speed back is very welcome indeed. ®

Get our [17]Tech Resources



[1] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/oses&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=2&c=2YzMeF1kd26xzHKpZzt@68gAAAA0&t=ct%3Dns%26unitnum%3D2%26raptor%3Dcondor%26pos%3Dtop%26test%3D0

[2] https://www.theregister.com/1999/09/08/merced_the_linux_track/

[3] https://www.theregister.com/2006/01/27/rootkits_bios/

[4] https://www.linuxjournal.com/article/7279

[5] https://lore.kernel.org/all/MN0PR12MB61013DC656891259F5D5FA96E24E9@MN0PR12MB6101.namprd12.prod.outlook.com/T/

[6] https://github.com/jlgreathouse/AMD_IBS_Toolkit

[7] https://www.theregister.com/2022/09/27/onlyoffice_72_released/

[8] https://www.theregister.com/2022/09/26/firefox_power_user_guide/

[9] https://www.theregister.com/2022/09/24/systemd_windows_linux_microsoft/

[10] https://www.theregister.com/2022/09/22/gnome_43_is_here_soon/

[11] https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=x86/urgent&id=e400ad8b7e6a1b9102123c6240289a811501f7d9

[12] https://www.theregister.com/2022/09/26/linux_6_rc7/

[13] https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=x86/urgent&id=e400ad8b7e6a1b9102123c6240289a811501f7d9

[14] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/oses&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44YzMeF1kd26xzHKpZzt@68gAAAA0&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0

[15] https://www.theregister.com/2022/09/12/retbleed_slugs_vm_performance_by/

[16] https://www.theregister.com/2022/07/18/improve_linux_performance/

[17] https://whitepapers.theregister.com/



Why mince words??

Snake

"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."

Now that's getting down to the point :p

But in all seriousness, something like this should have been reviewed long ago.

Re: Why mince words??

Flocke Kroes

A key part of it is no-one noticed any problems. It only shows in the C2 power state, which is very unlikely on servers. It is common on laptops but AMD laptops are rare.

We're all wise in retrospect

gerryg

"But in all seriousness, something like this should have been reviewed long ago."

It seems like it was a small piece of code tucked away minding its own business. If I understand correctly you'd mostly notice it if you had an AMD laptop and there are few of those.

So given this is of of those issues for "need for speed" types the client group is not them and probably tiny. So no-one noticed.

But finally someone did and I envisage that still no-one will notice.

There's an obsolute compatibility patch running on my PC

Timto

It's called Windows

Re: There's an obsolute compatibility patch running on my PC

Flocke Kroes

Has this performance reducer been fixed in Windows? Did anyone notice?

Re: There's an obsolute compatibility patch running on my PC

Jim Mitchell

Does Windows have this issue?

It's official

Bitsminer

The issue it fixes is long gone....

Nobody understands it, it does things nobody wants, and it took an accident to find the bug.

Linux is now officially legacy software.

The older the OS...

DenTheMan

...the faster it is.

Every new OS adds millions of lines of code, much of the time the new code being bolted on to add to overhead.

I would love to see Windows 3.11 made to work, despite the interface being upteen times slower than Dos.

A rock store eventually closed down; they were taking too much for granite.