Skip to contentSkip to conversation

Export the stream instance ID.

PATCH New Julien Desfossez 2 participants 5 messages Jul 13, 2015 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/3 Add a packet sequence number

This allows the viewer to identify the gaps between trace packets.

---
 lttng-abi.c                         | 18 +++++++++++++++
 lttng-abi.h                         |  5 ++++
 lttng-events.c                      | 46 +++++++++++++++++++++++++------------
 lttng-events.h                      |  4 ++++
 lttng-ring-buffer-client.h          | 35 ++++++++++++++++++++++++++++
 lttng-ring-buffer-metadata-client.h | 15 ++++++++++++
 6 files changed, 108 insertions(+), 15 deletions(-)
lttng-abi.c +18 -0
index 8f63ad9..586116d 100644
@@ -1508,6 +1508,15 @@ static long lttng_stream_ring_buffer_ioctl(struct file *filp,
 			goto error;
 		return put_u64(ts, arg);
 	}
+	case LTTNG_RING_BUFFER_GET_SEQ_NUM:
+	{
+		uint64_t seq;
+
+		ret = ops->sequence_number(config, buf, &seq);
+		if (ret < 0)
+			goto error;
+		return put_u64(seq, arg);
+	}
 	default:
 		return lib_ring_buffer_file_operations.unlocked_ioctl(filp,
 				cmd, arg);
@@ -1594,6 +1603,15 @@ static long lttng_stream_ring_buffer_compat_ioctl(struct file *filp,
 			goto error;
 		return put_u64(ts, arg);
 	}
+	case LTTNG_RING_BUFFER_COMPAT_GET_SEQ_NUM:
+	{
+		uint64_t seq;
+
+		ret = ops->sequence_number(config, buf, &seq);
+		if (ret < 0)
+			goto error;
+		return put_u64(seq, arg);
+	}
 	default:
 		return lib_ring_buffer_file_operations.compat_ioctl(filp,
 				cmd, arg);
