175 points · by r4um · 5y ago · 83 comments
Regardless, from the commit message:
> I didn't manage to come up with a reproducer in test environment, and the problem can't be reproduced after rebooting.
I've seen unit tests that try to reproduce race conditions. They're naive mirrors of the code that break as soon as you even think about changing the implementation. They're kind of pointless.
They also run with sanitisers which can detect races and undefined behaviour.
And really good tooling also does formal verification to try and find any codepaths or inputs that could lead to an assertion failure.
I think any of the above 3 things would have had a reasonable chance of catching this issue.
Basically what used to be known as alpha/beta testing. Seems like there's more automated testing these days.
I work on a smaller piece of software with many automated tests that is significantly less reliable. I wonder if there's some lessons there. Another interesting tidbit is that our tests break a lot as well.
In "The Olde Days" many a pieces of complex/reliable software was written without a single unit test or any automated test for that matter. Sure, some of it had bugs, maybe even nasty bugs, but so does most software today. Have we made progress? maybe.
But there’s lots of code out there which doesn’t (or can’t) have a dedicated owner in the same kind of way. I had an issue opened on one of my GitHub projects the other day. I’m the sole maintainer of this project, the code is fiendishly complex and it’s working without any changes for about 18 months. Somebody found a bug! But after 18 months I’ve forgotten the mental context I had while writing that code - so I was terrified I’d break something else while fixing that problem. But I had an extensive test suite to fall back on. So when I fixed the bug and the existing tests all passed, I had the confidence to publish a new version. (And of course, I added the bug’s repro to the test suite for next time).
Lots of projects need guard rails like this. Maybe they’re solo projects. Or maybe there’s a lot of churn in the team. Sometimes there’s just more code than there are engineers to keep track of everything, so people are bouncing around a lot and don’t build much expertise in a single area. For the long tail of software, I’m pretty confident in saying unit tests have dramatically improved reliability beyond the standard we had a couple of decades ago. Have they made us lazier too? Maybe! But in my book they’re definitely a win on the whole.
…but it’s in the commit message, which is basically the same as a comment.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...
I love it when people put this level of detail into their commit messages, but this technique has one weak spot I don't know what to do about: if someone makes a change that confuses git's semantic heuristics - rename a function, split a file into two, etc. (or maybe all of them in a single commit), it creates a boundary for blame/log-trace that's hard to bridge.
But then, maybe I'm just not clever enough with git log -L ...
But if you think about the implications of this strangeness, it can be equally interpreted as "Linus is playing a dangerous game" or "maybe we've kind of exaggerated the importance of unit tests, seeing Linux is doing fine".
Linux doesn't seem to stand out as exceptionally buggy. It has bugs, but then so does every project that's unit tested.
In theory they should still be useful, but in practice perhaps not.
There is nothing positive in forfeiting principles of good software engineering in the name of falsely perceived imbalance of stakes in the project. Instead of falling back on the biggest beneficiaries of the project for testing, we should have a participation model that welcomes contributions and improvements at all stages of development.
I've contributed to the kernel multiple times over the last few years and it was always a pain to some degree. Sometimes due to outdated contribution model, sometimes because of maintainer's personal preferences and allegiances.
Sadly current kernel dev culture still promotes exclusion and building walls instead of reducing tension and removing barriers for entry.
The result is never as good as it could be.
While the GNU/Linux was 20 years ahead, it's now more than 10 years late.
Also relevant: https://www.usenix.org/system/files/1311_05-08_mickens.pdf
> This is not the world of the systems hacker. When you debug a distributed system or an OS kernel, you do it Texas-style. You gather some mean, stoic people, people who have seen things die, and you get some primitive tools, like a compass and a rucksack and a stick that’s pointed on one end, and you walk into the wilderness and you look for trouble, possibly while using chewing tobacco. As a systems hacker, you must be pre-pared to do savage things, unspeakable things, to kill runaway threads with your bare hands, to write directly to network ports using telnet and an old copy of an RFC that you found in the Vatican. When you debug systems code, there are no high-level debates about font choices and the best kind of turquoise, because this is the Old Testament, an angry and monochro-matic world, and it doesn’t matter whether your Arial is Bold or Condensed when people are covered in boils and pestilence and Egyptian pharaoh oppression. HCI people discover bugs by receiving a concerned email from their therapist. Systems people discover bugs by waking up and discovering that their first-born children are missing and “ETIMEDOUT ” has been written in blood on the wall.
Using email for development isn't the 80s. It is very streamlined and built into the Git code itself and mail clients that are actively maintained like Mutt. Just because you can't imagine what life would be like without Gmail doesn't mean that these maintainers are less efficient and antiquated than you are.
> Coding standards based on old tty terminals
Don't even know what this means. What coding standard is based on old TTY terminals? TTY is part of Linux.
> No unit testing
Linux is the most widely used OS in enterprise. The internet runs on Linux. If you want unit tests for everyone then start an open source project to do this, or complain about the enterprises that aren't testing.
> Toxic leaders
Who is toxic? I love Linus's approach. It has allowed him to get things done without toxic people in the community trying to social engineer their way into destroying something good.
I'm guessing they're trying to poke fun at people who care about your code being too wide, and hard to read?
(But, while I no longer stick to a strict 80 column limit, like I used to, wide lines in code sucks. A proud mutt using systems engineer.)
You assume that there are not other tools to submit code and participate in discussion. That's obviously not true. Also the argument that "it is supported with git" is just a non-argument.
> Don't even know what this means. What coding standard is based on old TTY terminals? TTY is part of Linux.
You obviously don't know indeed. 80 lines comes from old teletype writers: http://www.navy-radio.com/tty.htm
And even Linus disagreed recently (http://lkml.iu.edu/hypermail/linux/kernel/2005.3/08168.html) but the limit was only increased to 100 columns. So yeah.
> Linux is the most widely used OS in enterprise. The internet runs on Linux.
And?
> If you want unit tests for everyone then start an open source project to do this, or complain about the enterprises that aren't testing.
That's just arguing from a position of power. There is an open source project by the way, named kunit, but it's obviously left as an afterthought. Testing is left to "community testing" which is just a way of saying "compile the whole thing, test the whole thing, let's wish somebody caught most bugs", which is just the naive way of doing things before automated testing became popular in the early 2000s.
> Who is toxic? I love Linus's approach. It has allowed him to get things done without toxic people in the community trying to social engineer their way into destroying something good.
There are tons of other successful open source projects that do have to rely on base insults and abuse. The fact that the way the Linux kernel hasn't changed a bit for 30 years just shows how much its community is intolerant to ideas.
“There are two hard things in programming: naming things, cache invalidation, and off-by-one-errors.”
And once you're no longer afraid of software, but instead an active creator of software, it's much cheaper and safer to instead employ some open source developers to take care of maintenance for your stuff. The old school enterprise way would have been to pay IBM, Red Hat, Oracle, whoever, millions and tens of millions of dollars in support for Cover-Your-A** type policies set by middle managers.
FAANG & co. instead hire developers for this maintenance, and guess what, once you hire these people, they can do other things for you, because they're generally smart people (and also motivated, can work without supervision, etc.).
"The Kernel & Operating System team at Twitter is responsible for shipping the Linux kernel and OS versions on which all of Twitter’s services run. Our job is to ensure the safe, reliable, fast, and efficient operation of the lowest levels of the Twitter software stack! We actively contribute many of our fixes upstream and are active members of the Linux OSS community."
[1]https://careers.twitter.com/en/work-for-twitter/202101/005c4...
I couldn't really find there are more in the team.
I had similar problem before, and I didn't even notice that the cache was not cleared and had worked on pointless hypothesis until a coworker pointed out that there was a case where the kernel didn't evict the page cache. It's very hard to even detect that problem.
Twitter's Engineering blog has several interesting posts recently btw. Kudos to them.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...
"Doctor, when I do [x] it hurts"
"Then stop doing that"
approach
Same here, but luckily I started reading the article expecting that. Primarily because:
> The article requires some prerequisite knowledge about Linux kernel memory management subsystem.
Oh how I wish all articles had this sort of disclaimer.
Sadly I have no kernel hacking skills, don’t even know what a dentry is. Kudos to the author.
My issue happened after stress-testing Kubernetes by repeatedly starting and stopping many containers. So over time there could be tens of millions of files bind-mounted.
OBJS ACTIVE USE OBJ SIZE SLABS OBJ/SLAB CACHE SIZE NAME
534740452 533096794 99% 0.03K 4312423 124 17249692K kmalloc-32
32734926 23946797 73% 0.19K 1558806 21 6235224K dentry
86560 86558 99% 64.00K 86560 1 5539840K kmalloc-65536
2124646 1994340 93% 2.00K 1062323 2 4249292K kmalloc-2048
1013664 1013606 99% 4.00K 1013664 1 4054656K kmalloc-4096
14592544 11935392 81% 0.12K 456017 32 1824068K kmalloc-128
1300528 1158942 89% 1.00K 325132 4 1300528K kmalloc-1024