lttng/ust-clock.h \
lttng/ust-getcpu.h \
lttng/ust-libc-wrapper.h \
+ lttng/ust-thread.h \
lttng/urcu/pointer.h \
lttng/urcu/urcu-ust.h \
lttng/urcu/static/pointer.h \
--- /dev/null
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2021 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#ifndef _LTTNG_UST_THREAD_H
+#define _LTTNG_UST_THREAD_H
+
+#include <signal.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Initialize this thread's LTTng-UST data structures. There is
+ * typically no need to call this, because LTTng-UST initializes its
+ * per-thread data structures lazily, but it should be called explicitly
+ * upon creation of each thread before signal handlers nesting over
+ * those threads use LTTng-UST tracepoints.
+ */
+void lttng_ust_init_thread(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LTTNG_UST_THREAD_H */
struct ustctl_counter_attr *attr; /* initial attributes */
};
-extern void lttng_ring_buffer_client_overwrite_init(void);
-extern void lttng_ring_buffer_client_overwrite_rt_init(void);
-extern void lttng_ring_buffer_client_discard_init(void);
-extern void lttng_ring_buffer_client_discard_rt_init(void);
-extern void lttng_ring_buffer_metadata_client_init(void);
-extern void lttng_ring_buffer_client_overwrite_exit(void);
-extern void lttng_ring_buffer_client_overwrite_rt_exit(void);
-extern void lttng_ring_buffer_client_discard_exit(void);
-extern void lttng_ring_buffer_client_discard_rt_exit(void);
-extern void lttng_ring_buffer_metadata_client_exit(void);
-
int ustctl_release_handle(int sock, int handle)
{
struct ustcomm_ust_msg lum;
ust_err_init();
lttng_ust_getenv_init(); /* Needs ust_err_init() to be completed. */
lttng_ust_clock_init();
- lttng_ring_buffer_metadata_client_init();
- lttng_ring_buffer_client_overwrite_init();
- lttng_ring_buffer_client_overwrite_rt_init();
- lttng_ring_buffer_client_discard_init();
- lttng_ring_buffer_client_discard_rt_init();
- lttng_counter_client_percpu_32_modular_init();
- lttng_counter_client_percpu_64_modular_init();
+ lttng_ust_ring_buffer_clients_init();
+ lttng_ust_counter_clients_init();
lib_ringbuffer_signal_init();
}
static __attribute__((destructor))
void ustctl_exit(void)
{
- lttng_ring_buffer_client_discard_rt_exit();
- lttng_ring_buffer_client_discard_exit();
- lttng_ring_buffer_client_overwrite_rt_exit();
- lttng_ring_buffer_client_overwrite_exit();
- lttng_ring_buffer_metadata_client_exit();
- lttng_counter_client_percpu_32_modular_exit();
- lttng_counter_client_percpu_64_modular_exit();
+ lttng_ust_counter_clients_exit();
+ lttng_ust_ring_buffer_clients_exit();
}
struct lttng_ust_lib_ring_buffer_channel *chan, uint64_t *id);
};
+/*
+ * The ring buffer and counter clients init/exit symbols are private ABI
+ * for liblttng-ust-ctl, which is why they are not hidden.
+ */
+void lttng_ust_ring_buffer_clients_init(void);
+void lttng_ust_ring_buffer_clients_exit(void);
+
+void lttng_ust_counter_clients_init(void);
+void lttng_ust_counter_clients_exit(void);
+
#endif /* _LTTNG_RB_CLIENT_H */
#define RING_BUFFER_MODE_TEMPLATE RING_BUFFER_DISCARD
#define RING_BUFFER_MODE_TEMPLATE_STRING "discard-rt"
+#define RING_BUFFER_MODE_TEMPLATE_TLS_FIXUP \
+ lttng_ust_fixup_ring_buffer_client_discard_rt_tls
#define RING_BUFFER_MODE_TEMPLATE_INIT \
lttng_ring_buffer_client_discard_rt_init
#define RING_BUFFER_MODE_TEMPLATE_EXIT \
#define RING_BUFFER_MODE_TEMPLATE RING_BUFFER_DISCARD
#define RING_BUFFER_MODE_TEMPLATE_STRING "discard"
+#define RING_BUFFER_MODE_TEMPLATE_TLS_FIXUP \
+ lttng_ust_fixup_ring_buffer_client_discard_tls
#define RING_BUFFER_MODE_TEMPLATE_INIT \
lttng_ring_buffer_client_discard_init
#define RING_BUFFER_MODE_TEMPLATE_EXIT \
#define RING_BUFFER_MODE_TEMPLATE RING_BUFFER_OVERWRITE
#define RING_BUFFER_MODE_TEMPLATE_STRING "overwrite-rt"
+#define RING_BUFFER_MODE_TEMPLATE_TLS_FIXUP \
+ lttng_ust_fixup_ring_buffer_client_overwrite_rt_tls
#define RING_BUFFER_MODE_TEMPLATE_INIT \
lttng_ring_buffer_client_overwrite_rt_init
#define RING_BUFFER_MODE_TEMPLATE_EXIT \
#define RING_BUFFER_MODE_TEMPLATE RING_BUFFER_OVERWRITE
#define RING_BUFFER_MODE_TEMPLATE_STRING "overwrite"
+#define RING_BUFFER_MODE_TEMPLATE_TLS_FIXUP \
+ lttng_ust_fixup_ring_buffer_client_overwrite_tls
#define RING_BUFFER_MODE_TEMPLATE_INIT \
lttng_ring_buffer_client_overwrite_init
#define RING_BUFFER_MODE_TEMPLATE_EXIT \
/*
* Force a read (imply TLS fixup for dlopen) of TLS variables.
*/
-static
-void lttng_fixup_rb_client_tls(void)
+void RING_BUFFER_MODE_TEMPLATE_TLS_FIXUP(void)
{
asm volatile ("" : : "m" (URCU_TLS(private_ctx_stack)));
}
{
DBG("LTT : ltt ring buffer client \"%s\" init\n",
"relay-" RING_BUFFER_MODE_TEMPLATE_STRING "-mmap");
- lttng_fixup_rb_client_tls();
lttng_transport_register(<tng_relay_transport);
}
static const char *str_timeout;
static int got_timeout_env;
-extern void lttng_ring_buffer_client_overwrite_init(void);
-extern void lttng_ring_buffer_client_overwrite_rt_init(void);
-extern void lttng_ring_buffer_client_discard_init(void);
-extern void lttng_ring_buffer_client_discard_rt_init(void);
-extern void lttng_ring_buffer_metadata_client_init(void);
-extern void lttng_ring_buffer_client_overwrite_exit(void);
-extern void lttng_ring_buffer_client_overwrite_rt_exit(void);
-extern void lttng_ring_buffer_client_discard_exit(void);
-extern void lttng_ring_buffer_client_discard_rt_exit(void);
-extern void lttng_ring_buffer_metadata_client_exit(void);
-
static char *get_map_shm(struct sock_info *sock_info);
ssize_t lttng_ust_read(int fd, void *buf, size_t len)
lttng_fixup_net_ns_tls();
lttng_fixup_time_ns_tls();
lttng_fixup_uts_ns_tls();
+ lttng_ust_fixup_ring_buffer_client_discard_tls();
+ lttng_ust_fixup_ring_buffer_client_discard_rt_tls();
+ lttng_ust_fixup_ring_buffer_client_overwrite_tls();
+ lttng_ust_fixup_ring_buffer_client_overwrite_rt_tls();
+}
+
+/*
+ * LTTng-UST uses Global Dynamic model TLS variables rather than IE
+ * model because many versions of glibc don't preallocate a pool large
+ * enough for TLS variables IE model defined in other shared libraries,
+ * and causes issues when using LTTng-UST for Java tracing.
+ *
+ * Because of this use of Global Dynamic TLS variables, users wishing to
+ * trace from signal handlers need to explicitly trigger the lazy
+ * allocation of those variables for each thread before using them.
+ * This can be triggered by calling lttng_ust_init_thread().
+ */
+void lttng_ust_init_thread(void)
+{
+ /*
+ * Because those TLS variables are global dynamic, we need to
+ * ensure those are initialized before a signal handler nesting over
+ * this thread attempts to use them.
+ */
+ lttng_ust_fixup_tls();
}
int lttng_get_notify_socket(void *owner)
{
}
+void lttng_ust_ring_buffer_clients_init(void)
+{
+ lttng_ring_buffer_metadata_client_init();
+ lttng_ring_buffer_client_overwrite_init();
+ lttng_ring_buffer_client_overwrite_rt_init();
+ lttng_ring_buffer_client_discard_init();
+ lttng_ring_buffer_client_discard_rt_init();
+}
+
+void lttng_ust_ring_buffer_clients_exit(void)
+{
+ lttng_ring_buffer_client_discard_rt_exit();
+ lttng_ring_buffer_client_discard_exit();
+ lttng_ring_buffer_client_overwrite_rt_exit();
+ lttng_ring_buffer_client_overwrite_exit();
+ lttng_ring_buffer_metadata_client_exit();
+}
+
+void lttng_ust_counter_clients_init(void)
+{
+ lttng_counter_client_percpu_64_modular_init();
+ lttng_counter_client_percpu_32_modular_init();
+}
+
+void lttng_ust_counter_clients_exit(void)
+{
+ lttng_counter_client_percpu_32_modular_exit();
+ lttng_counter_client_percpu_64_modular_exit();
+}
+
/*
* sessiond monitoring thread: monitor presence of global and per-user
* sessiond by polling the application common named pipe.
lttng_ust_clock_init();
lttng_ust_getcpu_init();
lttng_ust_statedump_init();
- lttng_ring_buffer_metadata_client_init();
- lttng_ring_buffer_client_overwrite_init();
- lttng_ring_buffer_client_overwrite_rt_init();
- lttng_ring_buffer_client_discard_init();
- lttng_ring_buffer_client_discard_rt_init();
- lttng_counter_client_percpu_32_modular_init();
- lttng_counter_client_percpu_64_modular_init();
+ lttng_ust_ring_buffer_clients_init();
+ lttng_ust_counter_clients_init();
lttng_perf_counter_init();
/*
* Invoke ust malloc wrapper init before starting other threads.
lttng_ust_abi_exit();
lttng_ust_abi_events_exit();
lttng_perf_counter_exit();
- lttng_ring_buffer_client_discard_rt_exit();
- lttng_ring_buffer_client_discard_exit();
- lttng_ring_buffer_client_overwrite_rt_exit();
- lttng_ring_buffer_client_overwrite_exit();
- lttng_ring_buffer_metadata_client_exit();
- lttng_counter_client_percpu_32_modular_exit();
- lttng_counter_client_percpu_64_modular_exit();
+ lttng_ust_ring_buffer_clients_exit();
+ lttng_ust_counter_clients_exit();
lttng_ust_statedump_destroy();
lttng_ust_tp_exit();
if (!exiting) {
void lttng_ust_format_event_name(const struct lttng_ust_event_desc *desc,
char *name);
+__attribute__((visibility("hidden")))
+void lttng_ring_buffer_client_overwrite_init(void);
+__attribute__((visibility("hidden")))
+void lttng_ring_buffer_client_overwrite_rt_init(void);
+__attribute__((visibility("hidden")))
+void lttng_ring_buffer_client_discard_init(void);
+__attribute__((visibility("hidden")))
+void lttng_ring_buffer_client_discard_rt_init(void);
+__attribute__((visibility("hidden")))
+void lttng_ring_buffer_metadata_client_init(void);
+
+__attribute__((visibility("hidden")))
+void lttng_ring_buffer_client_overwrite_exit(void);
+__attribute__((visibility("hidden")))
+void lttng_ring_buffer_client_overwrite_rt_exit(void);
+__attribute__((visibility("hidden")))
+void lttng_ring_buffer_client_discard_exit(void);
+__attribute__((visibility("hidden")))
+void lttng_ring_buffer_client_discard_rt_exit(void);
+__attribute__((visibility("hidden")))
+void lttng_ring_buffer_metadata_client_exit(void);
+
+__attribute__((visibility("hidden")))
+void lttng_ust_fixup_ring_buffer_client_overwrite_tls(void);
+__attribute__((visibility("hidden")))
+void lttng_ust_fixup_ring_buffer_client_overwrite_rt_tls(void);
+__attribute__((visibility("hidden")))
+void lttng_ust_fixup_ring_buffer_client_discard_tls(void);
+__attribute__((visibility("hidden")))
+void lttng_ust_fixup_ring_buffer_client_discard_rt_tls(void);
+
#endif /* _LTTNG_UST_EVENTS_INTERNAL_H */