Revert "Use initial-exec TLS model"
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 7 Nov 2017 14:38:18 +0000 (09:38 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 7 Nov 2017 14:38:18 +0000 (09:38 -0500)
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 <mathieu.desnoyers@efficios.com>
configure.ac
liblttng-ust-comm/lttng-ust-fd-tracker.c
liblttng-ust-java-agent/jni/common/lttng_ust_context.c
liblttng-ust-java-agent/jni/common/lttng_ust_context.h
liblttng-ust-libc-wrapper/lttng-ust-malloc.c
liblttng-ust-libc-wrapper/lttng-ust-pthread.c
liblttng-ust/lttng-context-procname.c
liblttng-ust/lttng-context-vtid.c
liblttng-ust/lttng-ust-comm.c
libringbuffer/ring_buffer_frontend.c
tests/test-app-ctx/hello.c

index 68f41315c9bee4ed00aa60c4f37a89a73f9c0779..fb2f27864ce9f7c530a3b798b4203c912b2e6eb4 100644 (file)
@@ -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 <urcu.h>]])
-#Macro added in urcu 0.11.0
-AC_CHECK_DECL([DEFINE_URCU_TLS_IE], [],
-       [AC_MSG_ERROR([WRONG_LIBURCU_MSG])], [[#include <urcu/tls-compat.h>]]
-)
-
 # 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 <urcu/compiler.h>
+       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.])])
 
index 04ae2391f034f7f8a23e92aef97d3e4ace8518a0..5a763ff2960550c094306d9d7d90de3d2bf9d037 100644 (file)
@@ -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;
index e9b6da282db3bfbc5ec075a8ea64178c6f9ef851..3bed11ec8ff435768259a460d9dffbfb0636efc0 100644 (file)
@@ -24,7 +24,6 @@
 #include <lttng/ust-events.h>
 #include <lttng/ringbuffer-config.h>
 #include <lttng/ust-context-provider.h>
-#include <urcu/tls-compat.h>
 
 #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)
 {
index 8ea43e1ae362d471279c7b77c18c5bee9e2abf3f..415f7de228fa9bcbc500dc28929a978272ef0b76 100644 (file)
@@ -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 <urcu/tls-compat.h>
-
 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_ */
index f30a2c694372970c7f68581364075a67534dbeb4..f3e1e19e28e52d8d5fe07d399f6c4741d0d87282 100644 (file)
@@ -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
index 6554a47afe7057f3b8c2c21147574c2f77d5ad09..7836ffa02175d7599e4472403964b1b1069f4c33 100644 (file)
@@ -23,7 +23,6 @@
  * libc.
  */
 #include <lttng/ust-dlfcn.h>
-#include <urcu/tls-compat.h>
 #include <helper.h>
 #include <pthread.h>
 
@@ -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)
 {
index 4b8da28f255aa56d74fe87c67f12cdd214680782..b6e69501d81c08bc79c5f82d9ff5b85d1d22230a 100644 (file)
@@ -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)
index 8c9bbec56e67324bdaeeca71893197a58b571f38..f28e470a38c91be3e88c7b1d1fcd42c591d73c67 100644 (file)
@@ -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
index eec049b31fb2a09de4add833adac706e2e4168ce..511b9cf4a88214c0225ff8a7e15a63cbca32145e 100644 (file)
@@ -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
index d822039330853a7bce60a65f0ab6efb502188dcd..0d0f26865da9fd4da5aa140c5afcb702c4e89f08 100644 (file)
@@ -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
index f2859a7a13612318650abc313cafddd7c3b25e06..197df21e1ada8bbc1d9e1cdadfc992ae522abd0c 100644 (file)
@@ -26,7 +26,6 @@
 #include <fcntl.h>
 #include <signal.h>
 #include <string.h>
-#include <urcu/tls-compat.h>
 /*
  * 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 <lttng/ringbuffer-config.h>
 #include <lttng/ust-context-provider.h>
 
-static DEFINE_URCU_TLS_IE(unsigned int, test_count);
+static __thread unsigned int test_count;
 
 void test_inc_count(void)
 {
This page took 0.029206 seconds and 4 git commands to generate.