consumerd: tag metadata channel as being part of a live session
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 5 May 2020 19:48:05 +0000 (15:48 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 26 May 2020 21:29:40 +0000 (17:29 -0400)
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 <jeremie.galarneau@efficios.com>
Change-Id: I53db4bc717b149ed20e0309531db6f0241e873e1

src/bin/lttng-sessiond/client.c
src/bin/lttng-sessiond/consumer.c
src/bin/lttng-sessiond/consumer.h
src/bin/lttng-sessiond/kernel-consumer.c
src/bin/lttng-sessiond/trace-kernel.h
src/bin/lttng-sessiond/ust-consumer.c
src/common/consumer/consumer.c
src/common/consumer/consumer.h
src/common/kernel-consumer/kernel-consumer.c
src/common/sessiond-comm/sessiond-comm.h
src/common/ust-consumer/ust-consumer.c

index 327c1fe1706efabaefdf9dd2a3c5dc7fb4865c3e..1803a3bb92fbec6240a55dc797e16821740fe859 100644 (file)
@@ -498,6 +498,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;
 
index d376c9ee3cc31ff7817d9a99146f88fd8e806c45..57828b7208fd7dec64ec6db55065b8aaacfa71af 100644 (file)
@@ -920,6 +920,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,
@@ -966,6 +967,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;
@@ -1021,6 +1023,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)
 {
@@ -1050,6 +1053,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,
index 1590788cc1459310c9be4c05c8f4cf4d6c6df279..e9a15aa8017452757d6a4ae2fee57997f06bd7e3 100644 (file)
@@ -240,6 +240,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,
@@ -282,6 +283,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,
index 2d0605e9bc1b308a13886cf9f38b9af64b118920..57c8f549feac41918930165156bef72bb45f5ed2 100644 (file)
@@ -162,6 +162,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);
 
@@ -227,19 +228,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,
-                       DEFAULT_KERNEL_TRACE_DIR,
-                       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();
 
index e439c31cd34c0f012790242d3066f695a3afa893..ba1b2b881a9f75f292cd2968d4556e0c8e58bd89 100644 (file)
@@ -120,6 +120,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;
 };
index a3e7eea008aee322566ff32a622871cfe6d060f9..b7f2430b06e392b33ce2b2fd6eee45f220ae1059 100644 (file)
@@ -144,6 +144,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,
index f2ea2918778469d9416101ac848f75d1dcacf6e3..f3b042da435e37a5c40c2aa784f377573b2607c5 100644 (file)
@@ -1067,6 +1067,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)
 {
@@ -1098,6 +1099,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);
 
index f6e8b2b52d19071575bc5b539d8017ae34efa964..75746897255a26e0e41e973dbce67792290160e3 100644 (file)
@@ -192,6 +192,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;
@@ -773,6 +775,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,
index d2fda27b5d4dcbff1bc46217bc003144f50c33e6..4fe37d3c9e941062e17b9a8d8313705299685b79 100644 (file)
@@ -523,6 +523,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);
index a80a6ee97664ac04ace77307d90a70184be9ce21..cfffa157f3d9bc953ad4c6a45ccd91ef34317745 100644 (file)
@@ -495,6 +495,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. */
@@ -528,6 +530,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 */
index 19713c81291f3ae8e0ab3a5c4bfe67cbacb3c27d..db95179dc8f6f581efac87918d519728a05dec8c 100644 (file)
@@ -121,26 +121,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.
@@ -1490,19 +1470,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) {
This page took 0.032709 seconds and 4 git commands to generate.