mtx: fix spin mutexes interaction with failed fcmpset

While doing so move recursion support down to the fallback routine.
This commit is contained in:
mjg 2017-02-20 19:08:36 +00:00
parent 368fd06ff3
commit 48e0ee172a
2 changed files with 11 additions and 6 deletions

View File

@ -696,6 +696,14 @@ _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t v, uintptr_t tid,
lock_delay_arg_init(&lda, &mtx_spin_delay);
m = mtxlock2mtx(c);
if (__predict_false(v == MTX_UNOWNED))
v = MTX_READ_VALUE(m);
if (__predict_false(v == tid)) {
m->mtx_recurse++;
return;
}
if (LOCK_LOG_TEST(&m->lock_object, opts))
CTR1(KTR_LOCK, "_mtx_lock_spin: %p spinning", m);
KTR_STATE1(KTR_SCHED, "thread", sched_tdname((struct thread *)tid),

View File

@ -223,12 +223,9 @@ void thread_lock_flags_(struct thread *, int, const char *, int);
uintptr_t _v = MTX_UNOWNED; \
\
spinlock_enter(); \
if (!_mtx_obtain_lock_fetch((mp), &_v, _tid)) { \
if (_v == _tid) \
(mp)->mtx_recurse++; \
else \
_mtx_lock_spin((mp), _v, _tid, (opts), (file), (line));\
} else \
if (!_mtx_obtain_lock_fetch((mp), &_v, _tid)) \
_mtx_lock_spin((mp), _v, _tid, (opts), (file), (line)); \
else \
LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(spin__acquire, \
mp, 0, 0, file, line); \
} while (0)