From ee8935c3341c0130ea132659fae46ac7a2e29229 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 5 May 2020 15:48:05 -0400 Subject: [PATCH] consumerd: tag metadata channel as being part of a live session MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit metadata channels that are part of a live session must be handled differently than when they are part of non-live sessions since complete "metadata units" must be accumulated before they are forwarded to a relay daemon. This allows a follow-up fix to use this information since the live_timer_interval of a metadata channel is always 0. Signed-off-by: Jérémie Galarneau Change-Id: I53db4bc717b149ed20e0309531db6f0241e873e1 --- src/bin/lttng-sessiond/client.c | 1 + src/bin/lttng-sessiond/consumer.c | 4 +++ src/bin/lttng-sessiond/consumer.h | 2 ++ src/bin/lttng-sessiond/kernel-consumer.c | 19 ++++++-------- src/bin/lttng-sessiond/trace-kernel.h | 1 + src/bin/lttng-sessiond/ust-consumer.c | 1 + src/common/consumer/consumer.c | 2 ++ src/common/consumer/consumer.h | 3 +++ src/common/kernel-consumer/kernel-consumer.c | 1 + src/common/sessiond-comm/sessiond-comm.h | 3 +++ src/common/ust-consumer/ust-consumer.c | 26 +++----------------- 11 files changed, 29 insertions(+), 34 deletions(-) diff --git a/src/bin/lttng-sessiond/client.c b/src/bin/lttng-sessiond/client.c index a36b81c18..9f9afa25a 100644 --- a/src/bin/lttng-sessiond/client.c +++ b/src/bin/lttng-sessiond/client.c @@ -495,6 +495,7 @@ static int create_kernel_session(struct ltt_session *session) session->kernel_session->gid = session->gid; session->kernel_session->output_traces = session->output_traces; session->kernel_session->snapshot_mode = session->snapshot_mode; + session->kernel_session->is_live_session = session->live_timer != 0; return LTTNG_OK; diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index dc945020b..d282f59c9 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -913,6 +913,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, unsigned int switch_timer_interval, unsigned int read_timer_interval, unsigned int live_timer_interval, + bool is_in_live_session, unsigned int monitor_timer_interval, int output, int type, @@ -959,6 +960,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, msg->u.ask_channel.switch_timer_interval = switch_timer_interval; msg->u.ask_channel.read_timer_interval = read_timer_interval; msg->u.ask_channel.live_timer_interval = live_timer_interval; + msg->u.ask_channel.is_live = is_in_live_session; msg->u.ask_channel.monitor_timer_interval = monitor_timer_interval; msg->u.ask_channel.output = output; msg->u.ask_channel.type = type; @@ -1014,6 +1016,7 @@ void consumer_init_add_channel_comm_msg(struct lttcomm_consumer_msg *msg, uint64_t tracefile_count, unsigned int monitor, unsigned int live_timer_interval, + bool is_in_live_session, unsigned int monitor_timer_interval, struct lttng_trace_chunk *trace_chunk) { @@ -1043,6 +1046,7 @@ void consumer_init_add_channel_comm_msg(struct lttcomm_consumer_msg *msg, msg->u.channel.tracefile_count = tracefile_count; msg->u.channel.monitor = monitor; msg->u.channel.live_timer_interval = live_timer_interval; + msg->u.channel.is_live = is_in_live_session; msg->u.channel.monitor_timer_interval = monitor_timer_interval; strncpy(msg->u.channel.pathname, pathname, diff --git a/src/bin/lttng-sessiond/consumer.h b/src/bin/lttng-sessiond/consumer.h index 926697e1e..54c962a86 100644 --- a/src/bin/lttng-sessiond/consumer.h +++ b/src/bin/lttng-sessiond/consumer.h @@ -233,6 +233,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, unsigned int switch_timer_interval, unsigned int read_timer_interval, unsigned int live_timer_interval, + bool is_in_live_session, unsigned int monitor_timer_interval, int output, int type, @@ -275,6 +276,7 @@ void consumer_init_add_channel_comm_msg(struct lttcomm_consumer_msg *msg, uint64_t tracefile_count, unsigned int monitor, unsigned int live_timer_interval, + bool is_in_live_session, unsigned int monitor_timer_interval, struct lttng_trace_chunk *trace_chunk); int consumer_is_data_pending(uint64_t session_id, diff --git a/src/bin/lttng-sessiond/kernel-consumer.c b/src/bin/lttng-sessiond/kernel-consumer.c index 0fff2c1a1..9622d3058 100644 --- a/src/bin/lttng-sessiond/kernel-consumer.c +++ b/src/bin/lttng-sessiond/kernel-consumer.c @@ -156,6 +156,7 @@ int kernel_consumer_add_channel(struct consumer_socket *sock, channel->channel->attr.tracefile_count, monitor, channel->channel->attr.live_timer_interval, + ksession->is_live_session, channel_attr_extended->monitor_timer_interval, ksession->current_trace_chunk); @@ -221,19 +222,13 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock, consumer = ksession->consumer; /* Prep channel message structure */ - consumer_init_add_channel_comm_msg(&lkm, - ksession->metadata->key, - ksession->id, - "", - ksession->uid, - ksession->gid, - consumer->net_seq_index, - DEFAULT_METADATA_NAME, - 1, + consumer_init_add_channel_comm_msg(&lkm, ksession->metadata->key, + ksession->id, "", ksession->uid, ksession->gid, + consumer->net_seq_index, DEFAULT_METADATA_NAME, 1, DEFAULT_KERNEL_CHANNEL_OUTPUT, - CONSUMER_CHANNEL_TYPE_METADATA, - 0, 0, - monitor, 0, 0, ksession->current_trace_chunk); + CONSUMER_CHANNEL_TYPE_METADATA, 0, 0, monitor, 0, + ksession->is_live_session, 0, + ksession->current_trace_chunk); health_code_update(); diff --git a/src/bin/lttng-sessiond/trace-kernel.h b/src/bin/lttng-sessiond/trace-kernel.h index 61dd8eae9..dd6f21edf 100644 --- a/src/bin/lttng-sessiond/trace-kernel.h +++ b/src/bin/lttng-sessiond/trace-kernel.h @@ -111,6 +111,7 @@ struct ltt_kernel_session { unsigned int output_traces; unsigned int snapshot_mode; unsigned int has_non_default_channel; + bool is_live_session; /* Current trace chunk of the ltt_session. */ struct lttng_trace_chunk *current_trace_chunk; /* Tracker lists */ diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index e5ba996cc..25dc7ed1c 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -136,6 +136,7 @@ static int ask_channel_creation(struct ust_app_session *ua_sess, ua_chan->attr.switch_timer_interval, ua_chan->attr.read_timer_interval, ua_sess->live_timer_interval, + ua_sess->live_timer_interval != 0, ua_chan->monitor_timer_interval, output, (int) ua_chan->attr.type, diff --git a/src/common/consumer/consumer.c b/src/common/consumer/consumer.c index 4101925c6..e2e7438f6 100644 --- a/src/common/consumer/consumer.c +++ b/src/common/consumer/consumer.c @@ -1066,6 +1066,7 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, uint64_t session_id_per_pid, unsigned int monitor, unsigned int live_timer_interval, + bool is_in_live_session, const char *root_shm_path, const char *shm_path) { @@ -1097,6 +1098,7 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, channel->tracefile_count = tracefile_count; channel->monitor = monitor; channel->live_timer_interval = live_timer_interval; + channel->is_live = is_in_live_session; pthread_mutex_init(&channel->lock, NULL); pthread_mutex_init(&channel->timer_lock, NULL); diff --git a/src/common/consumer/consumer.h b/src/common/consumer/consumer.h index 077e959d7..000040982 100644 --- a/src/common/consumer/consumer.h +++ b/src/common/consumer/consumer.h @@ -183,6 +183,8 @@ struct lttng_consumer_channel { int live_timer_enabled; timer_t live_timer; int live_timer_error; + /* Channel is part of a live session ? */ + bool is_live; /* For channel monitoring timer. */ int monitor_timer_enabled; @@ -764,6 +766,7 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, uint64_t session_id_per_pid, unsigned int monitor, unsigned int live_timer_interval, + bool is_in_live_session, const char *root_shm_path, const char *shm_path); void consumer_del_stream(struct lttng_consumer_stream *stream, diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index 5aec4ecf8..7032a7f7f 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -513,6 +513,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, msg.u.channel.tracefile_count, 0, msg.u.channel.monitor, msg.u.channel.live_timer_interval, + msg.u.channel.is_live, NULL, NULL); if (new_channel == NULL) { lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR); diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index fd1ceae11..0b4c05fb7 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -534,6 +534,8 @@ struct lttcomm_consumer_msg { uint32_t monitor; /* timer to check the streams usage in live mode (usec). */ unsigned int live_timer_interval; + /* is part of a live session */ + uint8_t is_live; /* timer to sample a channel's positions (usec). */ unsigned int monitor_timer_interval; } LTTNG_PACKED channel; /* Only used by Kernel. */ @@ -567,6 +569,7 @@ struct lttcomm_consumer_msg { uint32_t switch_timer_interval; /* usec */ uint32_t read_timer_interval; /* usec */ unsigned int live_timer_interval; /* usec */ + uint8_t is_live; /* is part of a live session */ uint32_t monitor_timer_interval; /* usec */ int32_t output; /* splice, mmap */ int32_t type; /* metadata or per_cpu */ diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index b46a50502..e5143cd4a 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -111,26 +111,6 @@ error: return ret; } -/* - * Allocate and return a consumer channel object. - */ -static struct lttng_consumer_channel *allocate_channel(uint64_t session_id, - const uint64_t *chunk_id, const char *pathname, const char *name, - uint64_t relayd_id, uint64_t key, enum lttng_event_output output, - uint64_t tracefile_size, uint64_t tracefile_count, - uint64_t session_id_per_pid, unsigned int monitor, - unsigned int live_timer_interval, - const char *root_shm_path, const char *shm_path) -{ - assert(pathname); - assert(name); - - return consumer_allocate_channel(key, session_id, chunk_id, pathname, - name, relayd_id, output, tracefile_size, - tracefile_count, session_id_per_pid, monitor, - live_timer_interval, root_shm_path, shm_path); -} - /* * Allocate and return a consumer stream object. If _alloc_ret is not NULL, the * error value if applicable is set in it else it is kept untouched. @@ -1480,19 +1460,21 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, }; /* Create a plain object and reserve a channel key. */ - channel = allocate_channel(msg.u.ask_channel.session_id, + channel = consumer_allocate_channel( + msg.u.ask_channel.key, + msg.u.ask_channel.session_id, msg.u.ask_channel.chunk_id.is_set ? &chunk_id : NULL, msg.u.ask_channel.pathname, msg.u.ask_channel.name, msg.u.ask_channel.relayd_id, - msg.u.ask_channel.key, (enum lttng_event_output) msg.u.ask_channel.output, msg.u.ask_channel.tracefile_size, msg.u.ask_channel.tracefile_count, msg.u.ask_channel.session_id_per_pid, msg.u.ask_channel.monitor, msg.u.ask_channel.live_timer_interval, + msg.u.ask_channel.is_live, msg.u.ask_channel.root_shm_path, msg.u.ask_channel.shm_path); if (!channel) { -- 2.34.1