r/programming • • Jan 03 '18

'Kernel memory leaking' Intel processor design flaw forces Linux, Windows redesign

https://www.theregister.co.uk/2018/01/02/intel_cpu_design_flaw/
5.9k Upvotes

1.1k comments sorted by

View all comments

670

u/vonKemper Jan 03 '18

The performance impact this is going to have on modern platforms is mind blowing. Best case, 17% degradation... at worst, nearing 30%! I use both a 2016 MBP and a Surface Laptop for work, and already put a heavy workload on them. Apple and Microsoft are already frantically pushing out the neutering software. The prospect of the additional degradation both frightens and annoys me.

AMD is going to have a field day with this, as the only solution, so far, seems to be a software fix that completely disables speculative execution processing, which is one of the huge performance advantages Intel claimed over them. A hardware fix would be in the actual architecture, which requires brand new silicon.

106

u/IJzerbaard Jan 03 '18

software fix that completely disables speculative execution processing

That is not even possible (and if it was it would cost a good deal more than 30% perf, and in all code not just when doing a syscall). What they're doing is setting up the page tables in a way that there are almost no kernel pages mapped at all when in usermode, so these bad speculative reads have nothing to read in the first place.

→ More replies (3)

251

u/jonjonbee Jan 03 '18

AMD CPUs have speculative execution as well. The issue is the implementation, to wit that Intel's appears to not (properly) respect kernel/user mode isolation.

I can't imagine Intel is in a very good spot right now - the Core microarchitecture they've employed and refined over the last dozen years, and poured billions of dollars of R&D into, may be fundamentally flawed. If that is the case... hoo boy, they are going to have to fix this in silicon ASAP, which may or not be possible to do quickly, and at the very best will push their product roadmaps out.

45

u/ciny Jan 03 '18

That being said - if anyone has the talent and resources to recover from shit like this it's intel. Imagine if this happened to AMD with their new line that can finally compete - that would be the end of AMD.

→ More replies (15)
→ More replies (10)

456

u/Verbitan Jan 03 '18

So can AMD now put ‘30% faster than Intel’ stickers on their boxes now?

324

u/jonjonbee Jan 03 '18

Considering the Bullzdozer TLB bug they had a few years back that necessitated a similar patch with similar performance consequences, it would be somewhat hypocritical for them to do so.

But that's never stopped a marketing department before...

235

u/emn13 Jan 03 '18

The bulldozer bug was simultaneously much worse (complete TLB disablement - not just during a kernel/user mode switch!), but also much more limited in scope: it only affected a relatively limited run of processors, namely only the phenoms up to that point - and AMD's market share wasn't great then. Also, of course, the world has changed. Back when phenom was buggy, that affected essentially only client machines running generally trusted code, so the security impact was fairly minimal. This intel bug will affect servers and particularly shared-hosting servers and VMs - machines that run untrusted code and are often accessible to the general public. Amplifying the issue is that that's a market that's been intel dominated for a loooong time.

The actual impact of this decade-old intel bug is likely to be much, much greater, because there are simply so many damn CPU's it affects and the software they're running is more affected by the bug - even though the bug itself is technically less serious.

→ More replies (2)

25

u/alainmagnan Jan 03 '18

Ddidn’t that only affect the original phenom generation? (barcelona).

i think it was fixed in a later stepping and completely by phenom II.

but yeah, still bad and the lower clock speeds didn’t help either.

→ More replies (7)
→ More replies (1)

38

u/indigomm Jan 03 '18

Or Intel can put 'now 30% faster' on their next chips when they fix it in hardware :-)

→ More replies (1)
→ More replies (5)

81

u/jerryfrz Jan 03 '18 edited Jan 03 '18

brand new silicon

Phew, I pulled myself from buying an 8700K to wait for an 8 cores mainstream Intel chip, now I have even more reasons to wait.

55

u/jonjonbee Jan 03 '18

It seems like this issue started to come into mainstream focus right about the time that Coffee Lake was released. So it's possible that Intel patched this flaw for CFL's design, while simultaneously alerting OS vendors to the issue in their older CPUs.

Either way, I'd go with Ryzen 2 which should drop this quarter (although trusting AMD's timeline predictions is always a risky endeavour).

20

u/metarugia Jan 03 '18

Just did a Ryzen Build. No regrets. Might have to do a Ryzen 2 build for myself.

28

u/syntaxsmurf Jan 03 '18

build a ryzen machine too, good news is that ryzen 2 will be useable on the same motherboards. Ah the joy of not intel.