lttng-abi.h +5 -0
index ab54cf8..2d342c1 100644
@@ -228,6 +228,8 @@ struct lttng_kernel_filter_bytecode {
 #define LTTNG_RING_BUFFER_GET_STREAM_ID		_IOR(0xF6, 0x25, uint64_t)
 /* returns the current timestamp */
 #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)
 
 #ifdef CONFIG_COMPAT
 /* returns the timestamp begin of the current sub-buffer */
@@ -251,6 +253,9 @@ struct lttng_kernel_filter_bytecode {
 /* returns the current timestamp */
 #define LTTNG_RING_BUFFER_COMPAT_GET_CURRENT_TIMESTAMP \
 	LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP
+/* returns the packet sequence number */
+#define LTTNG_RING_BUFFER_COMPAT_GET_SEQ_NUM	\
+	LTTNG_RING_BUFFER_GET_SEQ_NUM
 #endif /* CONFIG_COMPAT */
 
 #endif /* _LTTNG_ABI_H */
lttng-events.c +31 -15

79 lines not on this page · raw message

lttng-events.h +4 -0
index 484534c..c8afd8f 100644
@@ -358,6 +358,10 @@ struct lttng_channel_ops {
 	int (*current_timestamp) (const struct lib_ring_buffer_config *config,
 			struct lib_ring_buffer *bufb,
 			uint64_t *ts);
+	int (*sequence_number) (const struct lib_ring_buffer_config *config,
+			struct lib_ring_buffer *bufb,
+			uint64_t *seq);
+	uint64_t (*subbuf_size)(struct channel *chan);
 };
 
 struct lttng_transport {
lttng-ring-buffer-client.h +35 -0
index 72fbf18..69cc99e 100644
@@ -65,6 +65,7 @@ struct packet_header {
 		uint64_t timestamp_end;		/* Cycle count at subbuffer end */
 		uint64_t content_size;		/* Size of data in subbuffer */
 		uint64_t packet_size;		/* Subbuffer size (include padding) */
+		uint64_t packet_seq_num;	/* Packet sequence number */
 		unsigned long events_discarded;	/*
 						 * Events lost in this subbuffer since
 						 * the beginning of the trace.
@@ -348,6 +349,10 @@ static void client_buffer_begin(struct lib_ring_buffer *buf, u64 tsc,
 				subbuf_idx * chan->backend.subbuf_size);
 	struct lttng_channel *lttng_chan = channel_get_private(chan);
 	struct lttng_session *session = lttng_chan->session;
+	/* subbuf_size cannot be 0 so we can use fls_long(x - 1) directly. */
+	unsigned long seq_num_offset =
+		fls_long(chan->backend.subbuf_size - 1);
+	unsigned int field_size = sizeof(header->ctx.packet_seq_num) * CHAR_BIT;
 
 	header->magic = CTF_MAGIC_NUMBER;
 	memcpy(header->uuid, session->uuid.b, sizeof(session->uuid));
@@ -357,6 +362,14 @@ static void client_buffer_begin(struct lib_ring_buffer *buf, u64 tsc,
 	header->ctx.timestamp_end = 0;
 	header->ctx.content_size = ~0ULL; /* for debugging */
 	header->ctx.packet_size = ~0ULL;
+	header->ctx.packet_seq_num = 0;
+	/*
+	 * vread returns an unsigned long, the bt_bitfield_write adds the
+	 * complement of padding.
+	*/
+	bt_bitfield_write(&header->ctx.packet_seq_num, unsigned long,
+			seq_num_offset, field_size - seq_num_offset,
+			v_read(&client_config, &buf->offset) >> seq_num_offset);
 	header->ctx.events_discarded = 0;
 	header->ctx.cpu_id = buf->backend.cpu;
 }
@@ -472,6 +485,26 @@ static int client_current_timestamp(const struct lib_ring_buffer_config *config,
 	return 0;
 }
 
+static int client_sequence_number(const struct lib_ring_buffer_config *config,
+			struct lib_ring_buffer *buf,
+			uint64_t *seq)
+{
+	struct packet_header *header = client_packet_header(config, buf);
+	struct channel *chan = buf->backend.chan;
+
+	/* subbuf_size cannot be 0, so we can use fls_long(x - 1) directly. */
+	*seq = header->ctx.packet_seq_num >>
+		(fls_long(chan->backend.subbuf_size - 1));
+
+	return 0;
+}
+
+static
+uint64_t client_get_subbuf_size(struct channel *chan)
+{
+	return chan->backend.subbuf_size;
+}
+
 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,
@@ -702,6 +735,8 @@ static struct lttng_transport lttng_relay_transport = {
 		.packet_size = client_packet_size,
 		.stream_id = client_stream_id,
 		.current_timestamp = client_current_timestamp,
+		.sequence_number = client_sequence_number,
+		.subbuf_size = client_get_subbuf_size,
 	},
 };
 
lttng-ring-buffer-metadata-client.h +15 -0
index 9e03530..da94aeb 100644
@@ -199,6 +199,19 @@ static int client_stream_id(const struct lib_ring_buffer_config *config,
 	return -ENOSYS;
 }
 
+static int client_sequence_number(const struct lib_ring_buffer_config *config,
+			struct lib_ring_buffer *bufb,
+			uint64_t *seq)
+{
+	return -ENOSYS;
+}
+
+static
+uint64_t client_get_subbuf_size(struct channel *chan)
+{
+	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,
@@ -405,6 +418,8 @@ static struct lttng_transport lttng_relay_transport = {
 		.packet_size = client_packet_size,
 		.stream_id = client_stream_id,
 		.current_timestamp = client_current_timestamp,
+		.sequence_number = client_sequence_number,
+		.subbuf_size = client_get_subbuf_size,
 	},
 };
 
Signature · 1 line
1.9.1
#2 lore raw

PATCH 3/3 Export the stream instance ID.

In reply to a message not in the archive

Allow the lttng-consumer to query the stream instance ID.

---
 lttng-abi.c                         | 18 ++++++++++++++++++
 lttng-abi.h                         |  5 +++++
 lttng-events.h                      |  3 +++
 lttng-ring-buffer-client.h          | 12 ++++++++++++
 lttng-ring-buffer-metadata-client.h |  9 +++++++++
 5 files changed, 47 insertions(+)
lttng-abi.c +18 -0
index 586116d..79d6e7f 100644
@@ -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);
lttng-abi.h +5 -0
index 2d342c1..994d280 100644
@@ -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 */
lttng-events.h +3 -0
index c8afd8f..f695bd5 100644
@@ -362,6 +362,9 @@ struct lttng_channel_ops {
 			struct lib_ring_buffer *bufb,
 			uint64_t *seq);
 	uint64_t (*subbuf_size)(struct channel *chan);
+	int (*instance_id) (const struct lib_ring_buffer_config *config,
+			struct lib_ring_buffer *bufb,
+			uint64_t *id);
 };
 
 struct lttng_transport {
lttng-ring-buffer-client.h +12 -0
index 69cc99e..6a2ee83 100644
@@ -505,6 +505,17 @@ uint64_t client_get_subbuf_size(struct channel *chan)
 	return chan->backend.subbuf_size;
 }
 
+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,
@@ -737,6 +748,7 @@ static struct lttng_transport lttng_relay_transport = {
 		.current_timestamp = client_current_timestamp,
 		.sequence_number = client_sequence_number,
 		.subbuf_size = client_get_subbuf_size,
+		.instance_id = client_instance_id,
 	},
 };
 
