diff options
author | Gunnar Beutner <[email protected]> | 2011-10-18 02:54:35 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2011-10-19 09:58:57 -0700 |
commit | 66cdc93b8c030db70a50563ac26f02301dde30ff (patch) | |
tree | 06d1ddd26f802d91088e2aa0c0d0fcbafe8912e4 | |
parent | 3160d4f56bf35492e9c400094f8c1ff2066d4459 (diff) |
Remove the spinlocks for mutex_enter()/mutex_exit()
The m_owner variable is protected by the mutex itself. Reading the variable
is guaranteed to be atomic (due to it being a word-sized reference) and
ACCESS_ONCE() takes care of read cache effects.
Signed-off-by: Brian Behlendorf <[email protected]>
-rw-r--r-- | include/sys/mutex.h | 28 |
1 files changed, 1 insertions, 27 deletions
diff --git a/include/sys/mutex.h b/include/sys/mutex.h index c55104a41..21f161cfb 100644 --- a/include/sys/mutex.h +++ b/include/sys/mutex.h @@ -103,45 +103,19 @@ extern int spl_mutex_spin_max(void); #define MUTEX(mp) ((struct mutex *)(mp)) -static inline kthread_t * -spl_mutex_get_owner(kmutex_t *mp) -{ - return mp->m_owner; -} - static inline void spl_mutex_set_owner(kmutex_t *mp) { - unsigned long flags; - - spin_lock_irqsave(&MUTEX(mp)->wait_lock, flags); mp->m_owner = current; - spin_unlock_irqrestore(&MUTEX(mp)->wait_lock, flags); } static inline void spl_mutex_clear_owner(kmutex_t *mp) { - unsigned long flags; - - spin_lock_irqsave(&MUTEX(mp)->wait_lock, flags); mp->m_owner = NULL; - spin_unlock_irqrestore(&MUTEX(mp)->wait_lock, flags); -} - -static inline kthread_t * -mutex_owner(kmutex_t *mp) -{ - unsigned long flags; - kthread_t *owner; - - spin_lock_irqsave(&MUTEX(mp)->wait_lock, flags); - owner = spl_mutex_get_owner(mp); - spin_unlock_irqrestore(&MUTEX(mp)->wait_lock, flags); - - return owner; } +#define mutex_owner(mp) (ACCESS_ONCE((mp)->m_owner)) #define mutex_owned(mp) (mutex_owner(mp) == current) #define MUTEX_HELD(mp) mutex_owned(mp) #define MUTEX_NOT_HELD(mp) (!MUTEX_HELD(mp)) |