/*
* Force a read (imply TLS allocation for dlopen) of TLS variables.
*/
-void lttng_cgroup_ns_alloc_tls(void)
+void lttng_ust_cgroup_ns_init_thread(int flags)
{
asm volatile ("" : : "m" (URCU_TLS(cached_cgroup_ns)));
+ if (flags & LTTNG_UST_INIT_THREAD_CONTEXT_CACHE)
+ (void)get_cgroup_ns();
}
/*
* Force a read (imply TLS allocation for dlopen) of TLS variables.
*/
-void lttng_ipc_ns_alloc_tls(void)
+void lttng_ust_ipc_ns_init_thread(int flags)
{
asm volatile ("" : : "m" (URCU_TLS(cached_ipc_ns)));
+ if (flags & LTTNG_UST_INIT_THREAD_CONTEXT_CACHE)
+ (void)get_ipc_ns();
}
/*
* Force a read (imply TLS allocation for dlopen) of TLS variables.
*/
-void lttng_net_ns_alloc_tls(void)
+void lttng_ust_net_ns_init_thread(int flags)
{
asm volatile ("" : : "m" (URCU_TLS(cached_net_ns)));
+ if (flags & LTTNG_UST_INIT_THREAD_CONTEXT_CACHE)
+ (void)get_net_ns();
}
/*
* Force a read (imply TLS allocation for dlopen) of TLS variables.
*/
-void lttng_ust_perf_counter_alloc_tls(void)
+void lttng_ust_perf_counter_init_thread(int flags)
{
asm volatile ("" : : "m" (URCU_TLS(ust_perf_mutex_nest)));
+ (void)flags;
}
void lttng_perf_lock(void)
/*
* Force a read (imply TLS allocation for dlopen) of TLS variables.
*/
-void lttng_procname_alloc_tls(void)
+void lttng_ust_procname_init_thread(int flags)
{
asm volatile ("" : : "m" (URCU_TLS(cached_procname)[0]));
+ if (flags & LTTNG_UST_INIT_THREAD_CONTEXT_CACHE)
+ (void)wrapper_getprocname();
}
size_t name_len = strlen(provider->name);
uint32_t hash;
- lttng_ust_alloc_tls();
+ lttng_ust_common_init_thread(0);
/* Provider name starts with "$app.". */
if (strncmp("$app.", provider->name, strlen("$app.")) != 0)
void lttng_ust_context_provider_unregister(struct lttng_ust_registered_context_provider *reg_provider)
{
- lttng_ust_alloc_tls();
+ lttng_ust_common_init_thread(0);
if (ust_lock())
goto end;
/*
* Force a read (imply TLS allocation for dlopen) of TLS variables.
*/
-void lttng_time_ns_alloc_tls(void)
+void lttng_ust_time_ns_init_thread(int flags)
{
asm volatile ("" : : "m" (URCU_TLS(cached_time_ns)));
+ if (flags & LTTNG_UST_INIT_THREAD_CONTEXT_CACHE)
+ (void)get_time_ns();
}
/*
* Force a read (imply TLS allocation for dlopen) of TLS variables.
*/
-void lttng_uts_ns_alloc_tls(void)
+void lttng_ust_uts_ns_init_thread(int flags)
{
asm volatile ("" : : "m" (URCU_TLS(cached_uts_ns)));
+ if (flags & LTTNG_UST_INIT_THREAD_CONTEXT_CACHE)
+ (void)get_uts_ns();
}
/*
* Force a read (imply TLS allocation for dlopen) of TLS variables.
*/
-void lttng_vtid_alloc_tls(void)
+void lttng_ust_vtid_init_thread(int flags)
{
asm volatile ("" : : "m" (URCU_TLS(cached_vtid)));
+ if (flags & LTTNG_UST_INIT_THREAD_CONTEXT_CACHE)
+ (void)wrapper_getvtid();
}
{
struct lttng_ust_registered_probe *reg_probe = NULL;
- lttng_ust_alloc_tls();
+ lttng_ust_common_init_thread(0);
/*
* If version mismatch, don't register, but don't trigger assert
void lttng_ust_probe_unregister(struct lttng_ust_registered_probe *reg_probe)
{
- lttng_ust_alloc_tls();
+ lttng_ust_common_init_thread(0);
if (!reg_probe)
return;
#include <lttng/ust-ringbuffer-context.h>
#include "common/logging.h"
+enum lttng_ust_init_thread_flags {
+ LTTNG_UST_INIT_THREAD_CONTEXT_CACHE = (1 << 0),
+ LTTNG_UST_INIT_THREAD_MASK = (LTTNG_UST_INIT_THREAD_CONTEXT_CACHE << 1) - 1,
+};
+
struct lttng_ust_session;
struct lttng_ust_channel_buffer;
struct lttng_ust_ctx_field;
void ust_unlock(void)
__attribute__((visibility("hidden")));
-void lttng_ust_alloc_tls(void)
+void lttng_ust_common_init_thread(int flags)
__attribute__((visibility("hidden")));
-void lttng_vtid_alloc_tls(void)
+void lttng_ust_vtid_init_thread(int flags)
__attribute__((visibility("hidden")));
-void lttng_procname_alloc_tls(void)
+void lttng_ust_procname_init_thread(int flags)
__attribute__((visibility("hidden")));
-void lttng_cgroup_ns_alloc_tls(void)
+void lttng_ust_cgroup_ns_init_thread(int flags)
__attribute__((visibility("hidden")));
-void lttng_ipc_ns_alloc_tls(void)
+void lttng_ust_ipc_ns_init_thread(int flags)
__attribute__((visibility("hidden")));
-void lttng_net_ns_alloc_tls(void)
+void lttng_ust_net_ns_init_thread(int flags)
__attribute__((visibility("hidden")));
-void lttng_time_ns_alloc_tls(void)
+void lttng_ust_time_ns_init_thread(int flags)
__attribute__((visibility("hidden")));
-void lttng_uts_ns_alloc_tls(void)
+void lttng_ust_uts_ns_init_thread(int flags)
__attribute__((visibility("hidden")));
const char *lttng_ust_obj_get_name(int id)
__attribute__((visibility("hidden")));
#ifdef HAVE_LINUX_PERF_EVENT_H
-void lttng_ust_perf_counter_alloc_tls(void)
+void lttng_ust_perf_counter_init_thread(int flags)
__attribute__((visibility("hidden")));
void lttng_perf_lock(void)
__attribute__((visibility("hidden")));
#else /* #ifdef HAVE_LINUX_PERF_EVENT_H */
static inline
-void lttng_ust_perf_counter_alloc_tls(void)
+void lttng_ust_perf_counter_init_thread(int flags __attribute__((unused)))
{
}
static inline
* Force a read (imply TLS allocation for dlopen) of TLS variables.
*/
static
-void lttng_nest_count_alloc_tls(void)
+void lttng_ust_nest_count_alloc_tls(void)
{
asm volatile ("" : : "m" (URCU_TLS(lttng_ust_nest_count)));
}
* Allocate lttng-ust urcu TLS.
*/
static
-void lttng_lttng_ust_urcu_alloc_tls(void)
+void lttng_ust_urcu_alloc_tls(void)
{
(void) lttng_ust_urcu_read_ongoing();
}
-void lttng_ust_alloc_tls(void)
+void lttng_ust_common_init_thread(int flags)
{
- lttng_lttng_ust_urcu_alloc_tls();
+ lttng_ust_urcu_alloc_tls();
lttng_ringbuffer_alloc_tls();
- lttng_vtid_alloc_tls();
- lttng_nest_count_alloc_tls();
- lttng_procname_alloc_tls();
+ lttng_ust_vtid_init_thread(flags);
+ lttng_ust_nest_count_alloc_tls();
+ lttng_ust_procname_init_thread(flags);
lttng_ust_mutex_nest_alloc_tls();
- lttng_ust_perf_counter_alloc_tls();
+ lttng_ust_perf_counter_init_thread(flags);
lttng_ust_common_alloc_tls();
- lttng_cgroup_ns_alloc_tls();
- lttng_ipc_ns_alloc_tls();
- lttng_net_ns_alloc_tls();
- lttng_time_ns_alloc_tls();
- lttng_uts_ns_alloc_tls();
+ lttng_ust_cgroup_ns_init_thread(flags);
+ lttng_ust_ipc_ns_init_thread(flags);
+ lttng_ust_net_ns_init_thread(flags);
+ lttng_ust_time_ns_init_thread(flags);
+ lttng_ust_uts_ns_init_thread(flags);
lttng_ust_ring_buffer_client_discard_alloc_tls();
lttng_ust_ring_buffer_client_discard_rt_alloc_tls();
lttng_ust_ring_buffer_client_overwrite_alloc_tls();
* ensure those are initialized before a signal handler nesting over
* this thread attempts to use them.
*/
- lttng_ust_alloc_tls();
+ lttng_ust_common_init_thread(LTTNG_UST_INIT_THREAD_MASK);
}
int lttng_get_notify_socket(void *owner)
int sock, ret, prev_connect_failed = 0, has_waited = 0, fd;
long timeout;
- lttng_ust_alloc_tls();
+ lttng_ust_common_init_thread(0);
/*
* If available, add '-ust' to the end of this thread's
* process name
* to be the dynamic linker mutex) and ust_lock, taken within
* the ust lock.
*/
- lttng_ust_alloc_tls();
+ lttng_ust_common_init_thread(0);
lttng_ust_loaded = 1;
int ret;
/* Allocate lttng-ust TLS. */
- lttng_ust_alloc_tls();
+ lttng_ust_common_init_thread(0);
if (URCU_TLS(lttng_ust_nest_count))
return;
* Force the allocation of lttng-ust TLS variables when called from
* dlopen/dlclose instrumentation.
*/
- lttng_ust_alloc_tls();
+ lttng_ust_common_init_thread(0);
data.exec_found = 0;
data.first = true;