diff options
author | davidxu <davidxu@FreeBSD.org> | 2008-04-03 11:49:20 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2008-04-03 11:49:20 +0000 |
commit | 6e5250730ed7b87efa7bf2a919eac62a6cd98b5c (patch) | |
tree | c90239dd61ef4381367ab2aafab8ae3e950ece6e /sys/kern/kern_umtx.c | |
parent | 42186e4f70062948edab3ed07b7d72488fb8de6b (diff) | |
download | FreeBSD-src-6e5250730ed7b87efa7bf2a919eac62a6cd98b5c.zip FreeBSD-src-6e5250730ed7b87efa7bf2a919eac62a6cd98b5c.tar.gz |
let umtxq_busy() only spin on mp machine. make function name
do_rwlock_unlock to be consistent with others.
Diffstat (limited to 'sys/kern/kern_umtx.c')
-rw-r--r-- | sys/kern/kern_umtx.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index 7da9a08..18ff562 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -324,14 +324,18 @@ umtxq_busy(struct umtx_key *key) uc = umtxq_getchain(key); mtx_assert(&uc->uc_lock, MA_OWNED); if (uc->uc_busy) { - int count = BUSY_SPINS; - if (count > 0) { - umtxq_unlock(key); - while (uc->uc_busy && --count > 0) - cpu_spinwait(); - umtxq_lock(key); - } - while (uc->uc_busy != 0) { +#ifdef SMP + if (smp_cpus > 1) { + int count = BUSY_SPINS; + if (count > 0) { + umtxq_unlock(key); + while (uc->uc_busy && --count > 0) + cpu_spinwait(); + umtxq_lock(key); + } + } +#endif + while (uc->uc_busy) { uc->uc_waiters++; msleep(uc, &uc->uc_lock, 0, "umtxqb", 0); uc->uc_waiters--; @@ -2604,7 +2608,7 @@ do_rw_wrlock2(struct thread *td, void *obj, struct timespec *timeout) } static int -do_rwlock_unlock(struct thread *td, struct urwlock *rwlock) +do_rw_unlock(struct thread *td, struct urwlock *rwlock) { struct umtx_q *uq; uint32_t flags; @@ -2896,7 +2900,7 @@ __umtx_op_rw_wrlock(struct thread *td, struct _umtx_op_args *uap) static int __umtx_op_rw_unlock(struct thread *td, struct _umtx_op_args *uap) { - return do_rwlock_unlock(td, uap->obj); + return do_rw_unlock(td, uap->obj); } typedef int (*_umtx_op_func)(struct thread *td, struct _umtx_op_args *uap); |