News for hackers. Stuff that matters.
Re:No nuances, just buggy code (was: related to Spinlock imp... by asdfasgasdgasdg on Sunday January 05, 2020 @01:40AM (#21960057)
Ok, so how you would write this (at least the first section, explaining the error) constructively could be much shorter.

"The author of that post has a common misconception, which is that spin locks are a fast drop in replacement for uncontended mutexes. They aren't. You can only use them well when you know you won't be descheduled, like we do in the kernel. In a generic userspace program, you don't have that knowledge. The possibility of your time slice ending skews all the time measurements, for example."

Boom. Roughly the same message. Most people will get the same amount of edification from this as Linus' original letter. You could go in to more detail if you want but it's not really necessary. Smart people will figure it out if you just point out the general shape of the error. No need for calling code "garbage."

Re:No nuances, just buggy code (was: related to Spinlock imp... by csande17 on Sunday January 05, 2020 @02:05AM (#21960103)
I personally really appreciated the additional details in Linus's version.

When I read your version, I learn that spin locks are not a drop-in replacement for uncontested mutexes. That's great, except that I don't really know for sure what either of those terms mean, and also I didn't gain any knowledge that doesn't relate to this specific situation. It also wasn't super convincing -- I could just as easily see someone post a reply saying "well actually spin locks ARE a drop-in something something mutex" and I'd have no way to tell who was right.

Linus, on the other hand, told me about the mechanism by which the problem happens. I learned about how the scheduler sees spin-locks' loops, and that the main advantage of "real" mutexes is that the scheduler knows who's waiting on what. I also wouldn't necessarily have realized the "take clock measurement, then get descheduled before you release the lock" issue if he hadn't called it out specifically.

Sure, I guess "garbage" comes off a little mean, but "the author has a common misconception" almost sounds more passive-aggressive to me.

Re:No nuances, just buggy code (was: related to Spinlock imp... by simias on Sunday January 05, 2020 @02:38AM (#21960184)
The first section of Linus's answer reads really rough to me and almost made me stop reading, imagining that it was going to be yet an other entry in the "Linus bullies some poor coder into submission by insulting them until they just stop responding" which is a shame because there's a lot of interesting content after that. I guess I invite the people who had the same knee-jerk reaction I had to give the post a 2nd chance and power through Linus' unnecessarily harsh tone to get to the good stuff.

>Sure, I guess "garbage" comes off a little mean, but "the author has a common misconception" almost sounds more passive-aggressive to me.

The latter might be slightly passive-aggressive (although it doesn't have to be), the former is simply aggressive-aggressive.

Re:No nuances, just buggy code (was: related to Spinlock imp... by needs on Sunday January 05, 2020 @04:20AM (#21960456)
As long as Linus is blaming the work done and not the people behind it, that's fine. Something truly aggressive would be "This benchmark is garbage and the people responsible for writing it are monkeys on crack". He did such things in the past, but in the 4 emails I got to find on this specific benchmark, none of them critic people writing code.

I think Linus got upset that a badly designed benchmark got popular and therefor is spreading misconceptions. His strongly worded answer is getting popular too and as a result everybody learns and he has stopped an urban legend from spreading. A success on every points.

Re:No nuances, just buggy code (was: related to Spinlock imp... by simias on Sunday January 05, 2020 @05:06AM (#21960580)
>As long as Linus is blaming the work done and not the people behind it, that's fine.

I think your comment is just wrong and generally pure garbage. I can't believe some poor server will have to host this nonsense for years to come. It's the most inane thing I've read all year.

I'm just talking about your comment, not you though, so clearly no hard feelings here and it's definitely the right way to frame my argument to have a nice, peaceful and constructive technical discussion.

Re:No nuances, just buggy code (was: related to Spinlock imp... by AndriyKunitsyn on Sunday January 05, 2020 @06:59AM (#21960896)
No, reductio ad absurdum is not an argument. What you wrote is an exercise in swearing. What Linus wrote is getting his point across.

It is certainly possible to describe a code with bad words without hurting the feelings of person who made it, and I think, in order for it to work everyone has to understand that everybody writes “garbage” or “crap” code sometimes, so when it happens, it’s not a big deal; it shouldn’t hurt your professional dignity.

On my job, in team of 4, we do it from time to time and it’s just much mentally easier, streamlined - and yes, constructive to conduct code reviews this way. I understand this may not work for other, bigger teams, but it’s certainly a valid way.

Re:No nuances, just buggy code (was: related to Spinlock imp... by polishTar on Sunday January 05, 2020 @12:04PM (#21962224)
There were ways for him to communicate those same ideas less negatively.

And it was more than just the "garbage" line. It was also things like "If I haven't convinced you of that by now, I don't know what I can say.", and "See how simplistic - and self-centered - your expectation is?".

Writing this way doesn't "streamline" anything. I interpreted it as a negative interaction, and clearly others have as well including the original author (since he said as much in his response).

Re:No nuances, just buggy code (was: related to Spinlock imp... by asdfasgasdgasdg on Sunday January 05, 2020 @12:24PM (#21962405)
> Writing this way doesn't "streamline" anything.

Exactly. Blameless and non-violent language can streamline communication. It does this by removing any trigger that would make your communication partner feel defensive. Needlessly emotional and charged language is sure to distract from the subject at hand. When you use calm language, there is only one thing to focus on: the content. When you call someone's code garbage, there are now two things that that person could focus on -- the content and the tone.

To me, it is completely reasonable that the original author might have made a mistake like this. After all, when he shared his findings it seemed like he had found something interesting to me! Many people on this very site commented positively on his efforts. There is nothing "garbage" about the code that he wrote, it just doesn't quite do exactly what he thought it did.

Re:No nuances, just buggy code (was: related to Spinlock imp... by thezilch on Sunday January 05, 2020 @03:34PM (#21963867)
> To me, it is completely reasonable that the original author might have made a mistake like this. After all, when he shared his findings it seemed like he had found something interesting to me! Many people on this very site commented positively on his efforts. There is nothing "garbage" about the code that he wrote, it just doesn't quite do exactly what he thought it did.

It was blogged about, so carries some authority on the topic, and was convincing to readers, but the code did nothing close -- not just "not quite exactly" -- to what it was portrayed to be doing in the benchmarks or article. It is garbage; useless; should be binned. I tried to come up with better adjectives -- "dangerous", "useless", etc -- but they came up short, in subtle ways. Who cares; Linus explains what he means better than the one, concise word.

Re:No nuances, just buggy code (was: related to Spinlock imp... by sebsito on Sunday January 05, 2020 @02:58PM (#21963612)
Speech is not violence.

It always contains some information payload. If you felt triggered by it and failed to parse the content then maybe you're overly emotional.

For some people who aren't it's going to be useful assessment of how bad this code was.

I see this ongoing trend (Twitter) that by limiting the ways in which people can express themselves, you can in theory broaden the recipient circle (to include people who otherwise would be offended and wouldn't read).

In practice you not only limit the ways in which information can be distributed but often also barter away some people who weren't offended and would get useful information this way.

Looking at speech this way is also a bad idea because today's acceptable is tomorrow's unacceptable word and the only way to allow all information is to allow all speech.

Re:No nuances, just buggy code (was: related to Spinlock imp... by asdfasgasdgasdg on Sunday January 05, 2020 @07:20PM (#21965343)
All I'm saying is that there is a spectrum of ways to communicate about things like this, from "fuck you you piece of shit how dare you put out this garbage code" to "hey, bud, I see what you're trying to do. But there's a mistake here, which I can explain." Linus chose something closer to the left than the right. You can get the same technical ideas across either way, but as you move toward the latter mode of communication you will decrease the number of recipients who have trouble receiving your message because of its negative emotional content.

"maybe you're overly emotional." Feel free to label me however you please. It does not change the fact that if your goal is to communicate ideas efficiently, my way will help you avoid alienating some folks, and has no practical downside.

Re:No nuances, just buggy code (was: related to Spinlock imp... by sebsito on Monday January 06, 2020 @04:22AM (#21967781)
There's a big difference between ugly ad hominem comments and saying that your code is bs.

> and has no practical downside That's the place when we differ in opinion. It has one direct downside of preventing some people from expressing their opinions and conveying the point. And another in the long run – setting up a precedents of what can and cannot be said.

> Feel free to label me however you please It was general note not something directed at you.

Re:No nuances, just buggy code (was: related to Spinlock imp... by ModernMech on Sunday January 05, 2020 @12:10PM (#21962286)
In my group, we call it "shoddy" code. A bit less brash than "garbage" I think.
Re:No nuances, just buggy code (was: related to Spinlock imp... by dahauns on Sunday January 05, 2020 @08:55AM (#21961245)
If you had followed with multiple paragraphs describing in detail as to why the comment is pure garbage, why it has to be called out, offering context, background information and possible alternatives - then you'd have a valid analogue and a basis for debate. Just sayin'.
Re:No nuances, just buggy code (was: related to Spinlock imp... by needs on Sunday January 05, 2020 @06:45AM (#21960848)
Believe it or not, it's one way or another to formulate a critic, and I'm fine with it. However your strongly worded answer lacks arguments, so color me unconvinced.
Re:No nuances, just buggy code (was: related to Spinlock imp... by mda on Sunday January 05, 2020 @06:44AM (#21960847)
Except your attempt is not exactly analogus to the situation discussed.
Re:No nuances, just buggy code (was: related to Spinlock imp... by sebsito on Sunday January 05, 2020 @07:04AM (#21960912)
Critique doesn’t have to be peaceful to be constructive
Re:No nuances, just buggy code (was: related to Spinlock imp... by speedplane on Sunday January 05, 2020 @04:28AM (#21960474)
> As long as Linus is blaming the work done and not the people behind it, that's fine.

Certainly, ad hominem attacks are worse than making substantive attacks, but is that really the standard we should judge it by? Instead of a sprawling thread of visceral, wouldn't it be better if he just explained the reasons why the approach is bad in a professional manner?

Writing like this just seems sloppy and non-professional. It's rambling and unclear. It could have been far more effective if written point-by-point with far less emotion.

Re:No nuances, just buggy code (was: related to Spinlock imp... by xelxebar on Sunday January 05, 2020 @06:41AM (#21960833)
Calling out non-professionalism and bashing a stranger's communication style are, perhaps ironically, nice examples of non-professional behavior.

I would answer your rhetorical questions with an emphatic "no." People's emotions and mental state are important. It's also important that we communicate, understand, and think about people's interior worlds.

Question for you: What else is Linus communicating with his writing style? Does he show that he cares? About what? What can we tell about his values? Are these values we want in a leader?

Sometimes it's good to take off the prescriptivist hat and try on Honest Curiosity.

Re:No nuances, just buggy code (was: related to Spinlock imp... by loopz on Sunday January 05, 2020 @09:35AM (#21961381)
If what you're measuring are random delays due to default scheduling and flawed code implementation, calling it "garbage" should give the author and others pause to think. In some cases, one need to establish a boundary, so as to not waste time and efforts into an endless discussion on flawed premises.

Explaining why and educating about the concepts, is the better approach, and was there as well. Short and concise would be best, while limiting the negative to exactly what need be pointed out: A spade is a spade after all.

If it stops people from developing "their own userspace spinlocks", it may even be kind of necessary to be quite direct.

Re:No nuances, just buggy code (was: related to Spinlock imp... by speedplane on Saturday January 11, 2020 @02:43AM (#22018733)
> Calling out non-professionalism and bashing a stranger's communication style are, perhaps ironically, nice examples of non-professional behavior.

I don't see how this is the case. One can critique a style of communication professionally just like any endeavor. I'm not "bashing" Linus, or even suggesting that he should be less honest. Just that there are far more effective ways to make the same point.

Re:No nuances, just buggy code (was: related to Spinlock imp... by diffeomorphism on Sunday January 05, 2020 @04:50AM (#21960539)
> yet an other entry in the "Linus bullies some poor coder into submission by insulting them until they just stop responding"

Has that ever happened? My impression was that he only ever takes a rough tone with high profile coders and is nice and polite to "poor coders". Also, he never insults them personally, but says that their code/argument is bad and that they are smart enough to know that already. Hence, they should stop making excuses and fix it already.

Re:No nuances, just buggy code (was: related to Spinlock imp... by simias on Sunday January 05, 2020 @05:02AM (#21960571)
I still think that this tone is counterproductive, but that might be personal preference. I hate working in an environment where I know I can end up on the receiving end of some public humiliation if I voice a dissenting opinion or make a mistake. That's how you end up with people censuring themselves and not pointing out when somebody is actually making a mistake because they don't want to suffer the abuse.

This is especially inexcusable coming from Linus because it's not like he needs to resort to these tactics to be heard or make an impression, he's one of the most respected software devs in existence (and for good reasons). You could remove all the abuse from his posts and you'd lose exactly nothing IMO.

But this discussion is hackneyed, I know many people love Linus' style and think it's perfectly acceptable and even a good thing, I'm just definitely not one of them.

Re:No nuances, just buggy code (was: related to Spinlock imp... by mritun on Sunday January 05, 2020 @09:05PM (#21965822)
Sigh

It’s sad that there are people who think calling garbage code garbage is inappropriate. What goes in their mind? Don’t they smell or call a smell a smell?

Re:No nuances, just buggy code (was: related to Spinlock imp... by TheFlyingFish on Tuesday January 07, 2020 @07:36PM (#21986972)
On at least one memorable occasion [0], he expressed surprise that the developer(s) responsible for some piece of code had survived to adulthood, considering they "were likely too stupid to find a tit to suck on" as a baby. I'm not super aware of the context here, but at first glance it doesn't appear to be a high-profile coder with lots of kernel experience that he's talking about.

[0] https://lkml.org/lkml/2012/7/6/495

Re:No nuances, just buggy code (was: related to Spinlock imp... by flafla2 on Sunday January 05, 2020 @02:54AM (#21960216)
I disagree with this sentiment. Linus' answer not only describes the immediate bug, but also gives enough detail and context that other, similar potential bugs related to the scheduler may be avoided after having read the entire post. Also I don't think Linus is being egregiously impolite in his post; he isn't calling the author of the post garbage. Calling the code garbage is not a personal affront, but an objective statement to dissuade others from being misled.

If this was a truly idiotic / trivial mistake I doubt Linus would put much thought or time into such a long post. I also think that if you are going to write a blog post, you are implicitly supposing a place of authority and therefore opening yourself to criticisms. In other words, writing a blog post that is incorrect (in this case, very incorrect) is actively harmful as it misleads others, and it is important to call out wrong posts when necessary. I've posted dumb advice with a know-it-all voice before too (see [1] for an embarrassing HN comment) and I am not at all angry/annoyed that I was similarly called out.

[1] https://news.ycombinator.com/item?id=20017832 (edit: wrong link)

Re:No nuances, just buggy code (was: related to Spinlock imp... by thenewnewguy on Sunday January 05, 2020 @02:45AM (#21960198)
> No need for calling code "garbage."

In my opinion calling the code garbage is much nicer than "The author of that post has a common misconception", which sounds like a passive-aggressive way to call someone dumb. Everyone writes bad/'garbage' code once in awhile.

Re:No nuances, just buggy code (was: related to Spinlock imp... by 0xBA5ED on Sunday January 05, 2020 @02:56AM (#21960220)
>"The author of that post has a common misconception", which sounds like a passive-aggressive way to call someone dumb

Not at all. It's a polite way to say they're ignorant of a particular thing. It would be rather insecure of them to read into it and think they're being called dumb across the board.

Re:No nuances, just buggy code (was: related to Spinlock imp... by csande17 on Sunday January 05, 2020 @03:13AM (#21960265)
When you say "the code is bad/wrong/garbage", that's a statement about the code. It gives the person who wrote it an out: they can say "Oh, right, I totally knew that, just slipped my mind for a second", or "This is why I shouldn't write blog posts about mutexes at 3 AM" or something. I've certainly written garbage code at times, and you probably have too -- it doesn't mean you're dumb or you don't know things.

When you say "the person who wrote this code has a common misconception", that's a statement about the person. You've jumped to a conclusion about the reason the person wrote the bad code. You're telling the person to accept that they don't know as much about mutexes as you, that they're ignorant, that they're a worse programmer (albeit in a fairly narrow category).

This is why I think GP's wording comes off worse even though it's superficially more polite.

Re:No nuances, just buggy code (was: related to Spinlock imp... by kelnos on Sunday January 05, 2020 @04:46AM (#21960526)
I get where you're going with that, but I would much rather someone tell me I hold a common misconception instead of saying my code is garbage. As much as the ideal is to remember that you are not your work, I still feel that my work reflects on me and my intelligence.

Giving someone an out is a great thing to do, especially for people for whom saving face is important. But I don't think "this code is garbage" does that. Something like, "that code is measuring timing incorrectly because X", conveys the same information without being inflammatory. "Garbage" is a value judgment, while just pointing out that it's doing something incorrectly is merely stating a fact.

Re:No nuances, just buggy code (was: related to Spinlock imp... by swfsql on Sunday January 05, 2020 @08:14AM (#21961113)
I'd appreciate if "this code is garbage" was at the end, so it would be (and feel more like) a conclusion.

Saying that stuff at the beginning only clutters the reasoning, as one should not "just believe" that that code was "indeed garbage", just because he said so.

Re:No nuances, just buggy code (was: related to Spinlock imp... by kelnos on Monday January 13, 2020 @07:27PM (#22040430)
That's a fair point, and moving it to the end would likely make the whole thing read better overall, but really... it's just not necessary to include it at all. It doesn't add anything to the discussion or critique, and can only serve to detract, so why bother?
Re:No nuances, just buggy code (was: related to Spinlock imp... by 0xBA5ED on Sunday January 05, 2020 @03:30AM (#21960312)
On the other hand, I wouldn't get offended if someone said a piece of my code indicated I was ignorant of something. If I was ignorant, I'd fess up to it no problem. Or if I had reasons for intentionally doing it a different way, I'd share and let someone school me if they had a point on why I was wrong. Ego sensitivity only causes problems. It never solves them.

Additionally, _sometimes_ offering someone an out to save their ego actually does them a disservice.

Re:No nuances, just buggy code (was: related to Spinlock imp... by empath75 on Sunday January 05, 2020 @11:47AM (#21962113)
You all are involved in like a 100 comment thread about his tone rather than the content, so that should maybe suggest that he didn’t get his point across well.
Re:No nuances, just buggy code (was: related to Spinlock imp... by nemetroid on Sunday January 05, 2020 @06:20AM (#21960766)
This is all in response to a blog post titled ”Measuring mutexes, spinlocks and how bad the Linux scheduler really is”. Based on the content and tone of that post, I think Linus’s tone is fair.
Re:No nuances, just buggy code (was: related to Spinlock imp... by kbumsik on Sunday January 05, 2020 @02:11AM (#21960119)
I'm favor of Linus version. They are not the same message to me. He clearly explains what really would happen behind the scene.
Re:No nuances, just buggy code (was: related to Spinlock imp... by bryal on Sunday January 05, 2020 @06:58AM (#21960890)
He probably just didn't take very kindly to the Linux scheduler being called "bad" in the blog post, when tons of people have spent an immense amount of time on it, and there are in fact good reasons for it behaving the way it does. If I were in the same seat, I'd be pretty stingy with the politeness as well.
Re:No nuances, just buggy code (was: related to Spinlock imp... by Dylan16807 on Sunday January 05, 2020 @03:12AM (#21960259)
> The possibility of your time slice ending skews all the time measurements, for example."

If you were forced to summarize the entire first third of the email into ten words, that might be valid. As-is, it's way too short to be a proper explanation. It's more of a reminder note. If someone doesn't know exactly what you mean at a single glance, it's useless. Linus has an actual explanation in his email.

Re:No nuances, just buggy code (was: related to Spinlock imp... by emily-c on Sunday January 05, 2020 @02:57AM (#21960223)
It's important to realize that you are not your code. Linus' reply comes off as passionate but he clearly cares enough to write such a detailed response.
Re:No nuances, just buggy code (was: related to Spinlock imp... by rdiddly on Sunday January 05, 2020 @03:18AM (#21960280)
At least it's not "total fucking braindamaged garbage." Progress?
Re:No nuances, just buggy code (was: related to Spinlock imp... by mda on Sunday January 05, 2020 @06:54AM (#21960876)
Your version lacks depth and I appreciate Linus's response.

Imo, he can call something garbage if the mentioned garbage makes false and bold claims about his and contributors decades of work.

Re:No nuances, just buggy code (was: related to Spinlock imp... by kstenerud on Sunday January 05, 2020 @03:06AM (#21960242)
Yes, Linus can still be abrasive, but he's gotten a LOT better than he was before his road to Damascus moment.
Re:No nuances, just buggy code (was: related to Spinlock imp... by tyingq on Sunday January 05, 2020 @06:32AM (#21960803)
I immediately thought of his lkml email where he reflected on this kind of thing: https://lore.kernel.org/lkml/CA+55aFy+Hv9O5citAawS+mVZO+ywCK...
Re:No nuances, just buggy code (was: related to Spinlock imp... by SergeAx on Sunday January 05, 2020 @02:43AM (#21960196)
In CS "garbage" has a bit different sounding, like in "garbage collector". Nonetheless, original poster started it, writing an article "Why Linux scheduler is bad". Next time he'll see it coming.

By the way, Linus' answer is much more informative than yours. I got a lot of useful insights from it and had fun just reading his lively language.

Re:No nuances, just buggy code (was: related to Spinlock imp... by kelnos on Sunday January 05, 2020 @04:48AM (#21960531)
> In CS "garbage" has a bit different sounding, like in "garbage collector".

It's a bit disingenuous to suggest that Torvalds meant it in that sense, though. He very obviously meant it in the sense of a piece of trash that should be thrown into a trash bin.

Re:No nuances, just buggy code (was: related to Spinlock imp... by SergeAx on Sunday January 05, 2020 @05:15AM (#21960597)
Or a piece of code that doesn't do anything useful or meaningful and may be skipped by compiler as well.
Re:No nuances, just buggy code (was: related to Spinlock imp... by loopz on Sunday January 05, 2020 @09:42AM (#21961403)
Compiler warning: Sourcecode classified as "garbage". Replaced with NOP for user protection.
Re:No nuances, just buggy code (was: related to Spinlock imp... by clarry on Sunday January 05, 2020 @04:43PM (#21964346)
Garbage code sounds like a fine new class of undefined behavior to add to the next C standard. You just need to teach ubsan to understand it.
Re:No nuances, just buggy code (was: related to Spinlock imp... by kelnos on Monday January 13, 2020 @07:26PM (#22040416)
No, he very clearly meant the definition I suggested.

(Also I've never heard of dead code referred to as "garbage code".)

Re:No nuances, just buggy code (was: related to Spinlock imp... by buzzkillington on Sunday January 05, 2020 @02:37AM (#21960179)
>Boom. Roughly the same message. Most people will get the same amount of edification from this as Linus' original letter. You could go in to more detail if you want but it's not really necessary. Smart people will figure it out if you just point out the general shape of the error. No need for calling code "garbage."

People should be shamed for being ignorant. It stops ignorance from spreading.

Re:No nuances, just buggy code (was: related to Spinlock imp... by dochtman on Sunday January 05, 2020 @02:42AM (#21960191)
I guess we should shame you for being ignorant about human beings and the value of being kind. There are plenty of ways to point out ignorance without being unkind (and the grandfather comment is a nice attempt).
Re:No nuances, just buggy code (was: related to Spinlock imp... by buzzkillington on Sunday January 05, 2020 @02:45AM (#21960202)
You just did, and got to pretend you didn't.
Re:No nuances, just buggy code (was: related to Spinlock imp... by simias on Sunday January 05, 2020 @02:42AM (#21960193)
Ignorance is the lack of knowledge, it doesn't "spread" like a disease. Misconceptions can, but without the original author's mistakes we wouldn't have this rebuttal by a very knowledgeable actor, so overall this is a net positive including for you and me.
Re:No nuances, just buggy code (was: related to Spinlock imp... by celticmusic on Sunday January 05, 2020 @05:47AM (#21960673)
misconception is a form of ignorance.
Re:No nuances, just buggy code (was: related to Spinlock imp... by simias on Sunday January 05, 2020 @06:21AM (#21960769)
And so is not reading the second half of comments.
Re:No nuances, just buggy code (was: related to Spinlock imp... by celticmusic on Sunday January 05, 2020 @09:14AM (#21961318)
Your "correction" literally explained the comment it was correcting as being true.

reacting in a haughty manner doesn't stop you from being wrong, it just makes you a dick.