From 0fdd0b8989a06910521827f82058f7100d9b6b8e Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 9 Feb 2018 15:15:20 -0500 Subject: [PATCH] Remove duplicate provider name checks It's now possible to register a probe provider with a name that has already been registered. This is useful when wanting to load a new version of a shared library on a already running process. Changes are necessary in the lttng-session daemon to support cases where the newly register event has a different probe payload. Taking a simple case where a probe provider is registered twice, the tracepoint call site will have two probes registered to it and thus will generate two events in the trace. Signed-off-by: Mathieu Desnoyers Signed-off-by: Francis Deslauriers Signed-off-by: Mathieu Desnoyers --- include/lttng/ust-tracepoint-event.h | 2 +- liblttng-ust/lttng-events.c | 11 ----------- liblttng-ust/lttng-probes.c | 23 +---------------------- 3 files changed, 2 insertions(+), 34 deletions(-) diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 15399c7c..ec292d24 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -1007,7 +1007,7 @@ _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void) _TP_COMBINE_TOKENS(__tracepoint_provider_check_, TRACEPOINT_PROVIDER)(); ret = lttng_probe_register(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER)); if (ret) { - fprintf(stderr, "LTTng-UST: Error (%d) while registering tracepoint probe. Duplicate registration of tracepoint probes having the same name is not allowed.\n", ret); + fprintf(stderr, "LTTng-UST: Error (%d) while registering tracepoint probe.\n", ret); abort(); } } diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c index bfdae4ff..f4a7cccd 100644 --- a/liblttng-ust/lttng-events.c +++ b/liblttng-ust/lttng-events.c @@ -537,7 +537,6 @@ int lttng_event_create(const struct lttng_event_desc *desc, struct lttng_event *event; struct lttng_session *session = chan->session; struct cds_hlist_head *head; - struct cds_hlist_node *node; int ret = 0; size_t name_len = strlen(event_name); uint32_t hash; @@ -546,15 +545,6 @@ int lttng_event_create(const struct lttng_event_desc *desc, hash = jhash(event_name, name_len, 0); head = &chan->session->events_ht.table[hash & (LTTNG_UST_EVENT_HT_SIZE - 1)]; - cds_hlist_for_each_entry(event, node, head, hlist) { - assert(event->desc); - if (!strncmp(event->desc->name, desc->name, - LTTNG_UST_SYM_NAME_LEN - 1) - && chan == event->chan) { - ret = -EEXIST; - goto exist; - } - } notify_socket = lttng_get_notify_socket(session->owner); if (notify_socket < 0) { @@ -623,7 +613,6 @@ sessiond_register_error: cache_error: create_enum_error: socket_error: -exist: return ret; } diff --git a/liblttng-ust/lttng-probes.c b/liblttng-ust/lttng-probes.c index 390265ad..a09497f8 100644 --- a/liblttng-ust/lttng-probes.c +++ b/liblttng-ust/lttng-probes.c @@ -147,20 +147,6 @@ struct cds_list_head *lttng_get_probe_list_head(void) return &_probe_list; } -static -const struct lttng_probe_desc *find_provider(const char *provider) -{ - struct lttng_probe_desc *iter; - struct cds_list_head *probe_list; - - probe_list = lttng_get_probe_list_head(); - cds_list_for_each_entry(iter, probe_list, head) { - if (!strcmp(iter->provider, provider)) - return iter; - } - return NULL; -} - static int check_provider_version(struct lttng_probe_desc *desc) { @@ -206,13 +192,6 @@ int lttng_probe_register(struct lttng_probe_desc *desc) ust_lock_nocheck(); - /* - * Check if the provider has already been registered. - */ - if (find_provider(desc->provider)) { - ret = -EEXIST; - goto end; - } cds_list_add(&desc->lazy_init_head, &lazy_probe_init); desc->lazy = 1; DBG("adding probe %s containing %u events to lazy registration list", @@ -224,7 +203,7 @@ int lttng_probe_register(struct lttng_probe_desc *desc) */ if (lttng_session_active()) fixup_lazy_probes(); -end: + ust_unlock(); return ret; } -- 2.34.1