mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
Use Linux atomic primitives by default.
Previously Solaris style atomic primitives were implemented simply by wrapping the desired operation in a global spinlock. This was easy to implement at the time when I wasn't 100% sure I could safely layer the Solaris atomic primatives on the Linux counterparts. It however was likely not good for performance. After more investigation however it does appear the Solaris primitives can be layered on Linux's fairly safely. The Linux atomic_t type really just wraps a long so we can simply cast the Solaris unsigned value to either a atomic_t or atomic64_t. The only lingering problem for both implementations is that Solaris provides no atomic read function. This means reading a 64-bit value on a 32-bit arch can (and will) result in word breaking. I was very concerned about this initially, but upon further reflection it is a limitation of the Solaris API. So really we are just being bug-for-bug compatible here. With this change the default implementation is layered on top of Linux atomic types. However, because we're assuming a lot about the internal implementation of those types I've made it easy to fall-back to the generic approach. Simply build with --enable-atomic_spinlocks if issues are encountered with the new implementation.
This commit is contained in:
@@ -32,9 +32,11 @@
|
||||
|
||||
#define DEBUG_SUBSYSTEM S_ATOMIC
|
||||
|
||||
#ifdef ATOMIC_SPINLOCK
|
||||
/* Global atomic lock declarations */
|
||||
spinlock_t atomic64_lock = SPIN_LOCK_UNLOCKED;
|
||||
spinlock_t atomic32_lock = SPIN_LOCK_UNLOCKED;
|
||||
spinlock_t atomic64_lock = SPIN_LOCK_UNLOCKED;
|
||||
|
||||
EXPORT_SYMBOL(atomic64_lock);
|
||||
EXPORT_SYMBOL(atomic32_lock);
|
||||
EXPORT_SYMBOL(atomic64_lock);
|
||||
#endif /* ATOMIC_SPINLOCK */
|
||||
|
||||
Reference in New Issue
Block a user