Weekly Edition Return to the Kernel page |
No more 24-bit atomic_t
The atomic_t type in the Linux kernel is a simple integer variable
with a set of operations which are guaranteed to be atomic without the need
for explicit locking. For years, atomic_t variables have operated
under the constraint that they can be expected to hold no more than 24
bits; this limitation was forced by the Sparc32 architecture, which used
the other eight bits to implement the atomic operations.
As of 2.6.3, this limitation no longer holds. This patch by Keith M Wesolowski has changed the Sparc32 implementation to a version (taken from the PA-RISC architecture) which provides full 32-bit atomic variables. The new implementation works by creating a small array (four entries) of spinlocks. When an operation is to be performed on an atomic variable, one of those spinlocks is chosen by a hash function; the code holds the given lock while manipulating the variable. The result is proper locking for atomic operations without doubling the size of every atomic_t in the system. The patch was quickly picked up and merged, and kernel programmers have one less strange limitation to worry about. (Log in to post comments)
No more 24-bit atomic_t Posted Feb 19, 2004 21:32 UTC (Thu) by xorbe (guest, #3165) [Link] "a small array (four entries) of spinlocks"4 spinlocks for the entire system's atomic variables? Helloooooooooo deadlock!
No more 24-bit atomic_t Posted Feb 20, 2004 20:39 UTC (Fri) by ptr (guest, #5885) [Link] Well, without digging deep, there should not be any (additional) dead locks, since always only up to one of the four locks is used per thread... Additionally, the atomicity dead lock is always the last. If the locking order was robust before, it will be after the change.
No more 24-bit atomic_t Posted Feb 21, 2004 4:09 UTC (Sat) by im14u2c (subscriber, #5246) [Link] Spinlocks disable preemption, right?
|
Copyright © 2004, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds
Powered by Rackspace Managed Hosting.