X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ftrace-ust.cpp;h=de368a3baa054a25616f342017b0d1fdc3ecf1f4;hp=bf57a4056df382c0210eec5dde37298b78831fe1;hb=HEAD;hpb=28ab034a2c3582d07d3423d2d746731f87d3969f diff --git a/src/bin/lttng-sessiond/trace-ust.cpp b/src/bin/lttng-sessiond/trace-ust.cpp index bf57a4056..e4fdef9ad 100644 --- a/src/bin/lttng-sessiond/trace-ust.cpp +++ b/src/bin/lttng-sessiond/trace-ust.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -174,7 +175,7 @@ struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht, cons lttng_ht_lookup(ht, (void *) name, &iter); node = lttng_ht_iter_get_node_str(&iter); - if (node == NULL) { + if (node == nullptr) { goto error; } @@ -184,7 +185,7 @@ struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht, cons error: DBG2("Trace UST channel %s not found by name", name); - return NULL; + return nullptr; } /* @@ -218,7 +219,7 @@ struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, &key, &iter.iter); node = lttng_ht_iter_get_node_str(&iter); - if (node == NULL) { + if (node == nullptr) { goto error; } @@ -228,7 +229,7 @@ struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, error: DBG2("Trace UST event %s NOT found", key.name); - return NULL; + return nullptr; } /* @@ -241,7 +242,7 @@ error: struct agent *trace_ust_find_agent(struct ltt_ust_session *session, enum lttng_domain_type domain_type) { - struct agent *agt = NULL; + struct agent *agt = nullptr; struct lttng_ht_node_u64 *node; struct lttng_ht_iter iter; uint64_t key; @@ -274,7 +275,7 @@ struct ltt_ust_session *trace_ust_create_session(uint64_t session_id) /* Allocate a new ltt ust session */ lus = zmalloc(); - if (lus == NULL) { + if (lus == nullptr) { PERROR("create ust session zmalloc"); goto error_alloc; } @@ -321,7 +322,7 @@ struct ltt_ust_session *trace_ust_create_session(uint64_t session_id) goto error; } lus->consumer = consumer_create_output(CONSUMER_DST_LOCAL); - if (lus->consumer == NULL) { + if (lus->consumer == nullptr) { goto error; } @@ -337,7 +338,7 @@ error: lttng_ht_destroy(lus->agents); free(lus); error_alloc: - return NULL; + return nullptr; } /* @@ -353,7 +354,7 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, LTTNG_ASSERT(chan); luc = zmalloc(); - if (luc == NULL) { + if (luc == nullptr) { PERROR("ltt_ust_channel zmalloc"); goto error; } @@ -464,7 +465,7 @@ enum lttng_error_code trace_ust_create_event(struct lttng_event *ev, } local_ust_event = zmalloc(); - if (local_ust_event == NULL) { + if (local_ust_event == nullptr) { PERROR("ust event zmalloc"); ret = LTTNG_ERR_NOMEM; goto error; @@ -645,15 +646,15 @@ int trace_ust_match_context(const struct ltt_ust_context *uctx, } if (strncmp(uctx->ctx.u.perf_counter.name, ctx->u.perf_counter.name, - LTTNG_UST_ABI_SYM_NAME_LEN)) { + LTTNG_UST_ABI_SYM_NAME_LEN) != 0) { return 0; } break; case LTTNG_UST_ABI_CONTEXT_APP_CONTEXT: LTTNG_ASSERT(uctx->ctx.u.app_ctx.provider_name); LTTNG_ASSERT(uctx->ctx.u.app_ctx.ctx_name); - if (strcmp(uctx->ctx.u.app_ctx.provider_name, ctx->u.app_ctx.provider_name) || - strcmp(uctx->ctx.u.app_ctx.ctx_name, ctx->u.app_ctx.ctx_name)) { + if (strcmp(uctx->ctx.u.app_ctx.provider_name, ctx->u.app_ctx.provider_name) != 0 || + strcmp(uctx->ctx.u.app_ctx.ctx_name, ctx->u.app_ctx.ctx_name) != 0) { return 0; } default: @@ -669,7 +670,7 @@ int trace_ust_match_context(const struct ltt_ust_context *uctx, */ struct ltt_ust_context *trace_ust_create_context(const struct lttng_event_context *ctx) { - struct ltt_ust_context *uctx = NULL; + struct ltt_ust_context *uctx = nullptr; int utype; LTTNG_ASSERT(ctx); @@ -698,7 +699,7 @@ struct ltt_ust_context *trace_ust_create_context(const struct lttng_event_contex break; case LTTNG_UST_ABI_CONTEXT_APP_CONTEXT: { - char *provider_name = NULL, *ctx_name = NULL; + char *provider_name = nullptr, *ctx_name = nullptr; provider_name = strdup(ctx->u.app_ctx.provider_name); if (!provider_name) { @@ -721,7 +722,7 @@ end: return uctx; error: trace_ust_destroy_context(uctx); - return NULL; + return nullptr; } static void destroy_id_tracker_node_rcu(struct rcu_head *head) @@ -761,16 +762,20 @@ static void fini_id_tracker(struct ust_id_tracker *id_tracker) if (!id_tracker->ht) { return; } - rcu_read_lock(); - cds_lfht_for_each_entry (id_tracker->ht->ht, &iter.iter, tracker_node, node.node) { - int ret = lttng_ht_del(id_tracker->ht, &iter); - LTTNG_ASSERT(!ret); - destroy_id_tracker_node(tracker_node); + { + lttng::urcu::read_lock_guard read_lock; + + cds_lfht_for_each_entry (id_tracker->ht->ht, &iter.iter, tracker_node, node.node) { + int ret = lttng_ht_del(id_tracker->ht, &iter); + + LTTNG_ASSERT(!ret); + destroy_id_tracker_node(tracker_node); + } } - rcu_read_unlock(); + lttng_ht_destroy(id_tracker->ht); - id_tracker->ht = NULL; + id_tracker->ht = nullptr; } static struct ust_id_tracker_node * @@ -784,7 +789,7 @@ id_tracker_lookup(struct ust_id_tracker *id_tracker, int id, struct lttng_ht_ite if (node) { return lttng::utils::container_of(node, &ust_id_tracker_node::node); } else { - return NULL; + return nullptr; } } @@ -850,7 +855,7 @@ static struct ust_id_tracker *get_id_tracker(struct ltt_ust_session *session, case LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID: return &session->vgid_tracker; default: - return NULL; + return nullptr; } } @@ -866,7 +871,7 @@ _trace_ust_get_process_attr_tracker(struct ltt_ust_session *session, case LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID: return session->tracker_vgid; default: - return NULL; + return nullptr; } } @@ -1202,18 +1207,20 @@ static void destroy_contexts(struct lttng_ht *ht) LTTNG_ASSERT(ht); - rcu_read_lock(); - cds_lfht_for_each_entry (ht->ht, &iter.iter, node, node) { - /* Remove from ordered list. */ - ctx = lttng::utils::container_of(node, <t_ust_context::node); - cds_list_del(&ctx->list); - /* Remove from channel's hash table. */ - ret = lttng_ht_del(ht, &iter); - if (!ret) { - call_rcu(&node->head, destroy_context_rcu); + { + lttng::urcu::read_lock_guard read_lock; + + cds_lfht_for_each_entry (ht->ht, &iter.iter, node, node) { + /* Remove from ordered list. */ + ctx = lttng::utils::container_of(node, <t_ust_context::node); + cds_list_del(&ctx->list); + /* Remove from channel's hash table. */ + ret = lttng_ht_del(ht, &iter); + if (!ret) { + call_rcu(&node->head, destroy_context_rcu); + } } } - rcu_read_unlock(); lttng_ht_destroy(ht); } @@ -1268,13 +1275,15 @@ static void destroy_events(struct lttng_ht *events) LTTNG_ASSERT(events); - rcu_read_lock(); - cds_lfht_for_each_entry (events->ht, &iter.iter, node, node) { - ret = lttng_ht_del(events, &iter); - LTTNG_ASSERT(!ret); - call_rcu(&node->head, destroy_event_rcu); + { + lttng::urcu::read_lock_guard read_lock; + + cds_lfht_for_each_entry (events->ht, &iter.iter, node, node) { + ret = lttng_ht_del(events, &iter); + LTTNG_ASSERT(!ret); + call_rcu(&node->head, destroy_event_rcu); + } } - rcu_read_unlock(); lttng_ht_destroy(events); } @@ -1333,10 +1342,10 @@ void trace_ust_delete_channel(struct lttng_ht *ht, struct ltt_ust_channel *chann int trace_ust_regenerate_metadata(struct ltt_ust_session *usess) { int ret = 0; - struct buffer_reg_uid *uid_reg = NULL; - struct buffer_reg_session *session_reg = NULL; + struct buffer_reg_uid *uid_reg = nullptr; + struct buffer_reg_session *session_reg = nullptr; - rcu_read_lock(); + lttng::urcu::read_lock_guard read_lock; cds_list_for_each_entry (uid_reg, &usess->buffer_reg_uid_list, lnode) { lsu::registry_session *registry; @@ -1353,7 +1362,6 @@ int trace_ust_regenerate_metadata(struct ltt_ust_session *usess) } end: - rcu_read_unlock(); return ret; } @@ -1367,15 +1375,17 @@ static void destroy_channels(struct lttng_ht *channels) LTTNG_ASSERT(channels); - rcu_read_lock(); - cds_lfht_for_each_entry (channels->ht, &iter.iter, node, node) { - struct ltt_ust_channel *chan = - lttng::utils::container_of(node, <t_ust_channel::node); + { + lttng::urcu::read_lock_guard read_lock; + + cds_lfht_for_each_entry (channels->ht, &iter.iter, node, node) { + struct ltt_ust_channel *chan = + lttng::utils::container_of(node, <t_ust_channel::node); - trace_ust_delete_channel(channels, chan); - trace_ust_destroy_channel(chan); + trace_ust_delete_channel(channels, chan); + trace_ust_destroy_channel(chan); + } } - rcu_read_unlock(); lttng_ht_destroy(channels); } @@ -1407,14 +1417,16 @@ void trace_ust_destroy_session(struct ltt_ust_session *session) /* Cleaning up UST domain */ destroy_domain_global(&session->domain_global); - rcu_read_lock(); - cds_lfht_for_each_entry (session->agents->ht, &iter.iter, agt, node.node) { - int ret = lttng_ht_del(session->agents, &iter); + { + lttng::urcu::read_lock_guard read_lock; + + cds_lfht_for_each_entry (session->agents->ht, &iter.iter, agt, node.node) { + int ret = lttng_ht_del(session->agents, &iter); - LTTNG_ASSERT(!ret); - agent_destroy(agt); + LTTNG_ASSERT(!ret); + agent_destroy(agt); + } } - rcu_read_unlock(); lttng_ht_destroy(session->agents);