Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_mutex.c
Show First 20 Lines • Show All 581 Lines • ▼ Show 20 Lines | #ifdef KDTRACE_HOOKS | ||||
lda.spin_cnt++; | lda.spin_cnt++; | ||||
#endif | #endif | ||||
#ifdef ADAPTIVE_MUTEXES | #ifdef ADAPTIVE_MUTEXES | ||||
/* | /* | ||||
* If the owner is running on another CPU, spin until the | * If the owner is running on another CPU, spin until the | ||||
* owner stops running or the state of the lock changes. | * owner stops running or the state of the lock changes. | ||||
*/ | */ | ||||
owner = lv_mtx_owner(v); | owner = lv_mtx_owner(v); | ||||
if (TD_IS_RUNNING(owner)) { | if (__predict_true(m != &Giant) && TD_IS_RUNNING(owner)) { | ||||
if (LOCK_LOG_TEST(&m->lock_object, 0)) | if (LOCK_LOG_TEST(&m->lock_object, 0)) | ||||
CTR3(KTR_LOCK, | CTR3(KTR_LOCK, | ||||
"%s: spinning on %p held by %p", | "%s: spinning on %p held by %p", | ||||
__func__, m, owner); | __func__, m, owner); | ||||
KTR_STATE1(KTR_SCHED, "thread", | KTR_STATE1(KTR_SCHED, "thread", | ||||
sched_tdname((struct thread *)tid), | sched_tdname((struct thread *)tid), | ||||
"spinning", "lockname:\"%s\"", | "spinning", "lockname:\"%s\"", | ||||
m->lock_object.lo_name); | m->lock_object.lo_name); | ||||
Show All 26 Lines | #ifdef ADAPTIVE_MUTEXES | ||||
/* | /* | ||||
* The current lock owner might have started executing | * The current lock owner might have started executing | ||||
* on another CPU (or the lock could have changed | * on another CPU (or the lock could have changed | ||||
* owners) while we were waiting on the turnstile | * owners) while we were waiting on the turnstile | ||||
* chain lock. If so, drop the turnstile lock and try | * chain lock. If so, drop the turnstile lock and try | ||||
* again. | * again. | ||||
*/ | */ | ||||
owner = lv_mtx_owner(v); | owner = lv_mtx_owner(v); | ||||
if (TD_IS_RUNNING(owner)) { | if (__predict_true(m != &Giant) && TD_IS_RUNNING(owner)) { | ||||
turnstile_cancel(ts); | turnstile_cancel(ts); | ||||
continue; | continue; | ||||
} | } | ||||
#endif | #endif | ||||
/* | /* | ||||
* If the mutex isn't already contested and a failure occurs | * If the mutex isn't already contested and a failure occurs | ||||
* setting the contested bit, the mutex was either released | * setting the contested bit, the mutex was either released | ||||
▲ Show 20 Lines • Show All 708 Lines • Show Last 20 Lines |