X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;ds=sidebyside;f=liblttng-ust%2Ftracepoint.c;h=0393aa467a282b17139a05ae17fd8336e7271fb9;hb=f1fffc5728684ddf7ec3c674515c313e693bd3c4;hp=e62b11c73f23117c9275bed67bfbafc40f0d02f1;hpb=35897f8b2d311b756b81657dad9c53ef1c0fad8a;p=lttng-ust.git diff --git a/liblttng-ust/tracepoint.c b/liblttng-ust/tracepoint.c index e62b11c7..0393aa46 100644 --- a/liblttng-ust/tracepoint.c +++ b/liblttng-ust/tracepoint.c @@ -21,17 +21,20 @@ #define _LGPL_SOURCE #include -#include #include #include + #include #include #include #include #include + +#include + +#include #include -#include #include "tracepoint-internal.h" #include "ltt-tracer-core.h" #include "jhash.h" @@ -42,7 +45,10 @@ static const int tracepoint_debug; static int initialized; static void (*new_tracepoint_cb)(struct tracepoint *); -/* libraries that contain tracepoints (struct tracepoint_lib) */ +/* + * libraries that contain tracepoints (struct tracepoint_lib). + * Protected by UST lock. + */ static CDS_LIST_HEAD(libs); /* @@ -55,7 +61,7 @@ static CDS_LIST_HEAD(libs); /* * Tracepoint hash table, containing the active tracepoints. - * Protected by tracepoints_mutex. + * Protected by ust lock. */ #define TRACEPOINT_HASH_BITS 6 #define TRACEPOINT_TABLE_SIZE (1 << TRACEPOINT_HASH_BITS) @@ -68,7 +74,7 @@ static int need_update; * Note about RCU : * It is used to to delay the free of multiple probes array until a quiescent * state is reached. - * Tracepoint entries modifications are protected by the tracepoints_mutex. + * Tracepoint entries modifications are protected by the ust lock. */ struct tracepoint_entry { struct cds_hlist_node hlist; @@ -84,14 +90,14 @@ struct tp_probes { struct tracepoint_probe probes[0]; }; -static inline void *allocate_probes(int count) +static void *allocate_probes(int count) { struct tp_probes *p = zmalloc(count * sizeof(struct tracepoint_probe) + sizeof(struct tp_probes)); return p == NULL ? NULL : p->probes; } -static inline void release_probes(void *old) +static void release_probes(void *old) { if (old) { struct tp_probes *tp_probes = caa_container_of(old, @@ -193,7 +199,7 @@ tracepoint_entry_remove_probe(struct tracepoint_entry *entry, void *probe, /* * Get tracepoint if the tracepoint is present in the tracepoint hash table. - * Must be called with tracepoints_mutex held. + * Must be called with ust lock held. * Returns NULL if not present. */ static struct tracepoint_entry *get_tracepoint(const char *name) @@ -213,7 +219,7 @@ static struct tracepoint_entry *get_tracepoint(const char *name) /* * Add the tracepoint to the tracepoint hash table. Must be called with - * tracepoints_mutex held. + * ust lock held. */ static struct tracepoint_entry *add_tracepoint(const char *name) { @@ -248,7 +254,7 @@ static struct tracepoint_entry *add_tracepoint(const char *name) * Remove the tracepoint from the tracepoint hash table. Must be called with * ust_lock held. */ -static inline void remove_tracepoint(struct tracepoint_entry *e) +static void remove_tracepoint(struct tracepoint_entry *e) { cds_hlist_del(&e->hlist); free(e); @@ -488,105 +494,6 @@ void tracepoint_probe_update_all(void) } } -/* - * Returns 0 if current not found. - * Returns 1 if current found. - * - * Called with tracepoint mutex held - */ -int lib_get_iter_tracepoints(struct tracepoint_iter *iter) -{ - struct tracepoint_lib *iter_lib; - int found = 0; - - cds_list_for_each_entry(iter_lib, &libs, list) { - if (iter_lib < iter->lib) - continue; - else if (iter_lib > iter->lib) - iter->tracepoint = NULL; - found = tracepoint_get_iter_range(&iter->tracepoint, - iter_lib->tracepoints_start, - iter_lib->tracepoints_start + iter_lib->tracepoints_count); - if (found) { - iter->lib = iter_lib; - break; - } - } - return found; -} - -/** - * tracepoint_get_iter_range - Get a next tracepoint iterator given a range. - * @tracepoint: current tracepoints (in), next tracepoint (out) - * @begin: beginning of the range - * @end: end of the range - * - * Returns whether a next tracepoint has been found (1) or not (0). - * Will return the first tracepoint in the range if the input tracepoint is - * NULL. - * Called with tracepoint mutex held. - */ -int tracepoint_get_iter_range(struct tracepoint * const **tracepoint, - struct tracepoint * const *begin, struct tracepoint * const *end) -{ - if (!*tracepoint && begin != end) - *tracepoint = begin; - while (*tracepoint >= begin && *tracepoint < end) { - if (!**tracepoint) - (*tracepoint)++; /* skip dummy */ - else - return 1; - } - return 0; -} - -/* - * Called with tracepoint mutex held. - */ -static void tracepoint_get_iter(struct tracepoint_iter *iter) -{ - int found = 0; - - /* tracepoints in libs. */ - found = lib_get_iter_tracepoints(iter); - if (!found) - tracepoint_iter_reset(iter); -} - -/* - * Called with UST lock held. - */ -void tracepoint_iter_start(struct tracepoint_iter *iter) -{ - tracepoint_get_iter(iter); -} - -/* - * Called with UST lock held. - */ -void tracepoint_iter_next(struct tracepoint_iter *iter) -{ - iter->tracepoint++; - /* - * iter->tracepoint may be invalid because we blindly incremented it. - * Make sure it is valid by marshalling on the tracepoints, getting the - * tracepoints from following modules if necessary. - */ - tracepoint_get_iter(iter); -} - -/* - * Called with UST lock held. - */ -void tracepoint_iter_stop(struct tracepoint_iter *iter) -{ -} - -void tracepoint_iter_reset(struct tracepoint_iter *iter) -{ - iter->tracepoint = NULL; -} - void tracepoint_set_new_tracepoint_cb(void (*cb)(struct tracepoint *)) { new_tracepoint_cb = cb; @@ -672,3 +579,25 @@ void exit_tracepoint(void) { initialized = 0; } + +/* + * Create the wrapper symbols. + */ +#undef tp_rcu_read_lock_bp +#undef tp_rcu_read_unlock_bp +#undef tp_rcu_dereference_bp + +void tp_rcu_read_lock_bp(void) +{ + rcu_read_lock_bp(); +} + +void tp_rcu_read_unlock_bp(void) +{ + rcu_read_unlock_bp(); +} + +void *tp_rcu_dereference_sym_bp(void *p) +{ + return rcu_dereference_bp(p); +}