aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2010-05-20 14:20:34 -0700
committerBrian Behlendorf <[email protected]>2010-05-20 14:20:34 -0700
commit32f5faff694b30c7992181057e3028571f834d41 (patch)
tree6feaf6159c82e3dde397e49954e5c370ec699204 /module
parent23d91792efdc42779605025e15b03d63226cff6a (diff)
Simplify rwlock implementation.
Remove RW_COUNT() from the rwlock implementation. The idea was that it could be used as a generic wrapper for getting at the internal state of a rwlock. While a good idea it's proven problematic to keep it correct for multiple archs and internal implementation changes. In short it hasn't been worth the trouble. With that and simplicity in mind things have been updated to use the rwsem_is_locked() function instead of RW_COUNT for the RW_*_HELD() functions. As for rw_upgrade() it remains only implemented for the generic rwsem implemenation. It remains to be determined if its worth the effort of adding a custom implementation for each arch.
Diffstat (limited to 'module')
-rw-r--r--module/splat/splat-rwlock.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/module/splat/splat-rwlock.c b/module/splat/splat-rwlock.c
index 6b2ecbe82..dc560c2b9 100644
--- a/module/splat/splat-rwlock.c
+++ b/module/splat/splat-rwlock.c
@@ -571,7 +571,7 @@ static int
splat_rwlock_test6(struct file *file, void *arg)
{
rw_priv_t *rwp;
- int rc = -EINVAL;
+ int rc;
rwp = (rw_priv_t *)kmalloc(sizeof(*rwp), GFP_KERNEL);
if (rwp == NULL)
@@ -584,15 +584,18 @@ splat_rwlock_test6(struct file *file, void *arg)
splat_vprint(file, SPLAT_RWLOCK_TEST6_NAME,
"rwlock should be read lock: %d\n",
RW_READ_HELD(&rwp->rw_rwlock));
+ rc = -ENOLCK;
goto out;
}
- /* With one reader upgrade should never fail */
+#if defined(CONFIG_RWSEM_GENERIC_SPINLOCK)
+ /* With one reader upgrade should never fail. */
rc = rw_tryupgrade(&rwp->rw_rwlock);
if (!rc) {
splat_vprint(file, SPLAT_RWLOCK_TEST6_NAME,
- "rwlock contended preventing upgrade: %ld\n",
- (long int)RW_COUNT(&rwp->rw_rwlock));
+ "rwlock failed upgrade from reader: %d\n",
+ RW_READ_HELD(&rwp->rw_rwlock));
+ rc = -ENOLCK;
goto out;
}
@@ -607,6 +610,11 @@ splat_rwlock_test6(struct file *file, void *arg)
rc = 0;
splat_vprint(file, SPLAT_RWLOCK_TEST6_NAME, "%s",
"rwlock properly upgraded\n");
+#else
+ rc = 0;
+ splat_vprint(file, SPLAT_RWLOCK_TEST6_NAME, "%s",
+ "rw_tryupgrade() is disabled for this arch\n");
+#endif
out:
rw_exit(&rwp->rw_rwlock);
rw_destroy(&rwp->rw_rwlock);