Fix: lttng-sessiond: cpu hotplug: send channel to consumer only once
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/3 Fix: lttng-sessiond: cpu hotplug: send channel to consumer only once
On CPU hotplug, we currently send a duplicate of the channel key, which allocates its own object (duplicated) within the consumerd. We want the newly added stream to map to the pre-existing channel key, so don't send the channel duplicate.
--- src/bin/lttng-sessiond/kernel-consumer.c | 11 +++++++---- src/bin/lttng-sessiond/trace-kernel.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-)
src/bin/lttng-sessiond/kernel-consumer.c +7 -4
@@ -338,7 +338,7 @@ int kernel_consumer_send_channel_stream(struct consumer_socket *sock, struct ltt_kernel_channel *channel, struct ltt_kernel_session *session, unsigned int monitor) { - int ret; + int ret = LTTNG_OK;struct ltt_kernel_stream *stream;/* Safety net */
@@ -356,9 +356,12 @@ int kernel_consumer_send_channel_stream(struct consumer_socket *sock,DBG ("Sending streams of channel %s to kernel consumer" , channel->channel->name); - ret =kernel_consumer_add_channel (sock, channel, session, monitor); -if (ret <0 ) { - goto error; +if (!channel->sent_to_consumer) { + ret =kernel_consumer_add_channel (sock, channel, session, monitor); +if (ret <0 ) { + goto error; + } + channel->sent_to_consumer = true; }/* Send streams */
src/bin/lttng-sessiond/trace-kernel.h +1 -0
@@ -71,6 +71,7 @@ struct ltt_kernel_channel {struct cds_list_head list;/* Session pointer which has a reference to this object. */ struct ltt_kernel_session *session; +bool sent_to_consumer; };/* Metadata */
Signature · 6 lines
2.1.4 _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
PATCH 3/3 Fix: lttng-consumerd: cpu hotplug: send "streams_sent" command
In reply to a message not in the archiveWhen creating a new channel, the streams being sent to the relayd are kept invisible to the live client until the "streams_sent" command is received. This ensures the client does not see a partial stream set.
This "streams_sent" command needs to be sent on CPU hotplug too, otherwise the live client handling within relayd is not aware of those streams (they are never published).
--- src/common/consumer/consumer.h | 2 ++ src/common/kernel-consumer/kernel-consumer.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+)
src/common/consumer/consumer.h +2 -0
@@ -224,6 +224,8 @@ struct lttng_consumer_channel {uint64_t discarded_events;/* Total number of missed packets due to overwriting (overwrite). */ uint64_t lost_packets; + +bool streams_sent_to_relayd; };/*
src/common/kernel-consumer/kernel-consumer.c +15 -0
@@ -196,6 +196,7 @@ int lttng_kconsumer_snapshot_channel(uint64_t key, char *path,ERR ("sending streams sent to relayd" ); goto end_unlock; } + channel->streams_sent_to_relayd = true; } ret =kernctl_buffer_flush (stream->wait_fd);
@@ -741,6 +742,19 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,consumer_stream_free (new_stream); goto end_nosignal; } + +/* +* If adding an extra stream to an already +* existing channel (e.g. cpu hotplug), we need +* to sent the "streams_sent" command to relayd. +*/ +if (channel->streams_sent_to_relayd) { + ret =consumer_send_relayd_streams_sent ( + new_stream->net_seq_idx); +if (ret <0 ) { + goto end_nosignal; + } + } }/* Get the right pipe where the stream will be sent. */
@@ -834,6 +848,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,if (ret <0 ) { goto end_nosignal; } + channel->streams_sent_to_relayd = true; }break ; }
Signature · 6 lines
2.1.4 _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Re: [PATCH lttng-tools 1/3] Fix: lttng-sessiond: cpu hotplug stream number mismatch
In reply to a message not in the archiveMerged in master, stable-2.10, stable-2.9, and stable-2.8.
Thanks!
Jérémie
Quoted 57 lines · Mathieu Desnoyers
The counter should be always increasing (kept in the channel), rather than local to the function. This causes cpu hotplug handling to disregard further streams that should be added to the consumer output on CPU hotplug.
Signed-off-by Mathieu Desnoyers <[email protected]>--- src/bin/lttng-sessiond/kernel.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)src/bin/lttng-sessiond/kernel.c +8
-7@@ -644,17 +644,22 @@ error:* Open stream of channel, register it to the kernel tracer and add it * to the stream list of the channel. * +* Note: given that the streams may appear in random order wrt CPU +* number (e.g. cpu hotplug), the index value of the stream number in +* the stream name is not necessarily linked to the CPU number. +* * Return the number of created stream. Else, a negative value. */ int kernel_open_channel_stream (struct ltt_kernel_channel *channel) { -int ret, count =0 ; +int ret;struct ltt_kernel_stream *lks;assert (channel);while ((ret =kernctl_create_stream (channel->fd)) >=0 ) { - lks =trace_kernel_create_stream (channel->channel->name, count); + lks =trace_kernel_create_stream (channel->channel->name, + channel->stream_count);if (lks ==NULL ) { ret =close (ret);if (ret) {@@ -673,13 +678,10 @@ int kernel_open_channel_stream(struct ltt_kernel_channel *channel) lks->tracefile_size = channel->channel->attr.tracefile_size; lks->tracefile_count = channel->channel->attr.tracefile_count; -/* Add stream to channe stream list */ +/* Add stream to channel stream list */ cds_list_add (&lks->list, &channel->stream_list.head); channel->stream_count++; -/* Increment counter which represent CPU number. */ - count++; -DBG ("Kernel stream %s created (fd: %d, state: %d)" , lks->name, lks->fd, lks->state); } --2.1.4
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Merged in master, stable-2.10, stable-2.9, and stable-2.8.
Thanks!
Jérémie
Quoted 55 lines · Mathieu Desnoyers
On CPU hotplug, we currently send a duplicate of the channel key, which allocates its own object (duplicated) within the consumerd. We want the newly added stream to map to the pre-existing channel key, so don't send the channel duplicate.
Signed-off-by Mathieu Desnoyers <[email protected]>--- src/bin/lttng-sessiond/kernel-consumer.c | 11 +++++++---- src/bin/lttng-sessiond/trace-kernel.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-)src/bin/lttng-sessiond/kernel-consumer.c +7
-4@@ -338,7 +338,7 @@ int kernel_consumer_send_channel_stream(struct consumer_socket *sock, struct ltt_kernel_channel *channel, struct ltt_kernel_session *session, unsigned int monitor) { - int ret; + int ret = LTTNG_OK;struct ltt_kernel_stream *stream;/* Safety net */ @@ -356,9 +356,12 @@ int kernel_consumer_send_channel_stream(struct consumer_socket *sock,DBG ("Sending streams of channel %s to kernel consumer" , channel->channel->name); - ret =kernel_consumer_add_channel (sock, channel, session, monitor); -if (ret <0 ) { - goto error; +if (!channel->sent_to_consumer) { + ret =kernel_consumer_add_channel (sock, channel, session, monitor); +if (ret <0 ) { + goto error; + } + channel->sent_to_consumer = true; }/* Send streams */ src/bin/lttng-sessiond/trace-kernel.h +1
-1@@ -71,6 +71,7 @@ struct ltt_kernel_channel {struct cds_list_head list;/* Session pointer which has a reference to this object. */ struct ltt_kernel_session *session; +bool sent_to_consumer; };/* Metadata */ --2.1.4
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH lttng-tools 3/3] Fix: lttng-consumerd: cpu hotplug: send "streams_sent" command
Merged in master, stable-2.10, stable-2.9, and stable-2.8.
Thanks,
Jérémie
Quoted 40 lines · Mathieu Desnoyers
When creating a new channel, the streams being sent to the relayd are kept invisible to the live client until the "
streams_sent" command is received. This ensures the client does not see a partial stream set.This "
streams_sent" command needs to be sent on CPU hotplug too, otherwise the live client handling within relayd is not aware of those streams (they are never published).Signed-off-by Mathieu Desnoyers <[email protected]>--- src/common/consumer/consumer.h | 2 ++ src/common/kernel-consumer/kernel-consumer.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+)src/common/consumer/consumer.h +2
-0@@ -224,6 +224,8 @@ struct lttng_consumer_channel {uint64_t discarded_events;/* Total number of missed packets due to overwriting (overwrite). */ uint64_t lost_packets; + +bool streams_sent_to_relayd; };/* src/common/kernel-consumer/kernel-consumer.c +1
-0@@ -196,6 +196,7 @@ int lttng_kconsumer_snapshot_channel(uint64_t key, char *path,ERR ("sending streams sent to relayd" ); goto end_unlock; } + channel->streams_sent_to_relayd = true; } ret =kernctl_buffer_flush (stream->wait_fd);
src/common/kernel-consumer/kernel-consumer.c int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, · line 749
Quoted 8 lines
src/common/kernel-consumer/kernel-consumer.c +5
-0@@ -741,6 +742,19 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,consumer_stream_free (new_stream); goto end_nosignal; } + +/* +* If adding an extra stream to an already +* existing channel (e.g. cpu hotplug), we need +* to sent the "streams_sent" command to relayd.
Fixed this typo (sent -> send) and merged in master, stable-2.10, stable-2.9, and stable-2.8.
Thanks!
Jérémie
Quoted 22 lines
src/common/kernel-consumer/kernel-consumer.c +9
-1+*/ +if (channel->streams_sent_to_relayd) { + ret =consumer_send_relayd_streams_sent ( + new_stream->net_seq_idx); +if (ret <0 ) { + goto end_nosignal; + } + } }/* Get the right pipe where the stream will be sent. */ @@ -834,6 +848,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,if (ret <0 ) { goto end_nosignal; } + channel->streams_sent_to_relayd = true; }break ; } --2.1.4
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev