From: Mathieu Desnoyers Date: Tue, 7 Nov 2017 14:38:18 +0000 (-0500) Subject: Revert "Use initial-exec TLS model" X-Git-Tag: v2.11.0-rc1~35 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=16adecf1f2e80025667ed53f4905e725894f076a;p=lttng-ust.git Revert "Use initial-exec TLS model" This reverts commit 553bbf7f38652084ed7966c7817b8ccb372b14e1. The initial-exec model seems to behave differently than global-dynamic with respect to lazy initialization, causing locks to be taken then first time each thread touch the TLS. This introduces deadlocks with library constructors waiting on other threads. This will require further investigation. Signed-off-by: Mathieu Desnoyers --- diff --git a/configure.ac b/configure.ac index 68f41315..fb2f2786 100644 --- a/configure.ac +++ b/configure.ac @@ -249,22 +249,26 @@ AM_CONDITIONAL([HAVE_DLINFO], [test "x${ac_cv_have_decl_RTLD_DI_LINKMAP}" = "xye AC_CHECK_HEADERS([urcu-bp.h], [], [AC_MSG_ERROR([Cannot find [URCU] headers (urcu-bp.h). Use [CPPFLAGS]=-Idir to specify their location. This error can also occur when the liburcu package's configure script has not been run.])]) -# URCU library version needed or newer -m4_define([WRONG_LIBURCU_MSG], [Userspace RCU (liburcu) >= 0.11.0 is needed]) - -#Macro added in urcu 0.6.6 -AC_CHECK_DECL([caa_likely], [], - [AC_MSG_ERROR([WRONG_LIBURCU_MSG])], [[#include ]]) -#Macro added in urcu 0.11.0 -AC_CHECK_DECL([DEFINE_URCU_TLS_IE], [], - [AC_MSG_ERROR([WRONG_LIBURCU_MSG])], [[#include ]] -) - # urcu-cds - check that URCU Concurrent Data Structure lib is available to compilation # Part of Userspace RCU library 0.7.2 or better. AC_CHECK_LIB([urcu-cds], [_cds_lfht_new], [], [AC_MSG_ERROR([Cannot find liburcu-cds lib, part of Userspace RCU 0.7 or better. Use [LDFLAGS]=-Ldir to specify its location.])]) +AC_MSG_CHECKING([caa_likely()]) +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ + #include + void fct(void) + { + if (caa_likely(1)) { + } + } +]])], [ + AC_MSG_RESULT([yes]) +], [ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([Please upgrade your version of liburcu to 0.6.6 or better]) +]) + # urcu - check that URCU lib is available to compilation AC_CHECK_LIB([urcu-bp], [synchronize_rcu_bp], [], [AC_MSG_ERROR([Cannot find liburcu-bp lib. Use [LDFLAGS]=-Ldir to specify its location.])]) diff --git a/liblttng-ust-comm/lttng-ust-fd-tracker.c b/liblttng-ust-comm/lttng-ust-fd-tracker.c index 04ae2391..5a763ff2 100644 --- a/liblttng-ust-comm/lttng-ust-fd-tracker.c +++ b/liblttng-ust-comm/lttng-ust-fd-tracker.c @@ -65,7 +65,7 @@ static pthread_mutex_t ust_safe_guard_fd_mutex = PTHREAD_MUTEX_INITIALIZER; * Track whether we are within lttng-ust or application, for close * system call override by LD_PRELOAD library. */ -static DEFINE_URCU_TLS_IE(int, thread_fd_tracking); +static DEFINE_URCU_TLS(int, thread_fd_tracking); /* fd_set used to book keep fd being used by lttng-ust. */ static fd_set *lttng_fd_set; diff --git a/liblttng-ust-java-agent/jni/common/lttng_ust_context.c b/liblttng-ust-java-agent/jni/common/lttng_ust_context.c index e9b6da28..3bed11ec 100644 --- a/liblttng-ust-java-agent/jni/common/lttng_ust_context.c +++ b/liblttng-ust-java-agent/jni/common/lttng_ust_context.c @@ -24,7 +24,6 @@ #include #include #include -#include #include "helper.h" #include "lttng_ust_context.h" @@ -57,7 +56,7 @@ struct lttng_ust_jni_ctx_entry { } __attribute__((packed)); /* TLS passing context info from JNI to callbacks. */ -DECLARE_URCU_TLS_IE(struct lttng_ust_jni_tls, lttng_ust_context_info_tls); +__thread struct lttng_ust_jni_tls lttng_ust_context_info_tls; static const char *get_ctx_string_at_offset(int32_t offset) { diff --git a/liblttng-ust-java-agent/jni/common/lttng_ust_context.h b/liblttng-ust-java-agent/jni/common/lttng_ust_context.h index 8ea43e1a..415f7de2 100644 --- a/liblttng-ust-java-agent/jni/common/lttng_ust_context.h +++ b/liblttng-ust-java-agent/jni/common/lttng_ust_context.h @@ -19,8 +19,6 @@ #ifndef LIBLTTNG_UST_JAVA_AGENT_JNI_COMMON_LTTNG_UST_CONTEXT_H_ #define LIBLTTNG_UST_JAVA_AGENT_JNI_COMMON_LTTNG_UST_CONTEXT_H_ -#include - struct lttng_ust_jni_ctx_entry; struct lttng_ust_jni_tls { @@ -30,6 +28,6 @@ struct lttng_ust_jni_tls { int32_t ctx_strings_len; }; -extern DECLARE_URCU_TLS(struct lttng_ust_jni_tls, lttng_ust_context_info_tls); +extern __thread struct lttng_ust_jni_tls lttng_ust_context_info_tls; #endif /* LIBLTTNG_UST_JAVA_AGENT_JNI_COMMON_LTTNG_UST_CONTEXT_H_ */ diff --git a/liblttng-ust-libc-wrapper/lttng-ust-malloc.c b/liblttng-ust-libc-wrapper/lttng-ust-malloc.c index f30a2c69..f3e1e19e 100644 --- a/liblttng-ust-libc-wrapper/lttng-ust-malloc.c +++ b/liblttng-ust-libc-wrapper/lttng-ust-malloc.c @@ -95,7 +95,7 @@ void ust_malloc_spin_unlock(pthread_mutex_t *lock) #define calloc static_calloc #define pthread_mutex_lock ust_malloc_spin_lock #define pthread_mutex_unlock ust_malloc_spin_unlock -static DEFINE_URCU_TLS_IE(int, malloc_nesting); +static DEFINE_URCU_TLS(int, malloc_nesting); #undef ust_malloc_spin_unlock #undef ust_malloc_spin_lock #undef calloc diff --git a/liblttng-ust-libc-wrapper/lttng-ust-pthread.c b/liblttng-ust-libc-wrapper/lttng-ust-pthread.c index 6554a47a..7836ffa0 100644 --- a/liblttng-ust-libc-wrapper/lttng-ust-pthread.c +++ b/liblttng-ust-libc-wrapper/lttng-ust-pthread.c @@ -23,7 +23,6 @@ * libc. */ #include -#include #include #include @@ -32,7 +31,7 @@ #define TP_IP_PARAM ip #include "ust_pthread.h" -static DEFINE_URCU_TLS_IE(int, thread_in_trace); +static __thread int thread_in_trace; int pthread_mutex_lock(pthread_mutex_t *mutex) { diff --git a/liblttng-ust/lttng-context-procname.c b/liblttng-ust/lttng-context-procname.c index 4b8da28f..b6e69501 100644 --- a/liblttng-ust/lttng-context-procname.c +++ b/liblttng-ust/lttng-context-procname.c @@ -38,7 +38,7 @@ * thread. */ typedef char procname_array[17]; -static DEFINE_URCU_TLS_IE(procname_array, cached_procname); +static DEFINE_URCU_TLS(procname_array, cached_procname); static inline char *wrapper_getprocname(void) diff --git a/liblttng-ust/lttng-context-vtid.c b/liblttng-ust/lttng-context-vtid.c index 8c9bbec5..f28e470a 100644 --- a/liblttng-ust/lttng-context-vtid.c +++ b/liblttng-ust/lttng-context-vtid.c @@ -34,7 +34,7 @@ * We cache the result to ensure we don't trigger a system call for * each event. */ -static DEFINE_URCU_TLS_IE(pid_t, cached_vtid); +static DEFINE_URCU_TLS(pid_t, cached_vtid); /* * Upon fork or clone, the TID assigned to our thread is not the same as diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index eec049b3..511b9cf4 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -86,7 +86,7 @@ static int initialized; static pthread_mutex_t ust_mutex = PTHREAD_MUTEX_INITIALIZER; /* Allow nesting the ust_mutex within the same thread. */ -static DEFINE_URCU_TLS_IE(int, ust_mutex_nest); +static DEFINE_URCU_TLS(int, ust_mutex_nest); /* * ust_exit_mutex protects thread_active variable wrt thread exit. It diff --git a/libringbuffer/ring_buffer_frontend.c b/libringbuffer/ring_buffer_frontend.c index d8220393..0d0f2686 100644 --- a/libringbuffer/ring_buffer_frontend.c +++ b/libringbuffer/ring_buffer_frontend.c @@ -118,7 +118,7 @@ struct switch_offsets { switch_old_end:1; }; -DEFINE_URCU_TLS_IE(unsigned int, lib_ring_buffer_nesting); +DEFINE_URCU_TLS(unsigned int, lib_ring_buffer_nesting); /* * wakeup_fd_mutex protects wakeup fd use by timer from concurrent diff --git a/tests/test-app-ctx/hello.c b/tests/test-app-ctx/hello.c index f2859a7a..197df21e 100644 --- a/tests/test-app-ctx/hello.c +++ b/tests/test-app-ctx/hello.c @@ -26,7 +26,6 @@ #include #include #include -#include /* * Work-around inet.h missing struct mmsghdr forward declaration, with * triggers a warning when system files warnings are enabled. @@ -44,7 +43,7 @@ struct mmsghdr; #include #include -static DEFINE_URCU_TLS_IE(unsigned int, test_count); +static __thread unsigned int test_count; void test_inc_count(void) {