]> granicus.if.org Git - zfs/commitdiff
Remove the spinlocks for mutex_enter()/mutex_exit()
authorGunnar Beutner <gunnar@beutner.name>
Tue, 18 Oct 2011 00:54:35 +0000 (02:54 +0200)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 19 Oct 2011 16:58:57 +0000 (09:58 -0700)
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 <behlendorf1@llnl.gov>
include/sys/mutex.h

index c55104a417ac16acdcbbf58f81562fed86c207b9..21f161cfbe1cd7e0b37dcaff0b2d732ef2a458e3 100644 (file)
@@ -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))