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)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 26 May 2020 18:29:52 +0000 (14: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/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 960fe8e46439a6447c17198f0732c08b507bee4a..717dcdbf30859b58b4f9be2c1c6f0d848d27cedb 100644 (file)
@@ -814,6 +814,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,
                int output,
                int type,
                uint64_t session_id,
@@ -845,6 +846,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.output = output;
        msg->u.ask_channel.type = type;
        msg->u.ask_channel.session_id = session_id;
@@ -900,7 +902,8 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg,
                uint64_t tracefile_size,
                uint64_t tracefile_count,
                unsigned int monitor,
-               unsigned int live_timer_interval)
+               unsigned int live_timer_interval,
+               bool is_in_live_session)
 {
        assert(msg);
 
@@ -921,6 +924,7 @@ void consumer_init_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;
 
        strncpy(msg->u.channel.pathname, pathname,
                        sizeof(msg->u.channel.pathname));
index 08b57eb73b6a7e932e57a8b1dae0ffea2a9bfc8f..42e4ec892ea2d3d4b044ea1fe03ef7cc7ad19219 100644 (file)
@@ -232,6 +232,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,
                int output,
                int type,
                uint64_t session_id,
@@ -273,7 +274,8 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg,
                uint64_t tracefile_size,
                uint64_t tracefile_count,
                unsigned int monitor,
-               unsigned int live_timer_interval);
+               unsigned int live_timer_interval,
+               bool is_in_live_session);
 int consumer_is_data_pending(uint64_t session_id,
                struct consumer_output *consumer);
 int consumer_close_metadata(struct consumer_socket *socket,
index d21b1868aaf924e9199b8ad28bff846061d4dff2..a086384aca782141b5ce8d162550880871b79547 100644 (file)
@@ -132,7 +132,8 @@ int kernel_consumer_add_channel(struct consumer_socket *sock,
                        channel->channel->attr.tracefile_size,
                        channel->channel->attr.tracefile_count,
                        monitor,
-                       channel->channel->attr.live_timer_interval);
+                       channel->channel->attr.live_timer_interval,
+                       session->is_live_session);
 
        health_code_update();
 
@@ -196,7 +197,7 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock,
                        DEFAULT_KERNEL_CHANNEL_OUTPUT,
                        CONSUMER_CHANNEL_TYPE_METADATA,
                        0, 0,
-                       monitor, 0);
+                       monitor, 0, session->is_live_session);
 
        health_code_update();
 
index fbaa5039cbeb2745bcf2c618e0ef8ad82bda7037..7cb5c43f4f92f62eaa6fa63f0b6be082e79d129f 100644 (file)
@@ -117,13 +117,13 @@ struct ltt_kernel_session {
        unsigned int output_traces;
        unsigned int snapshot_mode;
        unsigned int has_non_default_channel;
-
        struct lttng_tracker_list *tracker_list_pid;
        struct lttng_tracker_list *tracker_list_vpid;
        struct lttng_tracker_list *tracker_list_uid;
        struct lttng_tracker_list *tracker_list_vuid;
        struct lttng_tracker_list *tracker_list_gid;
        struct lttng_tracker_list *tracker_list_vgid;
+       bool is_live_session;
 };
 
 /*
index 11318dbf1242b16837af564ac5e0acacb7f72cac..8bf342293e4846b877b7bbcd92e1eafc6dbcb443 100644 (file)
@@ -174,6 +174,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,
                        output,
                        (int) ua_chan->attr.type,
                        ua_sess->tracing_id,
index e1ee5f2fc7d411689b2c5c28949abbe8aa383c82..8eebce33423b115fff3bdd149d3800e11910d117 100644 (file)
@@ -952,6 +952,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)
 {
@@ -974,6 +975,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 9ba1dacbc6f52b9cf1b9caa4d1880fd9e93fd308..23166175fe2a5c7669f355a1fbb6c0cf37de8161 100644 (file)
@@ -170,6 +170,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;
 
        /* On-disk circular buffer */
        uint64_t tracefile_size;
@@ -672,6 +674,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 29b75d68d00d12d96cb62cfaf9ad3477d3f1314c..f6a5ba7f54a7859cb69a7052db1e82de4907eeec 100644 (file)
@@ -520,6 +520,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 608e83e9586d9b6af7ac0188616aea20d64ba9b5..06af0b48cb62e68542cc7b435fd69724b692458d 100644 (file)
@@ -452,6 +452,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;
                } LTTNG_PACKED channel; /* Only used by Kernel. */
                struct {
                        uint64_t stream_key;
@@ -483,6 +485,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 */
                        int32_t output;                         /* splice, mmap */
                        int32_t type;                           /* metadata or per_cpu */
                        uint64_t session_id;                    /* Tracing session id */
index c37be8fb8fa49f103d04125861a6465bb7667575..225f80e90b4da08c29a956e3b3885fba95b66ddf 100644 (file)
@@ -119,26 +119,6 @@ error:
        return ret;
 }
 
-/*
- * Allocate and return a consumer channel object.
- */
-static struct lttng_consumer_channel *allocate_channel(uint64_t session_id,
-               const char *pathname, const char *name, uid_t uid, gid_t gid,
-               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, pathname, name, uid,
-                       gid, 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.
@@ -1487,16 +1467,21 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
                struct ustctl_consumer_channel_attr attr;
 
                /* Create a plain object and reserve a channel key. */
-               channel = allocate_channel(msg.u.ask_channel.session_id,
-                               msg.u.ask_channel.pathname, msg.u.ask_channel.name,
-                               msg.u.ask_channel.uid, msg.u.ask_channel.gid,
-                               msg.u.ask_channel.relayd_id, msg.u.ask_channel.key,
+               channel = consumer_allocate_channel(
+                               msg.u.ask_channel.key,
+                               msg.u.ask_channel.session_id,
+                               msg.u.ask_channel.pathname,
+                               msg.u.ask_channel.name,
+                               msg.u.ask_channel.uid,
+                               msg.u.ask_channel.gid,
+                               msg.u.ask_channel.relayd_id,
                                (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.032223 seconds and 5 git commands to generate.