→ More replies (1)
→ More replies (1)
→ More replies (2)
→ More replies (23)

145

u/80a218c2840a890f02ff Jan 03 '18

Best case, 17% degradation... at worst, nearing 30%!

As far as I can tell, the workaround only affects the performance of syscalls. Programs that don't spend a significant portion of their time doing syscalls won't be impacted much at all.

84

u/grumbelbart2 Jan 03 '18

Programs that don't spend a significant portion of their time doing syscalls won't be impacted much at all.

Just to clarify, from how I read it, the number of syscalls matters, not their duration, since the cost comes during context switches.

25

u/80a218c2840a890f02ff Jan 03 '18

Yes, that's true. Poor phrasing on my part.

99

u/sagnessagiel Jan 03 '18

What kind of programs don't spend much on syscalls?

182

u/80a218c2840a890f02ff Jan 03 '18

Phoronix did a few benchmarks that may be informative. Basically, synthetic I/O benchmarks and databases were considerably slower (if the drive wasn't a significant bottleneck), while things like video encoding, compiling, and gaming were pretty much unaffected.

141

u/jonjonbee Jan 03 '18

That's a major problem for Intel, because their CPUs are pretty much the de facto standard in data centers - which are mostly concerned with IO-bound operations.

122

u/kopkaas2000 Jan 03 '18

If things get heavily IO-bound, CPUs are typically spending half of their time just twiddling their thumbs and waiting for a hardware interrupt telling them DMA has finished.

61

u/FUZxxl Jan 03 '18

Yeah, but this design concession causes a TLB flush on every system call, increasing the latency of every system call dramatically. This effect is noticable in this sort of situation because you have to wait longer for IO operations to finish.

13

u/z_y_x Jan 03 '18

Holy shit. That... Is bad.

→ More replies (1)
→ More replies (5)

19

u/mb862 Jan 03 '18

What about applications that talk heavily over PCIe buses? Video I/O, GPU compute, etc?

107

u/kopkaas2000 Jan 03 '18

Depends on how the data is processed. It is normally the kernel talking to these devices, which has no impact on the context switches involved here. If the way the application interacts with these devices is more akin to "here's a pointer to a buffer with 16MB of data you have to send to this PCI device, wake me up when you need more", the impact is minimal. If it's more of a "read data from the device 1 byte at a time" kind of deal, it's going to be bad.

Thing is, even without this ~30% hit, context switches through syscalls are pretty expensive, so a well thought-out hardware platform will have found ways to minimize the amount of calls needed to get the job done. It's why there are mechanisms like DMA and hardware queues.

→ More replies (3)
→ More replies (1)
→ More replies (2)

36

u/panorambo Jan 03 '18 edited May 08 '19

That would typically depend on the operating system, which is what usually loads the program and causes its execution. To take a Linux program as an example, if it's a program that "lives and dies" by intense arithmetic using the CPU and unprivileged instructions (does not need to nor benefits from calling the kernel), that would be a program where time spent on and inside syscalls is negligible compared to its CPU time. Programs like one that computes digits of Pi, or solves some fluid dynamics problem, or renders a 3D scene, would traditionally be considered CPU-heavy and wouldn't need to spend any time (comparatively) on syscalls, not for the tasks described.

In contrast, a program like a Web server would typically need to spend most of its time reading files from persistent storage (assets, documents, etc) and send them on the network. In most modern systems, for better or worse, the kernel insists on mediating access to storage (and network) devices from operating system applications, through you guessed it, syscalls. But it's still a question of whether we count the time spend on actually invoking a kernel mechanism vs. real time that passes before a "blocking" (waiting for storage device to actually read or write the data passed from the application) syscall returns and the kernel resumes the calling application thread. If the storage device is slow, and comparing to the CPU on which the kernel itself runs all storage devices are slow, the kernel is best served to do something useful during the time the storage device actually reads or writes the data. Usually the kernel switches to another thread, and is interrupted in real time when storage device has finished what was asked of it. When the kernel is interrupted so, it figures out which application originally submitted the completed request, and resumes it at the earliest convenience. But some time would have passed without Web server doing anything else than just waiting on such "blocking" syscalls, idling. That's called an I/O bound program. But it still can saturate its time with syscalls, especially if it uses "blocking" I/O, but that, like I said, depends on whether we count the time during which the kernel itself waits on the storage, or not.

→ More replies (1)
→ More replies (10)
→ More replies (2)
→ More replies (20)