From: Mathieu Desnoyers Date: Thu, 1 Mar 2012 17:09:40 +0000 (-0500) Subject: Fix: fixup ringbuffer tls at constructor by forcing read X-Git-Tag: v2.0.0-rc2~13 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=f645cfa794fc481dff6cb30ea56e93f825b3d423;p=lttng-ust.git Fix: fixup ringbuffer tls at constructor by forcing read Signed-off-by: Mathieu Desnoyers Conflicts: liblttng-ust/lttng-ust-comm.c libringbuffer/ring_buffer_frontend.c --- diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index fa184ad7..b90df861 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -46,6 +46,7 @@ #include #include "tracepoint-internal.h" #include "ltt-tracer-core.h" +#include "../libringbuffer/tlsfixup.h" /* * Has lttng ust comm constructor been called ? @@ -838,6 +839,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 diff --git a/libringbuffer/Makefile.am b/libringbuffer/Makefile.am index 9bd85868..b5b0ebd1 100644 --- a/libringbuffer/Makefile.am +++ b/libringbuffer/Makefile.am @@ -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 \ diff --git a/libringbuffer/ring_buffer_frontend.c b/libringbuffer/ring_buffer_frontend.c index 0996ecef..970fde90 100644 --- a/libringbuffer/ring_buffer_frontend.c +++ b/libringbuffer/ring_buffer_frontend.c @@ -53,6 +53,7 @@ #include "backend.h" #include "frontend.h" #include "shm.h" +#include "tlsfixup.h" #ifndef max #define max(a, b) ((a) > (b) ? (a) : (b)) @@ -1507,3 +1508,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 index 00000000..84ba889e --- /dev/null +++ b/libringbuffer/tlsfixup.h @@ -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 + * + * Dual LGPL v2.1/GPL v2 license. + */ + +void lttng_fixup_ringbuffer_tls(void); + +#endif /* _LTTNG_UST_LIB_RINGBUFFER_TLS_FIXUP_H */