diff options
author | jhb <jhb@FreeBSD.org> | 2002-05-21 20:34:28 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2002-05-21 20:34:28 +0000 |
commit | fd74bc1d8e5662fd92475219e1328528de5e2ad4 (patch) | |
tree | 8dcf23b3a7bd10af4e49bb31cd51131fa53024fc /sys/kern | |
parent | 476ca0197fe439db32412d254212efdcc10bd9cf (diff) | |
download | FreeBSD-src-fd74bc1d8e5662fd92475219e1328528de5e2ad4.zip FreeBSD-src-fd74bc1d8e5662fd92475219e1328528de5e2ad4.tar.gz |
Optimize spin mutexes for UP kernels without debugging to just enter and
exit critical sections. We only contest on a spin mutex on an SMP kernel
running on an SMP machine.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_mutex.c | 8 | ||||
-rw-r--r-- | sys/kern/subr_turnstile.c | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index b0e3f30..2a98204 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -394,7 +394,11 @@ _mtx_lock_spin_flags(struct mtx *m, int opts, const char *file, int line) { MPASS(curthread != NULL); +#if defined(SMP) || LOCK_DEBUG > 0 _get_spin_lock(m, curthread, opts, file, line); +#else + critical_enter(); +#endif LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_recurse, file, line); WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); @@ -409,7 +413,11 @@ _mtx_unlock_spin_flags(struct mtx *m, int opts, const char *file, int line) WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file, line); +#if defined(SMP) || LOCK_DEBUG > 0 _rel_spin_lock(m); +#else + critical_exit(); +#endif } /* diff --git a/sys/kern/subr_turnstile.c b/sys/kern/subr_turnstile.c index b0e3f30..2a98204 100644 --- a/sys/kern/subr_turnstile.c +++ b/sys/kern/subr_turnstile.c @@ -394,7 +394,11 @@ _mtx_lock_spin_flags(struct mtx *m, int opts, const char *file, int line) { MPASS(curthread != NULL); +#if defined(SMP) || LOCK_DEBUG > 0 _get_spin_lock(m, curthread, opts, file, line); +#else + critical_enter(); +#endif LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_recurse, file, line); WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); @@ -409,7 +413,11 @@ _mtx_unlock_spin_flags(struct mtx *m, int opts, const char *file, int line) WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file, line); +#if defined(SMP) || LOCK_DEBUG > 0 _rel_spin_lock(m); +#else + critical_exit(); +#endif } /* |