News for hackers. Stuff that matters.
Re:Linux page table isolation is not needed on AMD processors by jandrese on Tuesday January 02, 2018 @11:19AM (#16052768)
I think the du case was an outlier. Normal workloads shouldn't be so heavily affected. I am expecting a few percent loss on most programs though. It's basically a larger penalty for making a syscall, which was already a fairly slow operation so performance minded people avoid them in tight loops. It will be bad for people who need to do lots of fast I/O I suspect.
Re:Linux page table isolation is not needed on AMD processors by dannyw on Tuesday January 02, 2018 @08:21PM (#16057527)
Postgres and Redis are looking at a 20-25% performance hit.

https://www.phoronix.com/scan.php?page=article&item=linux-41...

Re:Linux page table isolation is not needed on AMD processors by tankenmate on Tuesday January 02, 2018 @11:32AM (#16052923)
Some portable / embedded databases come to mind. Also "normal" databases doing replication initiation, and replication re-sync. And lastly backup, restore, tar, etc with small files. For files under a handful of pages long mmap() isn't a big gain.

Another syscall I think that might cause issues is gettimeofday(), that particular call has been optimised to the nth degree, and lots of user programs spam the crap out of it (mostly necessarily), especially networking and streaming programs. It would be interesting to see how much of an overhead percentagewise page table isolation will cost, and its effects on low end media devices, et al.

Re:Linux page table isolation is not needed on AMD processors by pm215 on Tuesday January 02, 2018 @11:48AM (#16053088)
Linux gettimeofday these days is implemented in the 'vdso', which is code provided by the kernel that runs solely in userspace. So it's not a syscall in the 'privilege level switch by executing insn that takes an exception' sense and shouldn't be affected by the syscall-entry/exit path becoming more expensive.
Re:Linux page table isolation is not needed on AMD processors by tankenmate on Tuesday January 02, 2018 @12:40PM (#16053552)
Does this also apply to vsyscall's being emulated? Will this mean that older static binaries will no longer run? or just suffer a penalty as well?
Re:Linux page table isolation is not needed on AMD processors by wolf550e on Tuesday January 02, 2018 @01:14PM (#16053866)
Linux kernel has a compatibility guarantee to the user space visible API, so static binaries will continue to run. If the static binary is so old it does not know about vdso and uses regular syscall to query time, it will be slowed down.
Re:Linux page table isolation is not needed on AMD processors by amluto on Tuesday January 02, 2018 @09:59PM (#16057931)
Emulated vsyscalls were already very slow and will be even slower on a patched kernel. They'll still work, though.
Re:Linux page table isolation is not needed on AMD processors by tankenmate on Tuesday January 02, 2018 @05:30PM (#16056462)
This topic got me to look at the vDSO for my own machine so I wrote a short Perl program to dump your kernel's vDSO.

https://pastebin.com/UnQX5U1f

Re:Linux page table isolation is not needed on AMD processors by tankenmate on Wednesday January 03, 2018 @09:49AM (#16061370)
I added a quick repo to github if you want to clone or send pull requests for architectures apart from 64bit LE.

https://github.com/mattkeenan/dump-vdso

Re:Linux page table isolation is not needed on AMD processors by amluto on Tuesday January 02, 2018 @11:45AM (#16053063)
vDSO-based timing is unaffected.
Re:Linux page table isolation is not needed on AMD processors by mehrdadn on Tuesday January 02, 2018 @05:46PM (#16056580)
Isn't every (edit: contended) mutex/etc. wait operation a syscall? That's gotta hurt for any program that waits for frequent events that don't take too long to process.
Re:Linux page table isolation is not needed on AMD processors by mortehu on Tuesday January 02, 2018 @06:00PM (#16056694)
They are only system calls when you need to wait or wake up processes.

https://en.m.wikipedia.org/wiki/Futex

Re:Linux page table isolation is not needed on AMD processors by mehrdadn on Tuesday January 02, 2018 @06:14PM (#16056798)
I was assuming contention but I guess I wasn't clear, sorry. I updated the post. But saying this "only" occurs when there is contention is very misleading since it makes it seem like the scenario of lock contention is a negligible concern. It's not.
Re:Linux page table isolation is not needed on AMD processors by kllrnohj on Tuesday January 02, 2018 @08:30PM (#16057554)
Thread-suspending contended mutexes are already extremely slow. If you have a heavily-contended mutex you already have a major performance bug. If this is the kick in the pants you need to go fix it that's arguably a good thing ;)

Note that mutex contention does not itself mean immediately falling back to futex - commonly you'll spinloop first and hope that resolves your contention (fast), then fall back to futex (slow)

Re:Linux page table isolation is not needed on AMD processors by mehrdadn on Tuesday January 02, 2018 @09:29PM (#16057788)
> If you have a heavily-contended mutex you already have a major performance bug.

I can't really devote time to countering the unfounded assertion that every contended mutex must be a bug. It certainly isn't consistent with my experience, but if every problem you've solved could have been parallelized infinitely without increasing lock contention, more power to you.

Re:Linux page table isolation is not needed on AMD processors by kllrnohj on Tuesday January 02, 2018 @10:36PM (#16058128)
> I can't really devote time to countering the unfounded assertion that every contended mutex must be a bug.

Good, because that's not what I said. If you're heavily hitting futex convention you do have a performance bug, though. You might be confused with general contention that's being resolved with a spinlock rather than futex wait, though.

Re:Linux page table isolation is not needed on AMD processors by mehrdadn on Tuesday January 02, 2018 @10:45PM (#16058173)
>> I can't really devote time to countering the unfounded assertion that every contended mutex must be a bug.

> Good, because that's not what I said.

It is literally what you said:

>>> If you have a heavily-contended mutex you already have a major performance bug. If this is the kick in the pants you need to go fix it that's arguably a good thing ;)

> You might be confused with general contention that's being resolved with a spinlock rather than futex wait, though.

I'm not confusing them at all; I'm literally reading exactly what you wrote. You literally said contended mutexes are necessarily bugs (right here^) and that you considered mutexes to include the initial spinlocks ("note that mutex contention does not itself mean immediately falling back to futex - commonly you'll spinloop first"). But maybe you meant to say something else?

Re:Linux page table isolation is not needed on AMD processors by netheril96 on Wednesday January 03, 2018 @07:55AM (#16060564)
He said "heavily contended", and then you dropped the "heavily" prefix and claimed that was literally what he said. That adverb is material to the discussion and your dropping it completely changes the meaning.

I concur with his opinion. Infrequent contention is not a bug; otherwise no mutex is needed. Frequent contention (or heavy contention in his words) is a performance bug.

Re:Linux page table isolation is not needed on AMD processors by mehrdadn on Wednesday January 03, 2018 @08:16AM (#16060683)
> He said "heavily contended", and then you dropped the "heavily" prefix and claimed that was literally what he said. That adverb is material to the discussion and your dropping it completely changes the meaning.

"Heavily" was not dropped intentionally at all. Add it back to my comments. It changes nothing whatsoever. The incredible opinion that every problem can be necessarily parallelized without eventually resulting in contention (and I license you to freely modify this term with 'light', 'heavy', 'medium-rare', 'salted', 'peppered', or 'grilled at 450F' to your taste) is so fantastically absurd that I cannot believe you are debating it. I definitely don't know how you can justify such an unfounded claim with no evidence and I certainly have no interest in wasting time debating it. As I said earlier: if you never encounter problems that exhibit eventual scalability limits, more power to you.

Re:Linux page table isolation is not needed on AMD processors by kllrnohj on Tuesday January 02, 2018 @11:11PM (#16058309)
I literally said spin loop resolving is fast. Maybe read more than the single phrase you're pulling out of context to go on a rant about?
Re:Linux page table isolation is not needed on AMD processors by asveikau on Tuesday January 02, 2018 @09:48PM (#16057876)
Let's put it this way. If every contended mutex were a bug, why not remove the mutex and let the code run as-is? No, you wouldn't, so no, not a bug.
Re:Linux page table isolation is not needed on AMD processors by mehrdadn on Tuesday January 02, 2018 @09:57PM (#16057922)
> Let's put it this way. If every contended mutex were a bug, why not remove the mutex and let the code run as-is? No, you wouldn't, so no, not a bug.

I mean, the parent's argument is wrong, but isn't that naive. Presumably the argument is a bad (yet still correct) solution would result in lock contention while a better solution would e.g. use a different algorithm that is more parallelizable.

Re:Linux page table isolation is not needed on AMD processors by revelation on Tuesday January 02, 2018 @06:15PM (#16056804)
Ideally a mutex is just a cmpxchg. It gets more expensive when it is contended. See the Drepper paper on futexes:

http://www.akkadia.org/drepper/futex.pdf

Re:Linux page table isolation is not needed on AMD processors by mehrdadn on Tuesday January 02, 2018 @06:26PM (#16056893)
Thanks, yeah, someone already mentioned this and I already edited in "contended" to clarify. I was actually already aware of futexes (thanks for the link though, I've never actually read the paper), but I was assuming contention -- the "every" referred to every type of operation, not every instance. See my reply to the sibling comment regarding lock contention.
Re:Linux page table isolation is not needed on AMD processors by contrarian_ on Tuesday January 02, 2018 @02:29PM (#16054674)
Sounds like servers handling lots of small UDP packets would be hit pretty hard.
Re:Linux page table isolation is not needed on AMD processors by revelation on Tuesday January 02, 2018 @06:24PM (#16056879)
Applications like this where the syscall overhead (and latency) starts to be a significant factor in processing time and latency have moved to userland drivers anyway:

DPDK for 10-100 Gbps networking: https://dpdk.org/

SPDK for NVMe storage: http://www.spdk.io/

The queuing and balancing stuff the kernel does makes sense for spinning rust harddisks and residential networking, but when the underlying hardware is so fast that nothing is ever queued, really what are you doing. At 100 Gbps line speed, a 1518 byte packet takes all of ~ 120ns to transmit, or about 360 clock cycles for a 3 GHz processor.

Re:Linux page table isolation is not needed on AMD processors by emj on Wednesday January 03, 2018 @07:55AM (#16060568)
Taking control over network cards in user space seems doable nowdays. There was a talk about doing such drivers with IOMMU/DMA at CCC: https://media.ccc.de/v/34c3-9159-demystifying_network_cards
Re:Linux page table isolation is not needed on AMD processors by arghwhat on Saturday January 06, 2018 @07:24AM (#16084978)
User-space drivers have been doable for a while, and dpdk[1] is definitely worth a check. There's also some manufacturers[2] that only does user-space drivers for their high-performance cards (e.g. 4x10Gb/s, 2x40Gb/s, 2x100Gb/s cards). Being designed with this in mind helps performance a lot.

1: https://dpdk.org/ 2: http://www.napatech.com/

Re:Linux page table isolation is not needed on AMD processors by DSMan195276 on Wednesday January 03, 2018 @10:26AM (#16061716)
> Applications like this where the syscall overhead (and latency) starts to be a significant factor in processing time and latency have moved to userland drivers anyway:

I would personally think that is worse, though please correct me if I'm wrong. The userland driver will run with an isolated PT like any other userland process won't it? If so, it will suffer the same slowdown that every other process now has every-time it has to communicate with the kernel, which I would think would be a lot for a driver.

Re:Linux page table isolation is not needed on AMD processors by revelation on Wednesday January 03, 2018 @07:00PM (#16066703)
It's counter intuitive at first, but the key to understand how this works is that while you can use an MMU to assign chunks of physical memory to a process, you can of course also just use the MMU to assign the memory mapped IO registers of say a PCI express peripheral to a process.

That is in a nutshell what a "userland driver" is. It's not too far removed from poking the parallel port at 0x378 on your DOS computer :)

Re:Linux page table isolation is not needed on AMD processors by arghwhat on Saturday January 06, 2018 @07:26AM (#16084985)
A user-space driver doesn't communicate with the kernel. It is assigned DMA buffers, and communicates with the NIC solely through reading and writing to shared memory buffers.

Even before this fix, the benefits were massive, as sending a buffer was just writing to some memory, rather than syscalls and copies galore.

Re:Linux page table isolation is not needed on AMD processors by zmatt on Tuesday January 02, 2018 @08:17PM (#16057506)
Reduce number of syscalls by using sendmmsg()/recvmmsg() to batch together multiple packets per syscall?
Re:Linux page table isolation is not needed on AMD processors by jamiesonbecker on Thursday January 04, 2018 @12:09AM (#16068198)
Anyone run any DNS server benchmarks, esp BIND and PowerDNS?
Re:Linux page table isolation is not needed on AMD processors by brazzledazzle on Tuesday January 02, 2018 @05:54PM (#16056645)
This may end up doing some significant hurt to some build and testing pipelines.
Re:Linux page table isolation is not needed on AMD processors by mtanski on Tuesday January 02, 2018 @11:31AM (#16052908)
It sounds like databases on very fast storage will be updated. Tons of syscalls made for disk io and network io.
Re:Linux page table isolation is not needed on AMD processors by lmm on Tuesday January 02, 2018 @11:38AM (#16052977)
Databases are already written to minimise syscalls, like any other heavily performance-tuned system.
Re:Linux page table isolation is not needed on AMD processors by amadvance on Wednesday January 03, 2018 @03:32AM (#16059421)
Applications that already put an effort to minimize syscalls are the ones that most likely depend on syscalls performance.
Re:Linux page table isolation is not needed on AMD processors by lmm on Wednesday January 03, 2018 @03:51AM (#16059497)
Unlikely. It's relatively easy to get to the point where syscalls aren't the bottleneck by a long margin, so the only apps where syscalls are the bottleneck will be those that haven't put in any optimisation effort.
Re:Linux page table isolation is not needed on AMD processors by ambrop7 on Tuesday January 02, 2018 @04:13PM (#16055701)
I think syscalls are not as slow as many people imagine they are, especially with modern CPUs and kernels (there are special instruction for syscalls that are faster than the old "interrupt" approach). See here: http://pzemtsov.github.io/2017/07/23/the-slow-currenttimemil... ("Off-topic: A system call"). But they will be slow with this mitigation.