From: Mathieu Desnoyers Date: Sat, 5 Nov 2011 15:27:53 +0000 (-0400) Subject: Fix order of streams X-Git-Tag: v2.0-pre15~156 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5af2f756eb72d460d304318550afc782279452b9;p=lttng-tools.git Fix order of streams Use a list instead of hash table to send streams in correct order. Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng/lttng-consumer.h b/include/lttng/lttng-consumer.h index 7751570ef..1a6afc22a 100644 --- a/include/lttng/lttng-consumer.h +++ b/include/lttng/lttng-consumer.h @@ -85,6 +85,7 @@ struct lttng_consumer_channel { int nr_streams; int shm_fd_is_copy; int wait_fd_is_copy; + int cpucount; }; /* Forward declaration for UST. */ diff --git a/liblttng-consumer/lttng-consumer.c b/liblttng-consumer/lttng-consumer.c index 5311860e0..2fcb39a27 100644 --- a/liblttng-consumer/lttng-consumer.c +++ b/liblttng-consumer/lttng-consumer.c @@ -181,6 +181,7 @@ struct lttng_consumer_stream *consumer_allocate_stream( case LTTNG_CONSUMER_KERNEL: break; case LTTNG_CONSUMER_UST: + stream->cpu = stream->chan->cpucount++; ret = lttng_ustconsumer_allocate_stream(stream); if (ret) { free(stream); diff --git a/lttng-sessiond/trace-ust.h b/lttng-sessiond/trace-ust.h index 35683ebce..604024b18 100644 --- a/lttng-sessiond/trace-ust.h +++ b/lttng-sessiond/trace-ust.h @@ -53,7 +53,8 @@ struct ltt_ust_stream { int handle; char pathname[PATH_MAX]; struct lttng_ust_object_data *obj; - struct cds_lfht_node node; + /* Using a list of streams to keep order. */ + struct cds_list_head list; }; /* UST channel */ diff --git a/lttng-sessiond/ust-app.c b/lttng-sessiond/ust-app.c index bce76f791..9e6b3468b 100644 --- a/lttng-sessiond/ust-app.c +++ b/lttng-sessiond/ust-app.c @@ -322,7 +322,7 @@ static struct ust_app_channel *alloc_app_channel(char *name) ua_chan->handle = -1; ua_chan->obj = NULL; ua_chan->ctx = hashtable_new(0); - ua_chan->streams = hashtable_new(0); + CDS_INIT_LIST_HEAD(&ua_chan->streams.head); ua_chan->events = hashtable_new_str(0); hashtable_node_init(&ua_chan->node, (void *) ua_chan->name, strlen(ua_chan->name)); @@ -788,12 +788,11 @@ int ust_app_start_trace(struct ltt_ust_session *usess) memset(ustream, 0, sizeof(struct ltt_ust_stream)); ustream->obj = obj; ustream->handle = ustream->obj->handle; - hashtable_node_init(&ustream->node, - (void *)((unsigned long) ustream->handle), sizeof(void *)); - hashtable_add_unique(ua_chan->streams, &ustream->node); - ret = snprintf(ustream->pathname, PATH_MAX, "%s/%s_%lu", + /* Order is important */ + cds_list_add_tail(&ustream->list, &ua_chan->streams.head); + ret = snprintf(ustream->pathname, PATH_MAX, "%s/%s_%u", uchan->pathname, uchan->name, - hashtable_get_count(ua_chan->streams) - 1); + ua_chan->streams.count++); if (ret < 0) { PERROR("asprintf UST create stream"); goto next_chan; diff --git a/lttng-sessiond/ust-app.h b/lttng-sessiond/ust-app.h index 04c3472dd..9a30b6f8f 100644 --- a/lttng-sessiond/ust-app.h +++ b/lttng-sessiond/ust-app.h @@ -65,7 +65,7 @@ struct ust_app_channel { char name[LTTNG_UST_SYM_NAME_LEN]; struct lttng_ust_channel attr; struct lttng_ust_object_data *obj; - struct cds_lfht *streams; + struct ltt_ust_stream_list streams; struct cds_lfht *ctx; struct cds_lfht *events; struct cds_lfht_node node; diff --git a/lttng-sessiond/ust-consumer.c b/lttng-sessiond/ust-consumer.c index 1e583839e..444ff6eee 100644 --- a/lttng-sessiond/ust-consumer.c +++ b/lttng-sessiond/ust-consumer.c @@ -38,8 +38,7 @@ static int send_channel_streams(int sock, { int ret, fd; struct lttcomm_consumer_msg lum; - struct cds_lfht_iter iter; - struct cds_lfht_node *node; + struct ltt_ust_stream *stream; DBG("Sending streams of channel %s to UST consumer", uchan->name); @@ -66,15 +65,11 @@ static int send_channel_streams(int sock, goto error; } - rcu_read_lock(); - hashtable_get_first(uchan->streams, &iter); - while ((node = hashtable_iter_get_node(&iter)) != NULL) { - struct ltt_ust_stream *stream = - caa_container_of(node, struct ltt_ust_stream, node); + cds_list_for_each_entry(stream, &uchan->streams.head, list) { int fds[2]; if (!stream->obj->shm_fd) { - goto next; + continue; } lum.cmd_type = LTTNG_CONSUMER_ADD_STREAM; lum.u.stream.channel_key = uchan->obj->shm_fd; @@ -98,11 +93,7 @@ static int send_channel_streams(int sock, perror("send consumer stream ancillary data"); goto error; } - -next: - hashtable_get_next(uchan->streams, &iter); } - rcu_read_unlock(); DBG("consumer channel streams sent");