Add thread name for background threads.
This commit is contained in:
parent
52fc887b49
commit
a3f4977217
@ -1470,6 +1470,15 @@ if test "x$abi" != "xpecoff" ; then
|
||||
if test "x${je_cv_pthread_atfork}" = "xyes" ; then
|
||||
AC_DEFINE([JEMALLOC_HAVE_PTHREAD_ATFORK], [ ])
|
||||
fi
|
||||
dnl Check if pthread_setname_np is available with the expected API.
|
||||
JE_COMPILABLE([pthread_setname_np(3)], [
|
||||
#include <pthread.h>
|
||||
], [
|
||||
pthread_setname_np(pthread_self(), "setname_test");
|
||||
], [je_cv_pthread_setname_np])
|
||||
if test "x${je_cv_pthread_setname_np}" = "xyes" ; then
|
||||
AC_DEFINE([JEMALLOC_HAVE_PTHREAD_SETNAME_NP], [ ])
|
||||
fi
|
||||
fi
|
||||
|
||||
JE_APPEND_VS(CPPFLAGS, -D_REENTRANT)
|
||||
|
@ -98,6 +98,9 @@
|
||||
/* Defined if pthread_atfork(3) is available. */
|
||||
#undef JEMALLOC_HAVE_PTHREAD_ATFORK
|
||||
|
||||
/* Defined if pthread_setname_np(3) is available. */
|
||||
#undef JEMALLOC_HAVE_PTHREAD_SETNAME_NP
|
||||
|
||||
/*
|
||||
* Defined if clock_gettime(CLOCK_MONOTONIC_COARSE, ...) is available.
|
||||
*/
|
||||
|
@ -499,7 +499,9 @@ static void *
|
||||
background_thread_entry(void *ind_arg) {
|
||||
unsigned thread_ind = (unsigned)(uintptr_t)ind_arg;
|
||||
assert(thread_ind < ncpus);
|
||||
|
||||
#ifdef JEMALLOC_HAVE_PTHREAD_SETNAME_NP
|
||||
pthread_setname_np(pthread_self(), "jemalloc_bg_thd");
|
||||
#endif
|
||||
if (opt_percpu_arena != percpu_arena_disabled) {
|
||||
set_current_thread_affinity((int)thread_ind);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user