@@ -155,7 +155,9 @@ error_find_context:
/*
* 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();
}
@@ -153,7 +153,9 @@ error_find_context:
/*
* 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();
}
@@ -153,7 +153,9 @@ error_find_context:
/*
* 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();
}
@@ -87,9 +87,10 @@ static DEFINE_URCU_TLS(int, ust_perf_mutex_nest);
/*
* 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)
@@ -122,7 +122,9 @@ error_find_context:
/*
* 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();
}
@@ -67,7 +67,7 @@ struct lttng_ust_registered_context_provider *lttng_ust_context_provider_registe
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)
@@ -101,7 +101,7 @@ end:
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;
@@ -152,7 +152,9 @@ error_find_context:
/*
* 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();
}
@@ -154,7 +154,9 @@ error_find_context:
/*
* 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();
}
@@ -112,7 +112,9 @@ error_find_context:
/*
* 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();
}
@@ -231,7 +231,7 @@ struct lttng_ust_registered_probe *lttng_ust_probe_register(const struct lttng_u
{
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
@@ -269,7 +269,7 @@ end:
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;
@@ -16,6 +16,11 @@
#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;
@@ -34,28 +39,28 @@ void ust_lock_nocheck(void)
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)
@@ -78,7 +83,7 @@ void lttng_event_notifier_notification_send(
__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)
@@ -88,8 +93,9 @@ void lttng_perf_unlock(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)
{
+ (void)flags;
}
static inline
void lttng_perf_lock(void)
@@ -387,7 +387,7 @@ const char *get_lttng_home_dir(void)
* 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)));
}
@@ -402,26 +402,26 @@ void lttng_ust_mutex_nest_alloc_tls(void)
* 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();
@@ -446,7 +446,7 @@ void lttng_ust_init_thread(void)
* 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)
@@ -1815,7 +1815,7 @@ void *ust_listener_thread(void *arg)
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
@@ -2183,7 +2183,7 @@ void lttng_ust_ctor(void)
* 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;
@@ -2497,7 +2497,7 @@ void lttng_ust_before_fork(sigset_t *save_sigset)
int ret;
/* Allocate lttng-ust TLS. */
- lttng_ust_alloc_tls();
+ lttng_ust_common_init_thread(0);
if (URCU_TLS(lttng_ust_nest_count))
return;
@@ -557,7 +557,7 @@ void lttng_ust_dl_update(void *ip)
* 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;