X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=liblttng-ust%2Ftracepoint.c;h=00fcc740101b5f443d77fba5b8596f3053643302;hb=f1324c1158b8ad5b9dd8bcc55e2a1a26ab2113ae;hp=e0b5da3f46386fb39312a743d002db0efdddcacb;hpb=2b6f437483769831e50886b9f3bc4710b28f4ac9;p=lttng-ust.git diff --git a/liblttng-ust/tracepoint.c b/liblttng-ust/tracepoint.c index e0b5da3f..00fcc740 100644 --- a/liblttng-ust/tracepoint.c +++ b/liblttng-ust/tracepoint.c @@ -21,7 +21,7 @@ #include #include -#include /* for LTTNG_UST_SYM_NAME_LEN */ +#include /* for LTTNG_UST_ABI_SYM_NAME_LEN */ #include #include @@ -145,7 +145,7 @@ static void release_probes(void *old) if (old) { struct tp_probes *tp_probes = caa_container_of(old, struct tp_probes, probes[0]); - lttng_ust_synchronize_trace(); + lttng_ust_urcu_synchronize_rcu(); free(tp_probes); } } @@ -256,14 +256,14 @@ static struct tracepoint_entry *get_tracepoint(const char *name) size_t name_len = strlen(name); uint32_t hash; - if (name_len > LTTNG_UST_SYM_NAME_LEN - 1) { - WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_SYM_NAME_LEN - 1); - name_len = LTTNG_UST_SYM_NAME_LEN - 1; + if (name_len > LTTNG_UST_ABI_SYM_NAME_LEN - 1) { + WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_ABI_SYM_NAME_LEN - 1); + name_len = LTTNG_UST_ABI_SYM_NAME_LEN - 1; } hash = jhash(name, name_len, 0); head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)]; cds_hlist_for_each_entry(e, node, head, hlist) { - if (!strncmp(name, e->name, LTTNG_UST_SYM_NAME_LEN - 1)) + if (!strncmp(name, e->name, LTTNG_UST_ABI_SYM_NAME_LEN - 1)) return e; } return NULL; @@ -284,14 +284,14 @@ static struct tracepoint_entry *add_tracepoint(const char *name, size_t sig_off, name_off; uint32_t hash; - if (name_len > LTTNG_UST_SYM_NAME_LEN - 1) { - WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_SYM_NAME_LEN - 1); - name_len = LTTNG_UST_SYM_NAME_LEN - 1; + if (name_len > LTTNG_UST_ABI_SYM_NAME_LEN - 1) { + WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_ABI_SYM_NAME_LEN - 1); + name_len = LTTNG_UST_ABI_SYM_NAME_LEN - 1; } hash = jhash(name, name_len, 0); head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)]; cds_hlist_for_each_entry(e, node, head, hlist) { - if (!strncmp(name, e->name, LTTNG_UST_SYM_NAME_LEN - 1)) { + if (!strncmp(name, e->name, LTTNG_UST_ABI_SYM_NAME_LEN - 1)) { DBG("tracepoint %s busy", name); return ERR_PTR(-EEXIST); /* Already there */ } @@ -339,7 +339,7 @@ static void remove_tracepoint(struct tracepoint_entry *e) static void set_tracepoint(struct tracepoint_entry **entry, struct lttng_ust_tracepoint *elem, int active) { - WARN_ON(strncmp((*entry)->name, elem->name, LTTNG_UST_SYM_NAME_LEN - 1) != 0); + WARN_ON(strncmp((*entry)->name, elem->name, LTTNG_UST_ABI_SYM_NAME_LEN - 1) != 0); /* * Check that signatures match before connecting a probe to a * tracepoint. Warn the user if they don't. @@ -394,9 +394,9 @@ static void add_callsite(struct tracepoint_lib * lib, struct lttng_ust_tracepoin uint32_t hash; struct tracepoint_entry *tp_entry; - if (name_len > LTTNG_UST_SYM_NAME_LEN - 1) { - WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_SYM_NAME_LEN - 1); - name_len = LTTNG_UST_SYM_NAME_LEN - 1; + if (name_len > LTTNG_UST_ABI_SYM_NAME_LEN - 1) { + WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_ABI_SYM_NAME_LEN - 1); + name_len = LTTNG_UST_ABI_SYM_NAME_LEN - 1; } hash = jhash(name, name_len, 0); head = &callsite_table[hash & (CALLSITE_TABLE_SIZE - 1)]; @@ -451,16 +451,16 @@ static void tracepoint_sync_callsites(const char *name) struct tracepoint_entry *tp_entry; tp_entry = get_tracepoint(name); - if (name_len > LTTNG_UST_SYM_NAME_LEN - 1) { - WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_SYM_NAME_LEN - 1); - name_len = LTTNG_UST_SYM_NAME_LEN - 1; + if (name_len > LTTNG_UST_ABI_SYM_NAME_LEN - 1) { + WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_ABI_SYM_NAME_LEN - 1); + name_len = LTTNG_UST_ABI_SYM_NAME_LEN - 1; } hash = jhash(name, name_len, 0); head = &callsite_table[hash & (CALLSITE_TABLE_SIZE - 1)]; cds_hlist_for_each_entry(e, node, head, hlist) { struct lttng_ust_tracepoint *tp = e->tp; - if (strncmp(name, tp->name, LTTNG_UST_SYM_NAME_LEN - 1)) + if (strncmp(name, tp->name, LTTNG_UST_ABI_SYM_NAME_LEN - 1)) continue; if (tp_entry) { if (!e->tp_entry_callsite_ref) { @@ -619,10 +619,10 @@ end: /* * Caller needs to invoke __tracepoint_probe_release_queue() after - * calling __tracepoint_probe_register_queue_release() one or multiple + * calling lttng_ust_tp_probe_register_queue_release() one or multiple * times to ensure it does not leak memory. */ -int __tracepoint_probe_register_queue_release(const char *name, +int lttng_ust_tp_probe_register_queue_release(const char *name, void (*probe)(void), void *data, const char *signature) { void *old; @@ -690,10 +690,10 @@ end: /* * Caller needs to invoke __tracepoint_probe_release_queue() after - * calling __tracepoint_probe_unregister_queue_release() one or multiple + * calling lttng_ust_tp_probe_unregister_queue_release() one or multiple * times to ensure it does not leak memory. */ -int __tracepoint_probe_unregister_queue_release(const char *name, +int lttng_ust_tp_probe_unregister_queue_release(const char *name, void (*probe)(void), void *data) { void *old; @@ -714,7 +714,7 @@ end: return ret; } -void __tracepoint_probe_prune_release_queue(void) +void lttng_ust_tp_probe_prune_release_queue(void) { CDS_LIST_HEAD(release_probes); struct tp_probes *pos, *next; @@ -729,7 +729,7 @@ void __tracepoint_probe_prune_release_queue(void) release_queue_need_update = 0; /* Wait for grace period between all sync_callsites and free. */ - lttng_ust_synchronize_trace(); + lttng_ust_urcu_synchronize_rcu(); cds_list_for_each_entry_safe(pos, next, &release_probes, u.list) { cds_list_del(&pos->u.list); @@ -820,7 +820,7 @@ void tracepoint_probe_update_all(void) tracepoint_update_probes(); /* Wait for grace period between update_probes and free. */ - lttng_ust_synchronize_trace(); + lttng_ust_urcu_synchronize_rcu(); cds_list_for_each_entry_safe(pos, next, &release_probes, u.list) { cds_list_del(&pos->u.list); free(pos); @@ -829,11 +829,6 @@ end: pthread_mutex_unlock(&tracepoint_mutex); } -void tracepoint_set_new_tracepoint_cb(void (*cb)(struct lttng_ust_tracepoint *)) -{ - new_tracepoint_cb = cb; -} - static void new_tracepoints(struct lttng_ust_tracepoint * const *start, struct lttng_ust_tracepoint * const *end) { @@ -859,12 +854,14 @@ static void new_tracepoints(struct lttng_ust_tracepoint * const *start, * against recent liblttng-ust headers require a recent liblttng-ust * runtime for those tracepoints to be taken into account. */ +int tracepoint_register_lib(struct lttng_ust_tracepoint * const *tracepoints_start, + int tracepoints_count); int tracepoint_register_lib(struct lttng_ust_tracepoint * const *tracepoints_start, int tracepoints_count) { struct tracepoint_lib *pl, *iter; - init_tracepoint(); + lttng_ust_tp_init(); pl = (struct tracepoint_lib *) zmalloc(sizeof(struct tracepoint_lib)); if (!pl) { @@ -908,6 +905,7 @@ lib_added: return 0; } +int tracepoint_unregister_lib(struct lttng_ust_tracepoint * const *tracepoints_start); int tracepoint_unregister_lib(struct lttng_ust_tracepoint * const *tracepoints_start) { struct tracepoint_lib *lib; @@ -956,7 +954,7 @@ static void check_weak_hidden(void) "DIFFERENT addresses"); } -void init_tracepoint(void) +void lttng_ust_tp_init(void) { if (uatomic_xchg(&initialized, 1) == 1) return; @@ -964,7 +962,7 @@ void init_tracepoint(void) check_weak_hidden(); } -void exit_tracepoint(void) +void lttng_ust_tp_exit(void) { initialized = 0; } @@ -976,16 +974,19 @@ void exit_tracepoint(void) #undef tp_rcu_read_unlock #undef tp_rcu_dereference +void tp_rcu_read_lock(void); void tp_rcu_read_lock(void) { lttng_ust_urcu_read_lock(); } +void tp_rcu_read_unlock(void); void tp_rcu_read_unlock(void) { lttng_ust_urcu_read_unlock(); } +void *tp_rcu_dereference_sym(void *p); void *tp_rcu_dereference_sym(void *p) { return lttng_ust_rcu_dereference(p); @@ -1002,6 +1003,7 @@ void *tp_rcu_dereference_sym(void *p) * dlopen(3) and dlsym(3) to get an handle on the * tp_disable_destructors and tp_get_destructors_state symbols below. */ +void tp_disable_destructors(void); void tp_disable_destructors(void) { uatomic_set(&tracepoint_destructors_state, 0); @@ -1011,12 +1013,8 @@ void tp_disable_destructors(void) * Returns 1 if the destructors are enabled and should be executed. * Returns 0 if the destructors are disabled. */ +int tp_get_destructors_state(void); int tp_get_destructors_state(void) { return uatomic_read(&tracepoint_destructors_state); } - -void lttng_ust_synchronize_trace(void) -{ - lttng_ust_urcu_synchronize_rcu(); -}