From: Julien Desfossez Date: Sat, 1 Aug 2015 04:06:03 +0000 (-0400) Subject: Add stream instance id to the packet header X-Git-Tag: v2.8.0-rc1~88 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5594698f9c8ad13e0964c67946d1867df7757dae;p=lttng-modules.git Add stream instance id to the packet header 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 Acked-by: Mathieu Desnoyers Signed-off-by: Mathieu Desnoyers --- diff --git a/lttng-abi.c b/lttng-abi.c index 586116da..79d6e7ff 100644 --- a/lttng-abi.c +++ b/lttng-abi.c @@ -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); diff --git a/lttng-abi.h b/lttng-abi.h index 2d342c1b..994d2805 100644 --- a/lttng-abi.h +++ b/lttng-abi.h @@ -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 */ diff --git a/lttng-events.c b/lttng-events.c index c213b719..b49851b5 100644 --- a/lttng-events.c +++ b/lttng-events.c @@ -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, diff --git a/lttng-events.h b/lttng-events.h index d2a039e8..b3e94a0c 100644 --- a/lttng-events.h +++ b/lttng-events.h @@ -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 { diff --git a/lttng-ring-buffer-client.h b/lttng-ring-buffer-client.h index 34493333..4fffab98 100644 --- a/lttng-ring-buffer-client.h +++ b/lttng-ring-buffer-client.h @@ -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, }, }; diff --git a/lttng-ring-buffer-metadata-client.h b/lttng-ring-buffer-metadata-client.h index 446df897..3c9a3d8f 100644 --- a/lttng-ring-buffer-metadata-client.h +++ b/lttng-ring-buffer-metadata-client.h @@ -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, }, };