From 44253336b68e3b559861f6e69f72a1b4aaae18ec Mon Sep 17 00:00:00 2001 From: David Xu Date: Thu, 3 Apr 2008 11:49:20 +0000 Subject: [PATCH] let umtxq_busy() only spin on mp machine. make function name do_rwlock_unlock to be consistent with others. --- sys/kern/kern_umtx.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index 7da9a080721b..18ff562f5c1a 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); +#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); + } } - while (uc->uc_busy != 0) { +#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);