lttng-ring-buffer-metadata-client.h +9 -0
index da94aeb..a402301 100644
@@ -212,6 +212,14 @@ uint64_t client_get_subbuf_size(struct channel *chan)
 	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,
@@ -420,6 +428,7 @@ static struct lttng_transport lttng_relay_transport = {
 		.current_timestamp = client_current_timestamp,
 		.sequence_number = client_sequence_number,
 		.subbuf_size = client_get_subbuf_size,
+		.instance_id = client_instance_id,
 	},
 };
 
Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

Re: [MODULES PATCH 2/3] Add a packet sequence number

Quoted 121 lines · ----- On Jul 13, 2015, at 11:09 AM, Julien Desfossez [email protected]…

This allows the viewer to identify the gaps between trace packets.

---

lttng-abi.c                         | 18 +++++++++++++++
lttng-abi.h                         |  5 ++++
lttng-events.c                      | 46 +++++++++++++++++++++++++------------
lttng-events.h                      |  4 ++++
lttng-ring-buffer-client.h          | 35 ++++++++++++++++++++++++++++
lttng-ring-buffer-metadata-client.h | 15 ++++++++++++
6 files changed, 108 insertions(+), 15 deletions(-)
lttng-abi.c +9 -0
index 8f63ad9..586116d 100644
@@ -1508,6 +1508,15 @@ static long lttng_stream_ring_buffer_ioctl(struct file
 *filp,
 			goto error;
 		return put_u64(ts, arg);
 	}
+	case LTTNG_RING_BUFFER_GET_SEQ_NUM:
+	{
+		uint64_t seq;
+
+		ret = ops->sequence_number(config, buf, &seq);
+		if (ret < 0)
+			goto error;
+		return put_u64(seq, arg);
+	}
 	default:
 		return lib_ring_buffer_file_operations.unlocked_ioctl(filp,
				cmd, arg);
lttng-abi.c +9 -0
@@ -1594,6 +1603,15 @@ static long lttng_stream_ring_buffer_compat_ioctl(struct
 file *filp,
 			goto error;
 		return put_u64(ts, arg);
 	}
+	case LTTNG_RING_BUFFER_COMPAT_GET_SEQ_NUM:
+	{
+		uint64_t seq;
+
+		ret = ops->sequence_number(config, buf, &seq);
+		if (ret < 0)
+			goto error;
+		return put_u64(seq, arg);
+	}
 	default:
 		return lib_ring_buffer_file_operations.compat_ioctl(filp,
				cmd, arg);
