Fix the lock owner sanity checking during background thread boot.
During boot, some mutexes are not initialized yet, plus there's no point taking many mutexes while everything is covered by the global init lock, so the locking assumptions in some functions (e.g. background_thread_enabled_set()) can't be enforced. Skip the lock owner check in this case.
This commit is contained in:
parent
0181aaa495
commit
44db479fad
|
@ -11,10 +11,15 @@ background_thread_enabled(void) {
|
||||||
return atomic_load_b(&background_thread_enabled_state, ATOMIC_RELAXED);
|
return atomic_load_b(&background_thread_enabled_state, ATOMIC_RELAXED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JEMALLOC_ALWAYS_INLINE void
|
||||||
|
background_thread_enabled_set_impl(bool state) {
|
||||||
|
atomic_store_b(&background_thread_enabled_state, state, ATOMIC_RELAXED);
|
||||||
|
}
|
||||||
|
|
||||||
JEMALLOC_ALWAYS_INLINE void
|
JEMALLOC_ALWAYS_INLINE void
|
||||||
background_thread_enabled_set(tsdn_t *tsdn, bool state) {
|
background_thread_enabled_set(tsdn_t *tsdn, bool state) {
|
||||||
malloc_mutex_assert_owner(tsdn, &background_thread_lock);
|
malloc_mutex_assert_owner(tsdn, &background_thread_lock);
|
||||||
atomic_store_b(&background_thread_enabled_state, state, ATOMIC_RELAXED);
|
background_thread_enabled_set_impl(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
JEMALLOC_ALWAYS_INLINE background_thread_info_t *
|
JEMALLOC_ALWAYS_INLINE background_thread_info_t *
|
||||||
|
|
|
@ -819,7 +819,6 @@ background_thread_boot1(tsdn_t *tsdn, base_t *base) {
|
||||||
}
|
}
|
||||||
max_background_threads = opt_max_background_threads;
|
max_background_threads = opt_max_background_threads;
|
||||||
|
|
||||||
background_thread_enabled_set(tsdn, opt_background_thread);
|
|
||||||
if (malloc_mutex_init(&background_thread_lock,
|
if (malloc_mutex_init(&background_thread_lock,
|
||||||
"background_thread_global",
|
"background_thread_global",
|
||||||
WITNESS_RANK_BACKGROUND_THREAD_GLOBAL,
|
WITNESS_RANK_BACKGROUND_THREAD_GLOBAL,
|
||||||
|
@ -850,7 +849,8 @@ background_thread_boot1(tsdn_t *tsdn, base_t *base) {
|
||||||
background_thread_info_init(tsdn, info);
|
background_thread_info_init(tsdn, info);
|
||||||
malloc_mutex_unlock(tsdn, &info->mtx);
|
malloc_mutex_unlock(tsdn, &info->mtx);
|
||||||
}
|
}
|
||||||
|
/* Using _impl to bypass the locking check during init. */
|
||||||
|
background_thread_enabled_set_impl(opt_background_thread);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue