X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ftrace-ust.c;h=2c63ef0b5e65f7149e28eca47d6730cfeee3c9aa;hb=a1dcaf0fdbfbaf02ef38886b556c3d37e4458fdc;hp=8f15a1576a68375277609e0ffd50642d0fd4eb3c;hpb=7972aab22f74b18faa168c0482216a3dd711a075;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 8f15a1576..2c63ef0b5 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -26,6 +26,7 @@ #include "buffer-registry.h" #include "trace-ust.h" +#include "utils.h" /* * Match function for the events hash table lookup. @@ -180,8 +181,7 @@ error: * * Return pointer to structure or NULL. */ -struct ltt_ust_session *trace_ust_create_session(char *path, - unsigned int session_id) +struct ltt_ust_session *trace_ust_create_session(unsigned int session_id) { struct ltt_ust_session *lus; @@ -224,26 +224,12 @@ struct ltt_ust_session *trace_ust_create_session(char *path, */ lus->tmp_consumer = NULL; - /* Use the default consumer output which is the tracing session path. */ - if (*path != '\0') { - int ret; - - ret = snprintf(lus->consumer->dst.trace_path, PATH_MAX, - "%s" DEFAULT_UST_TRACE_DIR, path); - if (ret < 0) { - PERROR("snprintf UST consumer trace path"); - goto error_path; - } - } - DBG2("UST trace session create successful"); return lus; -error_path: - consumer_destroy_output(lus->consumer); error_consumer: - lttng_ht_destroy(lus->domain_global.channels); + ht_cleanup_push(lus->domain_global.channels); free(lus); error: return NULL; @@ -254,13 +240,11 @@ error: * * Return pointer to structure or NULL. */ -struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, - char *path) +struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan) { struct ltt_ust_channel *luc; assert(chan); - assert(path); luc = zmalloc(sizeof(struct ltt_ust_channel)); if (luc == NULL) { @@ -293,6 +277,10 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, luc->events = lttng_ht_new(0, LTTNG_HT_TYPE_STRING); luc->ctx = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG); + /* On-disk circular buffer parameters */ + luc->tracefile_size = chan->attr.tracefile_size; + luc->tracefile_count = chan->attr.tracefile_count; + DBG2("Trace UST channel %s created", luc->name); error: @@ -397,8 +385,8 @@ struct ltt_ust_metadata *trace_ust_create_metadata(char *path) lum->attr.overwrite = DEFAULT_CHANNEL_OVERWRITE; lum->attr.subbuf_size = default_get_metadata_subbuf_size(); lum->attr.num_subbuf = DEFAULT_METADATA_SUBBUF_NUM; - lum->attr.switch_timer_interval = DEFAULT_UST_CHANNEL_SWITCH_TIMER; - lum->attr.read_timer_interval = DEFAULT_UST_CHANNEL_READ_TIMER; + lum->attr.switch_timer_interval = DEFAULT_METADATA_SWITCH_TIMER; + lum->attr.read_timer_interval = DEFAULT_METADATA_READ_TIMER; lum->attr.output = LTTNG_UST_MMAP; lum->handle = -1; @@ -487,14 +475,16 @@ static void destroy_contexts(struct lttng_ht *ht) assert(ht); + rcu_read_lock(); cds_lfht_for_each_entry(ht->ht, &iter.iter, node, node) { ret = lttng_ht_del(ht, &iter); if (!ret) { call_rcu(&node->head, destroy_context_rcu); } } + rcu_read_unlock(); - lttng_ht_destroy(ht); + ht_cleanup_push(ht); } /* @@ -533,34 +523,34 @@ static void destroy_events(struct lttng_ht *events) assert(events); + rcu_read_lock(); cds_lfht_for_each_entry(events->ht, &iter.iter, node, node) { ret = lttng_ht_del(events, &iter); assert(!ret); call_rcu(&node->head, destroy_event_rcu); } + rcu_read_unlock(); - lttng_ht_destroy(events); + ht_cleanup_push(events); } /* * Cleanup ust channel structure. + * + * Should _NOT_ be called with RCU read lock held. */ -void trace_ust_destroy_channel(struct ltt_ust_channel *channel) +static void _trace_ust_destroy_channel(struct ltt_ust_channel *channel) { assert(channel); DBG2("Trace destroy UST channel %s", channel->name); - rcu_read_lock(); - /* Destroying all events of the channel */ destroy_events(channel->events); /* Destroying all context of the channel */ destroy_contexts(channel->ctx); free(channel); - - rcu_read_unlock(); } /* @@ -573,7 +563,29 @@ static void destroy_channel_rcu(struct rcu_head *head) struct ltt_ust_channel *channel = caa_container_of(node, struct ltt_ust_channel, node); - trace_ust_destroy_channel(channel); + _trace_ust_destroy_channel(channel); +} + +void trace_ust_destroy_channel(struct ltt_ust_channel *channel) +{ + call_rcu(&channel->node.head, destroy_channel_rcu); +} + +/* + * Remove an UST channel from a channel HT. + */ +void trace_ust_delete_channel(struct lttng_ht *ht, + struct ltt_ust_channel *channel) +{ + int ret; + struct lttng_ht_iter iter; + + assert(ht); + assert(channel); + + iter.iter.node = &channel->node.node; + ret = lttng_ht_del(ht, &iter); + assert(!ret); } /* @@ -608,10 +620,9 @@ static void destroy_channels(struct lttng_ht *channels) assert(!ret); call_rcu(&node->head, destroy_channel_rcu); } - - lttng_ht_destroy(channels); - rcu_read_unlock(); + + ht_cleanup_push(channels); } /* @@ -626,6 +637,8 @@ static void destroy_domain_global(struct ltt_ust_domain_global *dom) /* * Cleanup ust session structure + * + * Should *NOT* be called with RCU read-side lock held. */ void trace_ust_destroy_session(struct ltt_ust_session *session) { @@ -633,8 +646,6 @@ void trace_ust_destroy_session(struct ltt_ust_session *session) assert(session); - rcu_read_lock(); - DBG2("Trace UST destroy session %u", session->id); /* Cleaning up UST domain */ @@ -652,6 +663,4 @@ void trace_ust_destroy_session(struct ltt_ust_session *session) consumer_destroy_output(session->tmp_consumer); free(session); - - rcu_read_unlock(); }