lttng-abi.h +5 -0
index ab54cf8..2d342c1 100644
@@ -228,6 +228,8 @@ struct lttng_kernel_filter_bytecode {
 #define LTTNG_RING_BUFFER_GET_STREAM_ID		_IOR(0xF6, 0x25, uint64_t)
 /* returns the current timestamp */
 #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)
 
 #ifdef CONFIG_COMPAT
 /* returns the timestamp begin of the current sub-buffer */
@@ -251,6 +253,9 @@ struct lttng_kernel_filter_bytecode {
 /* returns the current timestamp */
 #define LTTNG_RING_BUFFER_COMPAT_GET_CURRENT_TIMESTAMP \
 	LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP
+/* returns the packet sequence number */
+#define LTTNG_RING_BUFFER_COMPAT_GET_SEQ_NUM	\
+	LTTNG_RING_BUFFER_GET_SEQ_NUM
 #endif /* CONFIG_COMPAT */
 
 #endif /* _LTTNG_ABI_H */
lttng-events.c +0 -0
index 3cbfcbf..319ba5a 100644
@@ -76,6 +76,9 @@ static
 int _lttng_session_metadata_statedump(struct lttng_session *session);

static
void _lttng_metadata_channel_hangup(struct lttng_metadata_stream *stream);

lttng-events.c +3 -0
+static
+int _lttng_stream_packet_context_declare(struct lttng_session *session,
+					struct lttng_channel *chan);

void synchronize_trace(void)
{

lttng-events.c +10 -2
@@ -1808,14 +1811,22 @@ int _lttng_channel_metadata_statedump(struct
 lttng_session *session,
 	ret = lttng_metadata_printf(session,
 		"stream {\n"
 		"	id = %u;\n"
-		"	event.header := %s;\n"
-		"	packet.context := struct packet_context;\n",
+		"	event.header := %s;\n",
 		chan->id,
 		chan->header_type == 1 ? "struct event_header_compact" :
 			"struct event_header_large");
 	if (ret)
 		goto end;
 
+	ret = lttng_metadata_printf(session,
+			"	packet.context := ");
+	if (ret)
+		goto end;
+
+	ret = _lttng_stream_packet_context_declare(session, chan);
+	if (ret)
+		goto end;
+
 	if (chan->ctx) {
 		ret = lttng_metadata_printf(session,
			"	event.context := struct {\n");
lttng-events.c +0 -0
@@ -1844,18 +1855,27 @@ end:
 * Must be called with sessions_mutex held.
 */

static

lttng-events.c +2 -1
-int _lttng_stream_packet_context_declare(struct lttng_session *session)
+int _lttng_stream_packet_context_declare(struct lttng_session *session,
+		struct lttng_channel *chan)

{

lttng-events.c

Quoted 3 lines
lttng-events.c +3 -0
+	unsigned int field_size = 64;
+	/* subbuf_size cannot be 0, so we can use fls_long(x - 1) directly. */
+	unsigned int padding = fls_long(chan->ops->subbuf_size(chan->chan) - 1);

can we create a get_count_order_long in a lttng-modules header somewhere instead of calling fls_long(x - 1) directly ? This is a future bug waiting to happen, because the semantic of fls() is counter-intuitive.

Quoted 66 lines

+
return lttng_metadata_printf(session,
"struct packet_context {\n"

lttng-events.c +12 -8
-		"	uint64_clock_monotonic_t timestamp_begin;\n"
-		"	uint64_clock_monotonic_t timestamp_end;\n"
-		"	uint64_t content_size;\n"
-		"	uint64_t packet_size;\n"
-		"	unsigned long events_discarded;\n"
-		"	uint32_t cpu_id;\n"
-		"};\n\n"
-		);
+		"		uint64_clock_monotonic_t timestamp_begin;\n"
+		"		uint64_clock_monotonic_t timestamp_end;\n"
+		"		uint64_t content_size;\n"
+		"		uint64_t packet_size;\n"
+		"		integer { size = %u; signed = false;"
+		" align = 1; } packet_seq_num_padding;\n"
+		"		integer { size = %u; signed = false;"
+		" align = 1; } packet_seq_num;\n"
+		"		unsigned long events_discarded;\n"
+		"		uint32_t cpu_id;\n"
+		"	};\n\n",
+		padding, field_size - padding);

}

/*

lttng-events.c +0 -4
@@ -2067,10 +2087,6 @@ int _lttng_session_metadata_statedump(struct
 lttng_session *session)
 	if (ret)
 		goto end;
 
-	ret = _lttng_stream_packet_context_declare(session);
-	if (ret)
-		goto end;
-
 	ret = _lttng_event_header_declare(session);
 	if (ret)
		goto end;
lttng-events.h +4 -0
index 484534c..c8afd8f 100644
@@ -358,6 +358,10 @@ struct lttng_channel_ops {
 	int (*current_timestamp) (const struct lib_ring_buffer_config *config,
 			struct lib_ring_buffer *bufb,
 			uint64_t *ts);
+	int (*sequence_number) (const struct lib_ring_buffer_config *config,
+			struct lib_ring_buffer *bufb,
+			uint64_t *seq);
+	uint64_t (*subbuf_size)(struct channel *chan);
 };
 
 struct lttng_transport {
lttng-ring-buffer-client.h +1 -0
index 72fbf18..69cc99e 100644
@@ -65,6 +65,7 @@ struct packet_header {
 		uint64_t timestamp_end;		/* Cycle count at subbuffer end */
 		uint64_t content_size;		/* Size of data in subbuffer */
 		uint64_t packet_size;		/* Subbuffer size (include padding) */
+		uint64_t packet_seq_num;	/* Packet sequence number */
 		unsigned long events_discarded;	/*
 						 * Events lost in this subbuffer since
 						 * the beginning of the trace.

lttng-ring-buffer-client.h static void client_buffer_begin(struct lib_ring_buffer · line 355

Quoted 7 lines
lttng-ring-buffer-client.h +3 -0
@@ -348,6 +349,10 @@ static void client_buffer_begin(struct lib_ring_buffer
 *buf, u64 tsc,
 				subbuf_idx * chan->backend.subbuf_size);
 	struct lttng_channel *lttng_chan = channel_get_private(chan);
 	struct lttng_session *session = lttng_chan->session;
+	/* subbuf_size cannot be 0 so we can use fls_long(x - 1) directly. */
+	unsigned long seq_num_offset =
+		fls_long(chan->backend.subbuf_size - 1);

same here.

Quoted 5 lines
lttng-ring-buffer-client.h +1 -0
+	unsigned int field_size = sizeof(header->ctx.packet_seq_num) * CHAR_BIT;
 
 	header->magic = CTF_MAGIC_NUMBER;
	memcpy(header->uuid, session->uuid.b, sizeof(session->uuid));

lttng-ring-buffer-client.h static void client_buffer_begin(struct lib_ring_buffer · line 370

Quoted 9 lines
lttng-ring-buffer-client.h +5 -0
@@ -357,6 +362,14 @@ static void client_buffer_begin(struct lib_ring_buffer
 *buf, u64 tsc,
 	header->ctx.timestamp_end = 0;
 	header->ctx.content_size = ~0ULL; /* for debugging */
 	header->ctx.packet_size = ~0ULL;
+	header->ctx.packet_seq_num = 0;
+	/*
+	 * vread returns an unsigned long, the bt_bitfield_write adds the
+	 * complement of padding.
+	*/

We could improve this comment by documenting the order of padding and seq_num:

"First, we have the padding. Then follows the seq_num. This is true for both big and little endian."

Quoted 9 lines
lttng-ring-buffer-client.h +3 -0
+	bt_bitfield_write(&header->ctx.packet_seq_num, unsigned long,
+			seq_num_offset, field_size - seq_num_offset,
+			v_read(&client_config, &buf->offset) >> seq_num_offset);
 	header->ctx.events_discarded = 0;
 	header->ctx.cpu_id = buf->backend.cpu;

}

lttng-ring-buffer-client.h +0 -0
@@ -472,6 +485,26 @@ static int client_current_timestamp(const struct
 lib_ring_buffer_config *config,
 	return 0;

lttng-ring-buffer-client.h static int client_current_timestamp(const struct · line 496

Quoted 10 lines
lttng-ring-buffer-client.h +8 -0
 }
 
+static int client_sequence_number(const struct lib_ring_buffer_config *config,
+			struct lib_ring_buffer *buf,
+			uint64_t *seq)
+{
+	struct packet_header *header = client_packet_header(config, buf);
+	struct channel *chan = buf->backend.chan;
+
+	/* subbuf_size cannot be 0, so we can use fls_long(x - 1) directly. */

same here about creating a wrapper.

Thanks!

Mathieu

Quoted 61 lines
lttng-ring-buffer-client.h +12 -0
+	*seq = header->ctx.packet_seq_num >>
+		(fls_long(chan->backend.subbuf_size - 1));
+
+	return 0;
+}
+
+static
+uint64_t client_get_subbuf_size(struct channel *chan)
+{
+	return chan->backend.subbuf_size;
+}
+
 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,

lttng-ring-buffer-client.h +2 -0
@@ -702,6 +735,8 @@ static struct lttng_transport lttng_relay_transport = {
 		.packet_size = client_packet_size,
 		.stream_id = client_stream_id,
 		.current_timestamp = client_current_timestamp,
+		.sequence_number = client_sequence_number,
+		.subbuf_size = client_get_subbuf_size,
 	},
 };
 
lttng-ring-buffer-metadata-client.h +13 -0
index 9e03530..da94aeb 100644
@@ -199,6 +199,19 @@ static int client_stream_id(const struct
 lib_ring_buffer_config *config,
 	return -ENOSYS;
 }
 
+static int client_sequence_number(const struct lib_ring_buffer_config *config,
+			struct lib_ring_buffer *bufb,
+			uint64_t *seq)
+{
+	return -ENOSYS;
+}
+
+static
+uint64_t client_get_subbuf_size(struct channel *chan)
+{
+	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,

lttng-ring-buffer-metadata-client.h +2 -1
@@ -405,6 +418,8 @@ static struct lttng_transport lttng_relay_transport = {
 		.packet_size = client_packet_size,
 		.stream_id = client_stream_id,
 		.current_timestamp = client_current_timestamp,
+		.sequence_number = client_sequence_number,
+		.subbuf_size = client_get_subbuf_size,
 	},
 };
 
--

1.9.1

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
#5 lore raw

Re: [MODULES PATCH 1/3] Add stream instance id to the packet header

In reply to a message not in the archive
Quoted 3 lines · ----- On Jul 13, 2015, at 11:09 AM, Julien Desfossez [email protected]…

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).

Quoted 43 lines

---
lttng-events.c | 1 +
lttng-ring-buffer-client.h | 2 ++

2 files changed, 3 insertions(+)
lttng-events.c +1 -0
index 9769f89..3cbfcbf 100644
@@ -1973,6 +1973,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,

lttng-ring-buffer-client.h +2 -0
index 7055e77..72fbf18 100644
@@ -57,6 +57,7 @@ struct packet_header {
 					 */
 	uint8_t uuid[16];
 	uint32_t stream_id;
+	uint64_t stream_instance_id;
 
 	struct {
 		/* Stream packet context */
@@ -351,6 +352,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 */

--
1.9.1

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 1 line · ----- On Jul 13, 2015, at 11:09 AM, Julien Desfossez [email protected]…

Allow the lttng-consumer to query the stream instance ID.

Quoted 145 lines

---

lttng-abi.c                         | 18 ++++++++++++++++++
lttng-abi.h                         |  5 +++++
lttng-events.h                      |  3 +++
lttng-ring-buffer-client.h          | 12 ++++++++++++
lttng-ring-buffer-metadata-client.h |  9 +++++++++
5 files changed, 47 insertions(+)
lttng-abi.c +9 -0
index 586116d..79d6e7f 100644
@@ -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);
lttng-abi.c +9 -0
@@ -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);
lttng-abi.h +5 -0
index 2d342c1..994d280 100644
@@ -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 */
lttng-events.h +3 -0
index c8afd8f..f695bd5 100644
@@ -362,6 +362,9 @@ struct lttng_channel_ops {
 			struct lib_ring_buffer *bufb,
 			uint64_t *seq);
 	uint64_t (*subbuf_size)(struct channel *chan);
+	int (*instance_id) (const struct lib_ring_buffer_config *config,
+			struct lib_ring_buffer *bufb,
+			uint64_t *id);
 };
 
 struct lttng_transport {
lttng-ring-buffer-client.h +12 -0
index 69cc99e..6a2ee83 100644
@@ -505,6 +505,17 @@ uint64_t client_get_subbuf_size(struct channel *chan)
 	return chan->backend.subbuf_size;
 }
 
+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,
@@ -737,6 +748,7 @@ static struct lttng_transport lttng_relay_transport = {
 		.current_timestamp = client_current_timestamp,
 		.sequence_number = client_sequence_number,
 		.subbuf_size = client_get_subbuf_size,
+		.instance_id = client_instance_id,
 	},
 };
 
lttng-ring-buffer-metadata-client.h +9 -1
index da94aeb..a402301 100644
@@ -212,6 +212,14 @@ uint64_t client_get_subbuf_size(struct channel *chan)
 	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,
@@ -420,6 +428,7 @@ static struct lttng_transport lttng_relay_transport = {
 		.current_timestamp = client_current_timestamp,
 		.sequence_number = client_sequence_number,
 		.subbuf_size = client_get_subbuf_size,
+		.instance_id = client_instance_id,
 	},
 };
 
--

1.9.1

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com