diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c index 162ef7dfe7a9..c019c8f27b36 100644 --- a/lib/libthr/thread/thr_init.c +++ b/lib/libthr/thread/thr_init.c @@ -118,7 +118,7 @@ size_t _thr_guard_default; size_t _thr_stack_default = THR_STACK_DEFAULT; size_t _thr_stack_initial = THR_STACK_INITIAL; int _thr_page_size; -int _thr_spinloops; +int _thr_spinloops = MUTEX_ADAPTIVE_SPINS; int _thr_yieldloops; int _thr_queuefifo = 4; int _gc_count; diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c index 139dc768b7ba..9c0939aa6080 100644 --- a/lib/libthr/thread/thr_mutex.c +++ b/lib/libthr/thread/thr_mutex.c @@ -62,12 +62,6 @@ _Static_assert(offsetof(struct pthread_mutex, m_qe) >= CACHE_LINE_SIZE, "m_qe must not share a cache line with m_lock.m_owner"); #endif -/* - * For adaptive mutexes, how many times to spin doing trylock2 - * before entering the kernel to block - */ -#define MUTEX_ADAPTIVE_SPINS 2000 - /* * Prototypes */ @@ -274,8 +268,7 @@ mutex_init_body(struct pthread_mutex *pmutex, pmutex->m_lock.m_flags |= UMUTEX_ROBUST; } if (PMUTEX_TYPE(pmutex->m_flags) == PTHREAD_MUTEX_ADAPTIVE_NP) { - pmutex->m_spinloops = - _thr_spinloops ? _thr_spinloops: MUTEX_ADAPTIVE_SPINS; + pmutex->m_spinloops = _thr_spinloops; pmutex->m_yieldloops = _thr_yieldloops; } } diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h index cf90ac5bd4ef..ffc4ff7233db 100644 --- a/lib/libthr/thread/thr_private.h +++ b/lib/libthr/thread/thr_private.h @@ -154,6 +154,12 @@ TAILQ_HEAD(mutex_queue, pthread_mutex); #define MAX_DEFER_WAITERS 50 +/* + * For adaptive mutexes, how many times to spin doing trylock2 + * before entering the kernel to block + */ +#define MUTEX_ADAPTIVE_SPINS 2000 + /* * Values for pthread_mutex m_ps indicator. */