rwsem use kernel provided owner when possible
If CONFIG_RWSEM_SPIN_ON_OWNER is defined, rw_semaphore will have an owner field, so we don't need our own. Signed-off-by: Chunwei Chen <tuxoko@gmail.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Issue #473
This commit is contained in:
parent
4f8e643afe
commit
a00b3eb58f
|
@ -40,29 +40,47 @@ typedef enum {
|
||||||
RW_READER = 2
|
RW_READER = 2
|
||||||
} krw_t;
|
} krw_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If CONFIG_RWSEM_SPIN_ON_OWNER is defined, rw_semaphore will have an owner
|
||||||
|
* field, so we don't need our own.
|
||||||
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct rw_semaphore rw_rwlock;
|
struct rw_semaphore rw_rwlock;
|
||||||
|
#ifndef CONFIG_RWSEM_SPIN_ON_OWNER
|
||||||
kthread_t *rw_owner;
|
kthread_t *rw_owner;
|
||||||
|
#endif
|
||||||
} krwlock_t;
|
} krwlock_t;
|
||||||
|
|
||||||
#define SEM(rwp) ((struct rw_semaphore *)(rwp))
|
#define SEM(rwp) (&(rwp)->rw_rwlock)
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
spl_rw_set_owner(krwlock_t *rwp)
|
spl_rw_set_owner(krwlock_t *rwp)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* If CONFIG_RWSEM_SPIN_ON_OWNER is defined, down_write, up_write,
|
||||||
|
* downgrade_write and __init_rwsem will set/clear owner for us.
|
||||||
|
*/
|
||||||
|
#ifndef CONFIG_RWSEM_SPIN_ON_OWNER
|
||||||
rwp->rw_owner = current;
|
rwp->rw_owner = current;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
spl_rw_clear_owner(krwlock_t *rwp)
|
spl_rw_clear_owner(krwlock_t *rwp)
|
||||||
{
|
{
|
||||||
|
#ifndef CONFIG_RWSEM_SPIN_ON_OWNER
|
||||||
rwp->rw_owner = NULL;
|
rwp->rw_owner = NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline kthread_t *
|
static inline kthread_t *
|
||||||
rw_owner(krwlock_t *rwp)
|
rw_owner(krwlock_t *rwp)
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
|
||||||
|
return SEM(rwp)->owner;
|
||||||
|
#else
|
||||||
return rwp->rw_owner;
|
return rwp->rw_owner;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
|
@ -153,6 +171,9 @@ RW_LOCK_HELD(krwlock_t *rwp)
|
||||||
})
|
})
|
||||||
|
|
||||||
#if defined(CONFIG_RWSEM_GENERIC_SPINLOCK)
|
#if defined(CONFIG_RWSEM_GENERIC_SPINLOCK)
|
||||||
|
#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
|
||||||
|
#error spinlock rwsem should not have spin on owner
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* For the generic implementations of rw-semaphores the following is
|
* For the generic implementations of rw-semaphores the following is
|
||||||
* true. If your semaphore implementation internally represents the
|
* true. If your semaphore implementation internally represents the
|
||||||
|
|
Loading…
Reference in New Issue