aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2009-10-30 10:55:25 -0700
committerBrian Behlendorf <[email protected]>2009-10-30 10:55:25 -0700
commit5e9b5d832b228b0628a61c9c1c9bf0b05d2fe122 (patch)
tree8dc52bf67d9cbd60a6bfc41e1156cf80b673126d /config
parent2b5adaf18fde25b963a9d21407773544f2cbed6f (diff)
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.
Diffstat (limited to 'config')
-rw-r--r--config/spl-build.m422
1 files changed, 22 insertions, 0 deletions
diff --git a/config/spl-build.m4 b/config/spl-build.m4
index e6a626108..15d10841b 100644
--- a/config/spl-build.m4
+++ b/config/spl-build.m4
@@ -25,6 +25,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
SPL_AC_DEBUG_KMEM
SPL_AC_DEBUG_KSTAT
SPL_AC_DEBUG_CALLB
+ SPL_AC_ATOMIC_SPINLOCK
SPL_AC_TYPE_UINTPTR_T
SPL_AC_TYPE_ATOMIC64_T
SPL_AC_3ARGS_INIT_WORK
@@ -303,6 +304,27 @@ AC_DEFUN([SPL_AC_DEBUG_CALLB], [
])
dnl #
+dnl # Use the atomic implemenation based on global spinlocks. This
+dnl # should never be needed, however it has been left in place as
+dnl # a fallback option in case problems are observed with directly
+dnl # mapping to the native Linux atomic operations.
+dnl #
+AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
+ AC_ARG_ENABLE([atomic-spinlocks],
+ [AS_HELP_STRING([--enable-atomic-spinlocks],
+ [Atomic types use spinlocks @<:@default=no@:>@])],
+ [],
+ [enable_atomic_spinlocks=no])
+
+ AS_IF([test "x$enable_atomic_spinlocks" = xyes],
+ [AC_DEFINE([ATOMIC_SPINLOCK], [1],
+ [Atomic types use spinlocks])])
+
+ AC_MSG_CHECKING([whether atomic types use spinlocks])
+ AC_MSG_RESULT([$enable_atomic_spinlocks])
+])
+
+dnl #
dnl # SPL_LINUX_CONFTEST
dnl #
AC_DEFUN([SPL_LINUX_CONFTEST], [