Zack's Kernel News
Zack's Kernel News
Zack Brown reports on: Doing the Two-Step, and Doing the Too-Much Step.
Doing the Two-Step
Sometimes developer conflicts are navigated with grace and poise. For example, Bart Van Assche recently invited public comment on something he'd been working on. Specifically, he pointed out that the Clang C compiler was capable of various compile-time tests – including multithreading safety tests – that could potentially identify bugs in source code. To demonstrate this, he posted a patch containing fixes for almost 900 files in the Linux kernel repository. His main question to the kernel developers was, should Clang's compile-time thread safety checks be enabled by default for the Linux kernel?
Threads and thread safety are pretty insane topics, very easy to get wrong, and very difficult to debug. Threading simply means that there are a bunch of programs all running at the same time (e.g., your web browser, your file editor, your video player, and of course, a giant build of the Linux kernel sucking up resources and making your movie skip frames). Modern operating systems run these threads "simultaneously" by switching between them so quickly that you never notice only one of them is ever actually running at a given moment. But any time a thread requests a bit of memory or some disk space or any other resource on the system, it needs to make sure that it and it alone has access to that resource, even though a thousand other threads may make a thousand similar requests before that one thread can finish using that resource. To solve this, there are many different types of "locks" including mutexes, spinlocks, and others, whose job is to prevent other threads from using a resource for the duration of time it's been claimed. Imagine trying to write kernel features; never forgetting to lock the resources you need at the times you need them, in the ways they need to be locked; and then freeing them up again afterwards. These Clang tests are a lifeline to help you get all that insanity right.
However, using Clang tests wouldn't be as easy as flipping a switch. The kernel sources themselves would need to be modified – not necessarily in terms of the code itself, but the code would need to be "annotated" to let Clang know when and how to do its checks. Annotation is fun! It's essentially a code comment that gives the compiler hints as to how to proceed. A lot of languages support it nowadays, but annotation in some form or other goes back to the early days of computers. So, suggesting using it in Linux is nothing new, although Bart's specific suggestion would involve adopting Clang's specific annotations wholesale throughout the source tree.
[...]
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Ubuntu Core 26 Offers Game-Changing Enterprise Features
Ubuntu Core 26 could be a game-changer for organizations looking for increased security and reliability.
-
AI Flooding the Linux Kernel Security Mailing List
AI is giving Linus Torvalds a headache, but not in the way you might think.
-
Top Priorities for Open Source Pros Seeking a New Job
Professional fulfillment tops the list, according to LPI report.
-
Container-Based Fedora Hummingbird Designed for Agent-First Builders
Fedora Hummingbird brings the same approach to the host OS as it does to containers to level up security.
-
Linux kernel Developers Considering a Kill Switch
With the rise of Linux vulnerabilities, the kernel developers are now considering adding a component that could help temporarily mitigate against them… in the form of a kill switch.
-
Fedora 44 Now Gaming Ready
The latest version of Fedora has been released with gaming support.
-
Manjaro 26.1 Preview Unveils New Features
The latest Manjaro 26.1 preview has been released with new desktop versions, a new kernel, and more.
-
Microsoft Issues Warning About Linux Vulnerability
The company behind Windows has released information about a flaw that affects millions of Linux systems.
-
Is AI Coming to Your Ubuntu Desktop?
According to the VP of Engineering at Canonical, AI could soon be added to the Ubuntu desktop distribution.
-
Framework Laptop 13 Pro Competes with the Best
Framework has released what might be considered the MacBook of Linux devices.
