summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2010-04-20 15:16:27 -0700
committerBrian Behlendorf <[email protected]>2010-04-22 12:28:19 -0700
commitef6c1368848f364ac08ccba60bb88010548d9930 (patch)
treeeea7bfeee70d3a15a486dba8df42b3aded3b3812
parent8934764e6049d1eebae3eca8af99b8ee7140c0ab (diff)
Disable rw_tryupgrade() for newer kernels
For kernels using the CONFIG_RWSEM_GENERIC_SPINLOCK implementation nothing has changed. But if your kernel is building with arch specific rwsems rw_tryupgrade() has been disabled until it can be implemented correctly. In particular, the x86 implementation now leverages atomic primatives for serialization rather than spinlocks. So to get this working again it will need to be implemented as a cmpxchg for x86 and likely something similiar for other arches we are interested in. For now it's safest to simply disable it.
-rw-r--r--include/sys/rwlock.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/include/sys/rwlock.h b/include/sys/rwlock.h
index 89fdfa537..0fc8d24f7 100644
--- a/include/sys/rwlock.h
+++ b/include/sys/rwlock.h
@@ -70,7 +70,7 @@ extern int __down_write_trylock_locked(struct rw_semaphore *);
*/
# if defined(_I386_RWSEM_H) || defined(_ASM_X86_RWSEM_H)
# define RW_COUNT(rwp) ((SEM(rwp)->count < 0) ? (-1) : \
- (SEM(rwp)->count & RWSEM_ACTIVE_MASK))
+ (SEM(rwp)->count & RWSEM_ACTIVE_MASK))
# else
# define RW_COUNT(rwp) (SEM(rwp)->count & RWSEM_ACTIVE_MASK)
# endif
@@ -225,6 +225,7 @@ RW_LOCK_HELD(krwlock_t *rwp)
downgrade_write(SEM(rwp)); \
})
+#if defined(CONFIG_RWSEM_GENERIC_SPINLOCK)
#define rw_tryupgrade(rwp) \
({ \
unsigned long _flags_; \
@@ -239,6 +240,14 @@ RW_LOCK_HELD(krwlock_t *rwp)
spin_unlock_irqrestore(&SEM(rwp)->wait_lock, _flags_); \
_rc_; \
})
+#else
+/*
+ * This can be done correctly but for each supported arch we will need
+ * a custom cmpxchg() to atomically check and promote the rwsem. That's
+ * not worth the trouble for now so rw_tryupgrade() will always fail.
+ */
+#define rw_tryupgrade(rwp) ({ 0; })
+#endif
int spl_rw_init(void);
void spl_rw_fini(void);