Add stream instance id to the packet header
authorJulien Desfossez <jdesfossez@efficios.com>
Sat, 1 Aug 2015 04:06:03 +0000 (00:06 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sun, 2 Aug 2015 15:35:01 +0000 (11:35 -0400)
This new field allows the viewer to distinguish between trace files
belonging to the same packet stream (in LTTng: the same CPU in the same
channel).

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng-abi.c
lttng-abi.h
lttng-events.c
lttng-events.h
lttng-ring-buffer-client.h
lttng-ring-buffer-metadata-client.h

index 586116dae39f6f5f50726191d90951d029bbea7e..79d6e7ffd1cb24ad242fe4d52fbe7c0065d02f62 100644 (file)
@@ -1517,6 +1517,15 @@ static long lttng_stream_ring_buffer_ioctl(struct file *filp,
                        goto error;
                return put_u64(seq, arg);
        }
+       case LTTNG_RING_BUFFER_INSTANCE_ID:
+       {
+               uint64_t id;
+
+               ret = ops->instance_id(config, buf, &id);
+               if (ret < 0)
+                       goto error;
+               return put_u64(id, arg);
+       }
        default:
                return lib_ring_buffer_file_operations.unlocked_ioctl(filp,
                                cmd, arg);
@@ -1612,6 +1621,15 @@ static long lttng_stream_ring_buffer_compat_ioctl(struct file *filp,
                        goto error;
                return put_u64(seq, arg);
        }
+       case LTTNG_RING_BUFFER_COMPAT_INSTANCE_ID:
+       {
+               uint64_t id;
+
+               ret = ops->instance_id(config, buf, &id);
+               if (ret < 0)
+                       goto error;
+               return put_u64(id, arg);
+       }
        default:
                return lib_ring_buffer_file_operations.compat_ioctl(filp,
                                cmd, arg);
index 2d342c1bfafc0d3d3da605f59c074796a277fae0..994d2805a142a1f7269a744ab3b6ceaf3144f282 100644 (file)
@@ -230,6 +230,8 @@ struct lttng_kernel_filter_bytecode {
 #define LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP        _IOR(0xF6, 0x26, uint64_t)
 /* returns the packet sequence number */
 #define LTTNG_RING_BUFFER_GET_SEQ_NUM          _IOR(0xF6, 0x27, uint64_t)
+/* returns the stream instance id */
+#define LTTNG_RING_BUFFER_INSTANCE_ID          _IOR(0xF6, 0x28, uint64_t)
 
 #ifdef CONFIG_COMPAT
 /* returns the timestamp begin of the current sub-buffer */
@@ -256,6 +258,9 @@ struct lttng_kernel_filter_bytecode {
 /* returns the packet sequence number */
 #define LTTNG_RING_BUFFER_COMPAT_GET_SEQ_NUM   \
        LTTNG_RING_BUFFER_GET_SEQ_NUM
+/* returns the stream instance id */
+#define LTTNG_RING_BUFFER_COMPAT_INSTANCE_ID   \
+       LTTNG_RING_BUFFER_INSTANCE_ID
 #endif /* CONFIG_COMPAT */
 
 #endif /* _LTTNG_ABI_H */
index c213b719fa4802876a6605c43829d0ccaf0736fb..b49851b548fa357d1ff249d732596bc11e415a16 100644 (file)
@@ -1974,6 +1974,7 @@ int _lttng_session_metadata_statedump(struct lttng_session *session)
                "               uint32_t magic;\n"
                "               uint8_t  uuid[16];\n"
                "               uint32_t stream_id;\n"
+               "               uint64_t stream_instance_id;\n"
                "       };\n"
                "};\n\n",
                lttng_alignof(uint8_t) * CHAR_BIT,
index d2a039e8f664cacf5aea2d91b86aafdd7e31acaa..b3e94a0c60b670acd814c21010be72cc0c128b86 100644 (file)
@@ -361,6 +361,9 @@ struct lttng_channel_ops {
        int (*sequence_number) (const struct lib_ring_buffer_config *config,
                        struct lib_ring_buffer *bufb,
                        uint64_t *seq);
+       int (*instance_id) (const struct lib_ring_buffer_config *config,
+                       struct lib_ring_buffer *bufb,
+                       uint64_t *id);
 };
 
 struct lttng_transport {
index 34493333bcc8a0055db535cf262a319e09b92021..4fffab981affbd2064bc2724bb03eabe67f0acc5 100644 (file)
@@ -57,6 +57,7 @@ struct packet_header {
                                         */
        uint8_t uuid[16];
        uint32_t stream_id;
+       uint64_t stream_instance_id;
 
        struct {
                /* Stream packet context */
@@ -352,6 +353,7 @@ static void client_buffer_begin(struct lib_ring_buffer *buf, u64 tsc,
        header->magic = CTF_MAGIC_NUMBER;
        memcpy(header->uuid, session->uuid.b, sizeof(session->uuid));
        header->stream_id = lttng_chan->id;
+       header->stream_instance_id = buf->backend.cpu;
        header->ctx.timestamp_begin = tsc;
        header->ctx.timestamp_end = 0;
        header->ctx.content_size = ~0ULL; /* for debugging */
@@ -485,6 +487,17 @@ static int client_sequence_number(const struct lib_ring_buffer_config *config,
        return 0;
 }
 
+static
+int client_instance_id(const struct lib_ring_buffer_config *config,
+               struct lib_ring_buffer *buf,
+               uint64_t *id)
+{
+       struct packet_header *header = client_packet_header(config, buf);
+       *id = header->stream_instance_id;
+
+       return 0;
+}
+
 static const struct lib_ring_buffer_config client_config = {
        .cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
        .cb.record_header_size = client_record_header_size,
@@ -716,6 +729,7 @@ static struct lttng_transport lttng_relay_transport = {
                .stream_id = client_stream_id,
                .current_timestamp = client_current_timestamp,
                .sequence_number = client_sequence_number,
+               .instance_id = client_instance_id,
        },
 };
 
index 446df89772ac885a90fc639d426f868ff53e1549..3c9a3d8f100c84c433b06e6b2ffbd22ed3db505a 100644 (file)
@@ -206,6 +206,14 @@ static int client_sequence_number(const struct lib_ring_buffer_config *config,
        return -ENOSYS;
 }
 
+static
+int client_instance_id(const struct lib_ring_buffer_config *config,
+               struct lib_ring_buffer *bufb,
+               uint64_t *id)
+{
+       return -ENOSYS;
+}
+
 static const struct lib_ring_buffer_config client_config = {
        .cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
        .cb.record_header_size = client_record_header_size,
@@ -413,6 +421,7 @@ static struct lttng_transport lttng_relay_transport = {
                .stream_id = client_stream_id,
                .current_timestamp = client_current_timestamp,
                .sequence_number = client_sequence_number,
+               .instance_id = client_instance_id,
        },
 };
 
This page took 0.030449 seconds and 4 git commands to generate.