Published in News

Linux scheduler issue claims garbage

by on06 January 2020

Says Linus Torvalds

Linus Torvalds says that claims by C++ game developer Malte Skarupke that his spinlocks experiments had discovered the Linux kernel had a scheduler issue were garbage.

Torvalds said the whole post seems to be just wrong and is measuring something completely different than what the author thinks and claims it is measuring.

He said that spinlocks can only be used if you actually know you're not being scheduled while using them. But the blog post author seems to be implementing his own spinlocks in userspace with no regard for whether the lock user might be scheduled or not. And the code used for the claimed "lock not held" timing is complete garbage.

It basically reads the time before releasing the lock, and then it reads it after acquiring the lock again and claims that the time difference is the time when no lock was held. "Which is just inane and pointless and completely wrong.

“The code in question is pure garbage. You can't do spinlocks like that. Or rather, you very much can do them like that, and when you do that you are measuring random latencies and getting nonsensical values because what you are measuring is "I have a lot of busywork, where all the processes are CPU-bound, and I'm measuring random points of how long the scheduler kept the process in place", wrote Torvalds.

“And then you write a blog-post blaming others, not understanding that it's your incorrect code that is garbage, and is giving random garbage values”, he added.

"You might even see issues like "when I run this as a foreground UI process, I get different numbers than when I run it in the background as a batch process". Cool interesting numbers, aren't they? “No, they aren't cool and interesting at all, you've just created a particularly bad random number generator."

He told Skarupke he should never ever think that he was clever enough to write locking routines.

“Because the likelihood is that you aren't (and by that "you" I very much include myself -- we've tweaked all the in-kernel locking over decades, and gone through the simple test-and-set to ticket locks to cacheline-efficient queuing locks, and even people who know what they are doing tend to get it wrong several times)”, Torvalds said.

Torvalds added: "There's a reason why you can find decades of academic papers on locking. Really. It's hard.

Skarupke replied that it really "meant a lot to me that Linus responded, even if the response is negative".


Last modified on 06 January 2020
Rate this item
(2 votes)

Read more about: