[lttng-dev] [PATCH lttng-tools] Use initial-exec TLS model

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Thu Oct 19 14:51:09 UTC 2017


The initial-exec TLS model is async-signal-safe, whereas the
global-dynamic is not. This is especially important for the logging
facility, because the first time a thread touches the TLS could be
from a signal handler (correctness).

Moreover, IE is faster than GD model.

Also change the health state to the IE model, just in case we end up
putting health progress reporting statements in signal handlers in the
future. Given that we link against, but don't dlopen, that library, it
is not using any of the IE backup pool, so there is no good reason for
using the GD model.

Link: https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter8-20.html
Link: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#Common-Variable-Attributes
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 configure.ac               | 7 ++++++-
 src/common/error.c         | 2 +-
 src/common/health/health.c | 2 +-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 016c56ec..77316a28 100644
--- a/configure.ac
+++ b/configure.ac
@@ -440,7 +440,7 @@ AC_SUBST(UUID_LIBS)
 AC_CHECK_FUNC([clock_gettime], [AC_DEFINE_UNQUOTED([LTTNG_HAVE_CLOCK_GETTIME], 1, [Has clock_gettime() support.])])
 
 # URCU library version needed or newer
-m4_define([WRONG_LIBURCU_MSG], [Userspace RCU (liburcu) >= 0.9.0 is needed])
+m4_define([WRONG_LIBURCU_MSG], [Userspace RCU (liburcu) >= 0.11.0 is needed])
 
 # Check liburcu needed function calls
 AC_CHECK_DECL([cds_list_add], [],
@@ -470,6 +470,11 @@ AC_CHECK_DECL([urcu_ref_get_unless_zero], [],
         [AC_MSG_ERROR([WRONG_LIBURCU_MSG])], [[#include <urcu/ref.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>]]
+)
+
 # Check for libkmod, it will be auto-neabled if found but won't fail if it's not,
 # it can be explicitly disabled with --without-kmod
 AH_TEMPLATE([HAVE_KMOD], [Define if you have kmod support])
diff --git a/src/common/error.c b/src/common/error.c
index 2215886d..5c45fc70 100644
--- a/src/common/error.c
+++ b/src/common/error.c
@@ -36,7 +36,7 @@
 static int lttng_opt_abort_on_error = -1;
 
 /* TLS variable that contains the time of one single log entry. */
-DEFINE_URCU_TLS(struct log_time, error_log_time);
+DEFINE_URCU_TLS_IE(struct log_time, error_log_time);
 
 LTTNG_HIDDEN
 const char *log_add_time(void)
diff --git a/src/common/health/health.c b/src/common/health/health.c
index 830b6f0e..b87c70b4 100644
--- a/src/common/health/health.c
+++ b/src/common/health/health.c
@@ -54,7 +54,7 @@ struct health_app {
 };
 
 /* Define TLS health state. */
-DEFINE_URCU_TLS(struct health_state, health_state);
+DEFINE_URCU_TLS_IE(struct health_state, health_state);
 
 /*
  * Initialize health check subsytem.
-- 
2.11.0



More information about the lttng-dev mailing list