Zack's Kernel News
Zack's Kernel News
![](/var/linux_magazin/storage/images/issues/2023/277/kernel-news/brown_zack.png/830938-1-eng-US/Brown_Zack.png_medium.png)
Zack Brown reports on improving spinlock efficiency and adding up a few extra bytes.
Improving Spinlock Efficiency
Alex Kogen, from Oracle, wanted to eke out a little more efficiency from spinlocks. Locks are part of any multitasking operating system – they make sure only one process can access any given system resource at a time. Spinlocks are locks that just loop around and around waiting for one process to let go of a resource so the next process can claim it. There are lots of different kinds of locks, depending on a ton of different special contexts. For example, an MCS lock is a particular type of spinlock named after the people who first described it: Mellor-Crummey and Scott.
In this case, Alex said, "In CNA [compact NUMA-aware], spinning threads are organized in two queues, a primary queue for threads running on the same node as the current lock holder, and a secondary queue for threads running on other nodes. After acquiring the MCS lock and before acquiring the spinlock, the MCS lock holder checks whether the next waiter in the primary queue (if it exists) is running on the same NUMA [non-uniform memory access] node. If it is not, that waiter is detached from the main queue and moved into the tail of the secondary queue. This way, we gradually filter the primary queue, leaving only waiters running on the same preferred NUMA node."
Alex was talking about having spinlocks be aware of the special context of the threads waiting for the resource they guard. Specifically, on systems with more than one CPU (which is pretty much all of them these days), threads on any CPU might be waiting for resources such as RAM on one specific CPU. But whenever a thread uses a resource on a different CPU from its own, access will be slower than a thread accessing that resource on its same CPU. Also, different CPUs may have RAM that's inherently faster or slower than RAM on another CPU. Those are called NUMA systems.
[...]
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.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.
-
SUSE Offers CentOS 7 Support with Liberty Linux Lite
SUSE's Liberty Linux support offering now includes CentOS 7, which means businesses won't be forced to migrate those servers for some time.
-
Ubuntu's App Center Finally Supports Local Installs Again
If you regularly download .deb files and would prefer a GUI method of installing, Ubuntu has your back.
-
AlmaLinux Now Supports Raspberry Pi 5
If you're looking to create with the Raspberry Pi 5 and want to use AlmaLinux as your OS, you're in luck because it's now possible.
-
Kubuntu Focus Releases New Iterations of Ir14 and Ir16 Laptops
If you're a fan of the Kubuntu Focus laptops or have been waiting for the right time to purchase one, that time might be now.
-
NixOS 24.05 Is Ready for Prime Time
The latest release of NixOS (Uakari) has arrived and offers its usual reproducible, declarative, and reliable goodness.
-
Linux Lite 7.0 Officially Released
Based on Ubuntu 24.04 and kernel 6.8, Linux Lite version 7 now offers more options than ever.
-
KaOS Linux 2024.05 Adds Bcachfs Support and More
With updates all around, KaOS Linux now includes support for the bcachefs file system.