Linus Torvalds Calls Blogger's Linux Scheduler Checks 'Pure Rubbish'

NPM Adds Command-Line Option To Help Fund Open-Source Coders

On Wednesday Phoronix cited a weblog publish by C++ recreation developer Malte Skarupke claiming his spinlocks experiments had found the Linux kernel had a scheduler problem affecting builders bringing video games to Linux for Google Stadia.

Linus Torvalds has now responded:
The entire publish appears to be simply fallacious, and is measuring one thing utterly completely different than what the creator thinks and claims it’s measuring.

First off, spinlocks can solely be used for those who really know you are not being scheduled whereas utilizing them. However the weblog publish creator appears to be implementing his personal spinlocks in consumer house with no regard for whether or not the lock consumer may be scheduled or not. And the code used for the claimed “lock not held” timing is full rubbish.

It mainly reads the time earlier than releasing the lock, after which it reads it after buying the lock once more, and claims that the time distinction is the time when no lock was held. Which is simply inane and pointless and utterly fallacious…

[T]he code in query is pure rubbish. You may’t do spinlocks like that. Or fairly, you very a lot can do them like that, and whenever you do that you’re measuring random latencies and getting nonsensical values, as a result of what you’re measuring is “I’ve lots of busywork, the place all of the processes are CPU-bound, and I am measuring random factors of how lengthy the scheduler stored the method in place”.

And then you definately write a blog-post blamings others, not understanding that it is your incorrect code that’s rubbish, and is giving random rubbish values…

You would possibly even see points like “once I run this as a foreground UI course of, I get completely different numbers than once I run it within the background as a batch course of”. Cool fascinating numbers, aren’t they?

No, they are not cool and fascinating in any respect, you have simply created a very dangerous random quantity generator…

[Y]ou ought to by no means ever suppose that you just’re intelligent sufficient to write down your personal locking routines.. As a result of the chances are high that you are not (and by that “you” I very a lot embody myself — we have tweaked all of the in-kernel locking over a long time, and gone by means of the straightforward test-and-set to ticket locks to cacheline-efficient queuing locks, and even individuals who know what they’re doing are inclined to get it fallacious a number of occasions).

There is a cause why you will discover a long time of educational papers on locking. Actually. It is onerous.

“It actually means so much to me that Linus responded,” the blogger wrote later, “even when the response is unfavorable.” They replied to Torvalds’ 1,500-word publish on the identical mailing listing — and this time acquired a 1900-word response arguing “you probably did locking essentially fallacious…”

The actual fact is, doing your personal locking is tough. It’s good to actually perceive the problems, and it’s essential to not over-simplify your mannequin of the world to the purpose the place it is not really describing actuality any extra…

Coping with actuality is tough. It generally implies that it’s essential to make your psychological mannequin for a way locking must work much more difficult…

Learn extra of this story at Slashdot.