Fix: fixup ringbuffer tls at constructor by forcing read
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 1 Mar 2012 17:09:40 +0000 (12:09 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 1 Mar 2012 17:09:40 +0000 (12:09 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust/lttng-ust-comm.c
libringbuffer/Makefile.am
libringbuffer/ring_buffer_frontend.c
libringbuffer/tlsfixup.h [new file with mode: 0644]

index ba69f5fff35a84c14fa97e64de461957f634a37f..2f2c783b189966d19181ae98bec17a020152c002 100644 (file)
@@ -46,6 +46,7 @@
 #include "tracepoint-internal.h"
 #include "ltt-tracer-core.h"
 #include "compat.h"
+#include "../libringbuffer/tlsfixup.h"
 
 /*
  * Has lttng ust comm constructor been called ?
@@ -833,6 +834,7 @@ void __attribute__((constructor)) lttng_ust_init(void)
         * the ust lock.
         */
        lttng_fixup_event_tls();
+       lttng_fixup_ringbuffer_tls();
 
        /*
         * We want precise control over the order in which we construct
index 9bd8586812a19b46a42ee9ed6abf2055053c563d..b5b0ebd1f2e7cda10a6cc6dc17d7ff1c610c9c2e 100644 (file)
@@ -11,7 +11,7 @@ libringbuffer_la_SOURCES = \
        api.h \
        backend.h backend_internal.h backend_types.h \
        frontend_api.h frontend.h frontend_internal.h frontend_types.h \
-       nohz.h vatomic.h
+       nohz.h vatomic.h tlsfixup.h
        
 libringbuffer_la_LIBADD = \
        -lpthread \
index 28e959bae215641bd6e149e580802e5242aab61d..0ae3d72f23a5b16b987d5b142fcb6964bd6f0c61 100644 (file)
@@ -53,6 +53,7 @@
 #include "backend.h"
 #include "frontend.h"
 #include "shm.h"
+#include "tlsfixup.h"
 #include "../liblttng-ust/compat.h"    /* For ENODATA */
 
 #ifndef max
@@ -1508,3 +1509,11 @@ int lib_ring_buffer_reserve_slow(struct lttng_ust_lib_ring_buffer_ctx *ctx)
        ctx->buf_offset = offsets.begin + offsets.pre_header_padding;
        return 0;
 }
+
+/*
+ * Force a read (imply TLS fixup for dlopen) of TLS variables.
+ */
+void lttng_fixup_ringbuffer_tls(void)
+{
+       asm volatile ("" : : "m" (lib_ring_buffer_nesting));
+}
diff --git a/libringbuffer/tlsfixup.h b/libringbuffer/tlsfixup.h
new file mode 100644 (file)
index 0000000..84ba889
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef _LTTNG_UST_LIB_RINGBUFFER_TLS_FIXUP_H
+#define _LTTNG_UST_LIB_RINGBUFFER_TLS_FIXUP_H
+
+/*
+ * libringbuffer/tlsfixup.h
+ *
+ * Copyright 2011 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+void lttng_fixup_ringbuffer_tls(void);
+
+#endif /* _LTTNG_UST_LIB_RINGBUFFER_TLS_FIXUP_H */
This page took 0.027755 seconds and 4 git commands to generate.