X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ftrace-ust.cpp;h=4a3e74de7792b8bc0b195b98f8bc15d9db9e5a10;hb=0114db0ec2407029052eb61a0189c9b1cd64d520;hp=ec62eef09810eca42ba55632f2898982560eaa99;hpb=ff9fe3137fc1aec6e18ebbf7c218907698206e7d;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/trace-ust.cpp b/src/bin/lttng-sessiond/trace-ust.cpp index ec62eef09..4a3e74de7 100644 --- a/src/bin/lttng-sessiond/trace-ust.cpp +++ b/src/bin/lttng-sessiond/trace-ust.cpp @@ -13,16 +13,18 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include "buffer-registry.h" -#include "trace-ust.h" -#include "utils.h" -#include "ust-app.h" -#include "agent.h" +#include "buffer-registry.hpp" +#include "trace-ust.hpp" +#include "utils.hpp" +#include "ust-app.hpp" +#include "agent.hpp" + +namespace lsu = lttng::sessiond::ust; /* * Match function for the events hash table lookup. @@ -167,6 +169,7 @@ struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht, struct lttng_ht_node_str *node; struct lttng_ht_iter iter; + ASSERT_RCU_READ_LOCKED(); /* * If we receive an empty string for channel name, it means the * default channel name is requested. @@ -182,7 +185,7 @@ struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht, DBG2("Trace UST channel %s found by name", name); - return caa_container_of(node, struct ltt_ust_channel, node); + return lttng::utils::container_of(node, <t_ust_channel::node); error: DBG2("Trace UST channel %s not found by name", name); @@ -204,6 +207,7 @@ struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, LTTNG_ASSERT(name); LTTNG_ASSERT(ht); + ASSERT_RCU_READ_LOCKED(); key.name = name; key.filter = filter; @@ -220,7 +224,7 @@ struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, DBG2("Trace UST event %s found", key.name); - return caa_container_of(node, struct ltt_ust_event, node); + return lttng::utils::container_of(node, <t_ust_event::node); error: DBG2("Trace UST event %s NOT found", key.name); @@ -253,7 +257,7 @@ struct agent *trace_ust_find_agent(struct ltt_ust_session *session, if (!node) { goto end; } - agt = caa_container_of(node, struct agent, node); + agt = lttng::utils::container_of(node, &agent::node); end: return agt; @@ -269,7 +273,7 @@ struct ltt_ust_session *trace_ust_create_session(uint64_t session_id) struct ltt_ust_session *lus; /* Allocate a new ltt ust session */ - lus = (ltt_ust_session *) zmalloc(sizeof(struct ltt_ust_session)); + lus = zmalloc(); if (lus == NULL) { PERROR("create ust session zmalloc"); goto error_alloc; @@ -329,8 +333,8 @@ error: process_attr_tracker_destroy(lus->tracker_vpid); process_attr_tracker_destroy(lus->tracker_vuid); process_attr_tracker_destroy(lus->tracker_vgid); - ht_cleanup_push(lus->domain_global.channels); - ht_cleanup_push(lus->agents); + lttng_ht_destroy(lus->domain_global.channels); + lttng_ht_destroy(lus->agents); free(lus); error_alloc: return NULL; @@ -348,7 +352,7 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, LTTNG_ASSERT(chan); - luc = (ltt_ust_channel *) zmalloc(sizeof(struct ltt_ust_channel)); + luc = zmalloc(); if (luc == NULL) { PERROR("ltt_ust_channel zmalloc"); goto error; @@ -461,7 +465,7 @@ enum lttng_error_code trace_ust_create_event(struct lttng_event *ev, goto error; } - local_ust_event = (ltt_ust_event *) zmalloc(sizeof(struct ltt_ust_event)); + local_ust_event = zmalloc(); if (local_ust_event == NULL) { PERROR("ust event zmalloc"); ret = LTTNG_ERR_NOMEM; @@ -685,7 +689,7 @@ struct ltt_ust_context *trace_ust_create_context( goto end; } - uctx = (ltt_ust_context *) zmalloc(sizeof(struct ltt_ust_context)); + uctx = zmalloc(); if (!uctx) { PERROR("zmalloc ltt_ust_context"); goto end; @@ -774,7 +778,7 @@ static void fini_id_tracker(struct ust_id_tracker *id_tracker) destroy_id_tracker_node(tracker_node); } rcu_read_unlock(); - ht_cleanup_push(id_tracker->ht); + lttng_ht_destroy(id_tracker->ht); id_tracker->ht = NULL; } @@ -789,7 +793,7 @@ static struct ust_id_tracker_node *id_tracker_lookup( lttng_ht_lookup(id_tracker->ht, (void *) _id, iter); node = lttng_ht_iter_get_node_ulong(iter); if (node) { - return caa_container_of(node, struct ust_id_tracker_node, node); + return lttng::utils::container_of(node, &ust_id_tracker_node::node); } else { return NULL; } @@ -811,7 +815,7 @@ static int id_tracker_add_id(struct ust_id_tracker *id_tracker, int id) retval = LTTNG_ERR_PROCESS_ATTR_EXISTS; goto end; } - tracker_node = (ust_id_tracker_node *) zmalloc(sizeof(*tracker_node)); + tracker_node = zmalloc(); if (!tracker_node) { retval = LTTNG_ERR_NOMEM; goto end; @@ -1199,9 +1203,9 @@ end: static void destroy_context_rcu(struct rcu_head *head) { struct lttng_ht_node_ulong *node = - caa_container_of(head, struct lttng_ht_node_ulong, head); + lttng::utils::container_of(head, <tng_ht_node_ulong::head); struct ltt_ust_context *ctx = - caa_container_of(node, struct ltt_ust_context, node); + lttng::utils::container_of(node, <t_ust_context::node); trace_ust_destroy_context(ctx); } @@ -1221,7 +1225,7 @@ static void destroy_contexts(struct lttng_ht *ht) rcu_read_lock(); cds_lfht_for_each_entry(ht->ht, &iter.iter, node, node) { /* Remove from ordered list. */ - ctx = caa_container_of(node, struct ltt_ust_context, node); + 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); @@ -1231,7 +1235,7 @@ static void destroy_contexts(struct lttng_ht *ht) } rcu_read_unlock(); - ht_cleanup_push(ht); + lttng_ht_destroy(ht); } /* @@ -1268,9 +1272,9 @@ void trace_ust_destroy_context(struct ltt_ust_context *ctx) static void destroy_event_rcu(struct rcu_head *head) { struct lttng_ht_node_str *node = - caa_container_of(head, struct lttng_ht_node_str, head); + lttng::utils::container_of(head, <tng_ht_node_str::head); struct ltt_ust_event *event = - caa_container_of(node, struct ltt_ust_event, node); + lttng::utils::container_of(node, <t_ust_event::node); trace_ust_destroy_event(event); } @@ -1294,7 +1298,7 @@ static void destroy_events(struct lttng_ht *events) } rcu_read_unlock(); - ht_cleanup_push(events); + lttng_ht_destroy(events); } /* @@ -1317,9 +1321,9 @@ static void _trace_ust_destroy_channel(struct ltt_ust_channel *channel) static void destroy_channel_rcu(struct rcu_head *head) { struct lttng_ht_node_str *node = - caa_container_of(head, struct lttng_ht_node_str, head); + lttng::utils::container_of(head, <tng_ht_node_str::head); struct ltt_ust_channel *channel = - caa_container_of(node, struct ltt_ust_channel, node); + lttng::utils::container_of(node, <t_ust_channel::node); _trace_ust_destroy_channel(channel); } @@ -1351,6 +1355,33 @@ void trace_ust_delete_channel(struct lttng_ht *ht, LTTNG_ASSERT(!ret); } +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; + + rcu_read_lock(); + cds_list_for_each_entry(uid_reg, &usess->buffer_reg_uid_list, lnode) { + lsu::registry_session *registry; + + session_reg = uid_reg->registry; + registry = session_reg->reg.ust; + + try { + registry->regenerate_metadata(); + } catch (const std::exception& ex) { + ERR("Failed to regenerate user space session metadata: %s", ex.what()); + ret = -1; + goto end; + } + } + +end: + rcu_read_unlock(); + return ret; +} + /* * Iterate over a hash table containing channels and cleanup safely. */ @@ -1364,14 +1395,14 @@ static void destroy_channels(struct lttng_ht *channels) rcu_read_lock(); cds_lfht_for_each_entry(channels->ht, &iter.iter, node, node) { struct ltt_ust_channel *chan = - caa_container_of(node, struct ltt_ust_channel, node); + lttng::utils::container_of(node, <t_ust_channel::node); trace_ust_delete_channel(channels, chan); trace_ust_destroy_channel(chan); } rcu_read_unlock(); - ht_cleanup_push(channels); + lttng_ht_destroy(channels); } /* @@ -1410,7 +1441,7 @@ void trace_ust_destroy_session(struct ltt_ust_session *session) } rcu_read_unlock(); - ht_cleanup_push(session->agents); + lttng_ht_destroy(session->agents); /* Cleanup UID buffer registry object(s). */ cds_list_for_each_entry_safe(reg, sreg, &session->buffer_reg_uid_list,