9 ms·
Tale of OpenBSD secure memory allocator internals – malloc(3)
- carapace 7y agoOpenBSD in C: A panic room made out of knives.
- chungy 7y agoI feel like either OpenBSD or NetBSD would probably make good candidates for experimenting with rewriting the operating system in Rust. They're small enough to make some significant inroads in rapid pace, but also general purpose enough to not be useless.
- renox 7y agoIf memory serves, NetBSD's strength is its portability.. So given the current state of Rust's portability, I doubt that they are very interested. As for OpenBSD, I wouldn't hold my breath: remember that Rust isn't the first 'safe' low level language but the others (Ada for example) didn't find success inside OpenBSD. That said development follow fashions, so who knows?
- chungy 7y agoMy own feelings didn't reflect that the upstream projects should, nor necessarily would, switch. I was thinking more in terms of a fork to research the avenue.
- pjmlp 7y agoBetter look at Genode OS and what they are doing with C++, Ada and SPARK integration, than hoping any UNIX clone will ever use anything else other than C.
- snvzz 7y agoAlways good to see that some systems still do some engineering. Linux has lost this. It got so complex that only small patches get in, so the hacks continue to stack up. OpenBSD does interesting stuff like this or pledge(2) and unveil(2). Dragonfly does interesting stuff like their concurrent lockfree/lockless servers approach instead of using kernel locks, and HAMMER2[0]. Genode[1][2] implements multiserver systems supporting many kernels including seL4, making good use of capabilities. [0]: https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/sys/vfs/hammer2/DESIGN https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/sys... [1]: https://www.genode.org https://www.genode.org [2]: https://www.genodians.org https://www.genodians.org
- burfog 7y agoLinux has plenty of engineering. Of course that doesn't mean identical features. Linux has a VFS with lockless path lookups. The push to get Linux running on machines like the SGI Altix, with at least 10240 cores running one shared instance of the kernel, has really helped with locking issues. Another factor has been the push for real-time performance, with and without choosing the option to make the kernel preemptable.
- snvzz 7y agoAnd all of this is based on hacks and ugly workarounds, due to the kernel being a monolithic design. When the kernel isn't monolithic, kernel preemption isn't necessary, or worth it[0]. Imagine if instead of the, I argue insane, complexity added by the fine-grained SMP locks and the unholy mess that is kernel preemption, the kernel had been split into separate processes, which maps to SMP cleanly. Actually, I don't have to imagine it, because that's what Dragonfly has been progressively doing since they forked FreeBSD, and what microkernel multiserver systems like Genode/seL4 or HelenOS are from the get-go. It turns out, despite having very little manpower (which is why they chose to focus on x86-64), Dragonfly has performance and scalability competitive to Linux today. Imagine if they had more people. I will not be too surprised when Dragonfly finally leaves Linux in the dust and people wonder how the hell, which is something I predict will happen. Linux hit a ceiling despite all the money thrown into it. Dragonfly hasn't yet. [0]: http://ts.csiro.au/publications/nicta_full_text/5859.pdf http://ts.csiro.au/publications/nicta_full_text/5859.pdf
- gigatexal 7y agoLet's have a HN style discussion of the article on the website and not a flame war.
- saagarjha 7y agoA bit of constructive criticism: it's nice when people do deep dives of components, but I think this one is too deep: it basically pastes all the code that is executed and then explains exactly what the code is doing, which isn't really that useful; I don't need to be told how to read C, as I can do so myself. And in fact, I think it's a bit counterproductive: I very quickly got lost in the minute details presented. What I really want is an overview of what the code does (and ideally, why) not how it does it.
- bsdb0y 7y agoFirst of all, Thank you for sharing your thoughts. I am beginner into this. And, yes, it is deep because OpenBSD malloc(3) has lots of features and I have tried to cover each and every line of code. So, I have shared all my learning and the process of how I learned. In future, if people want to learn anything that requires malloc(3) understanding they can refer to this. And, yes I have to paste the code otherwise it would be difficult to track the explanation and respective code. I have explained the following things: - What is the code doing - Reason on why is it doing that - tried to explain the developers' idea behind that code algorithm - tried to explain the mathematical calculations on the basis of sample code through the debugger And, the blog is for everyone, irrespective of ability to read C, or understanding of malloc(3) internals. If you got lost then please keep patience because for me it took exactly 30 days to understand, still, I am learning it. At least read the whole blog again and then if you want, you can make the remark as per your understanding. If you go through the whole blog, you will find out mailing lists and twitter links where the author discussed his queries and the reasons/ideas with the developer. Hope I cleared your queries, if you still have some doubts then please read the whole blog again, or you can also directly jump into the source code and learn it from there.