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.
This commit is contained in:
parent
07107de9bc
commit
e8fdcfb57a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=97079
@ -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
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -258,16 +258,21 @@ extern int mtx_pool_valid;
|
||||
_mtx_lock_spin_flags((m), (opts), LOCK_FILE, LOCK_LINE)
|
||||
#define mtx_unlock_spin_flags(m, opts) \
|
||||
_mtx_unlock_spin_flags((m), (opts), LOCK_FILE, LOCK_LINE)
|
||||
#else
|
||||
#else /* LOCK_DEBUG == 0 */
|
||||
#define mtx_lock_flags(m, opts) \
|
||||
_get_sleep_lock((m), curthread, (opts), LOCK_FILE, LOCK_LINE)
|
||||
#define mtx_unlock_flags(m, opts) \
|
||||
_rel_sleep_lock((m), curthread, (opts), LOCK_FILE, LOCK_LINE)
|
||||
#ifdef SMP
|
||||
#define mtx_lock_spin_flags(m, opts) \
|
||||
_get_spin_lock((m), curthread, (opts), LOCK_FILE, LOCK_LINE)
|
||||
#define mtx_unlock_spin_flags(m, opts) \
|
||||
_rel_spin_lock((m))
|
||||
#endif
|
||||
#else /* SMP */
|
||||
#define mtx_lock_spin_flags(m, opts) critical_enter()
|
||||
#define mtx_unlock_spin_flags(m, opts) critical_exit()
|
||||
#endif /* SMP */
|
||||
#endif /* LOCK_DEBUG */
|
||||
|
||||
#define mtx_trylock_flags(m, opts) \
|
||||
_mtx_trylock((m), (opts), LOCK_FILE, LOCK_LINE)
|
||||
|
Loading…
Reference in New Issue
Block a user