Skip to contentSkip to conversation

LTTng ringbuffer ABI calls for index generation

PATCH New Julien Desfossez 2 participants 3 messages Sep 19, 2013 1 message 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 LTTng ringbuffer ABI calls for index generation

These new calls export the data required for the consumer to generate the index while tracing :
- timestamp begin
- timestamp end
- events discarded
- context size
- packet size
- stream id

---
 include/lttng/ust-ctl.h                 |  14 ++++
 liblttng-ust-ctl/ustctl.c               | 110 ++++++++++++++++++++++++++++++++
 liblttng-ust/lttng-rb-clients.h         |  19 ++++++
 liblttng-ust/lttng-ring-buffer-client.h |  90 ++++++++++++++++++++++++++
 4 files changed, 233 insertions(+)
include/lttng/ust-ctl.h +14 -0
index 3c81e50..88112ad 100644
@@ -220,6 +220,20 @@ int ustctl_put_subbuf(struct ustctl_consumer_stream *stream);
 void ustctl_flush_buffer(struct ustctl_consumer_stream *stream,
 		int producer_active);
 
+/* index */
+int ustctl_get_timestamp_begin(struct ustctl_consumer_stream *stream,
+		uint64_t *timestamp_begin);
+int ustctl_get_timestamp_end(struct ustctl_consumer_stream *stream,
+	uint64_t *timestamp_end);
+int ustctl_get_events_discarded(struct ustctl_consumer_stream *stream,
+	uint64_t *events_discarded);
+int ustctl_get_content_size(struct ustctl_consumer_stream *stream,
+	uint64_t *content_size);
+int ustctl_get_packet_size(struct ustctl_consumer_stream *stream,
+	uint64_t *packet_size);
+int ustctl_get_stream_id(struct ustctl_consumer_stream *stream,
+		uint64_t *stream_id);
+
 /* event registry management */
 
 enum ustctl_socket_type {
liblttng-ust-ctl/ustctl.c +110 -0

122 lines not on this page · raw message

liblttng-ust/lttng-rb-clients.h +19 -0
index c9a1619..c43aa75 100644
@@ -21,6 +21,25 @@
 
 struct lttng_ust_client_lib_ring_buffer_client_cb {
 	struct lttng_ust_lib_ring_buffer_client_cb parent;
+
+	int (*timestamp_begin) (struct lttng_ust_lib_ring_buffer *buf,
+			struct lttng_ust_shm_handle *handle,
+			uint64_t *timestamp_begin);
+	int (*timestamp_end) (struct lttng_ust_lib_ring_buffer *buf,
+			struct lttng_ust_shm_handle *handle,
+			uint64_t *timestamp_end);
+	int (*events_discarded) (struct lttng_ust_lib_ring_buffer *buf,
+			struct lttng_ust_shm_handle *handle,
+			uint64_t *events_discarded);
+	int (*content_size) (struct lttng_ust_lib_ring_buffer *buf,
+			struct lttng_ust_shm_handle *handle,
+			uint64_t *content_size);
+	int (*packet_size) (struct lttng_ust_lib_ring_buffer *buf,
+			struct lttng_ust_shm_handle *handle,
+			uint64_t *packet_size);
+	int (*stream_id) (struct lttng_ust_lib_ring_buffer *buf,
+			struct lttng_ust_shm_handle *handle,
+			uint64_t *stream_id);
 };
 
 #endif /* _LTTNG_RB_CLIENT_H */
liblttng-ust/lttng-ring-buffer-client.h +90 -0

102 lines not on this page · raw message

Signature · 1 line
1.8.3.2
#2 lore raw

PATCH 3/3 Per-stream ioctl to get the current timestamp

In reply to a message not in the archive
---
 include/lttng/ust-ctl.h                 |  2 ++
 liblttng-ust-ctl/ustctl.c               | 15 +++++++++++++++
 liblttng-ust/lttng-rb-clients.h         |  3 +++
 liblttng-ust/lttng-ring-buffer-client.h | 13 +++++++++++++
 4 files changed, 33 insertions(+)
include/lttng/ust-ctl.h +2 -0
index 88112ad..c8ac3f9 100644
@@ -233,6 +233,8 @@ int ustctl_get_packet_size(struct ustctl_consumer_stream *stream,
 	uint64_t *packet_size);
 int ustctl_get_stream_id(struct ustctl_consumer_stream *stream,
 		uint64_t *stream_id);
+int ustctl_get_current_timestamp(struct ustctl_consumer_stream *stream,
+		uint64_t *ts);
 
 /* event registry management */
 
liblttng-ust-ctl/ustctl.c +15 -0
index 7830132..11fc704 100644
@@ -1571,6 +1571,21 @@ int ustctl_get_stream_id(struct ustctl_consumer_stream *stream,
 	return client_cb->stream_id(buf, handle, stream_id);
 }
 
+int ustctl_get_current_timestamp(struct ustctl_consumer_stream *stream,
+		uint64_t *ts)
+{
+	struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
+	struct lttng_ust_lib_ring_buffer *buf = stream->buf;
+	struct lttng_ust_shm_handle *handle = stream->chan->chan->handle;
+
+	if (!stream || !ts)
+		return -EINVAL;
+	client_cb = get_client_cb(buf, handle);
+	if (!client_cb || !client_cb->current_timestamp)
+		return -ENOSYS;
+	return client_cb->current_timestamp(buf, handle, ts);
+}
+
 /*
  * Returns 0 on success, negative error value on error.
  */
liblttng-ust/lttng-rb-clients.h +3 -0
index c43aa75..85d4e1b 100644
@@ -40,6 +40,9 @@ struct lttng_ust_client_lib_ring_buffer_client_cb {
 	int (*stream_id) (struct lttng_ust_lib_ring_buffer *buf,
 			struct lttng_ust_shm_handle *handle,
 			uint64_t *stream_id);
+	int (*current_timestamp) (struct lttng_ust_lib_ring_buffer *buf,
+			struct lttng_ust_shm_handle *handle,
+			uint64_t *ts);
 };
 
 #endif /* _LTTNG_RB_CLIENT_H */
liblttng-ust/lttng-ring-buffer-client.h +13 -0
index 4671713..2cdecbe 100644
@@ -470,6 +470,18 @@ static int client_stream_id(struct lttng_ust_lib_ring_buffer *buf,
 	return 0;
 }
 
+static int client_current_timestamp(struct lttng_ust_lib_ring_buffer *buf,
+		struct lttng_ust_shm_handle *handle,
+		uint64_t *ts)
+{
+	struct channel *chan;
+
+	chan = shmp(handle, handle->chan);
+	*ts = client_ring_buffer_clock_read(chan);
+
+	return 0;
+}
+
 static const
 struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
 	.parent = {
@@ -487,6 +499,7 @@ struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
 	.content_size = client_content_size,
 	.packet_size = client_packet_size,
 	.stream_id = client_stream_id,
+	.current_timestamp = client_current_timestamp,
 };
 
 static const struct lttng_ust_lib_ring_buffer_config client_config = {
Signature · 1 line
1.8.3.2
#3 lore raw

Re: [UST PATCH 1/3] Specialize lttng_ust_lib_ring_buffer_client_cb

In reply to a message not in the archive

patches 1 to 3 merged, thanks!

Mathieu

Quoted 193 lines · * Julien Desfossez ([email protected]) wrote:

Prepare the ring-buffer config to have custom callbacks. These custom callbacks are not related to the ring-buffer operations but allow applications to add custom functions.
No additional feature or change in behaviour in this patch.

---
 include/lttng/ringbuffer-config.h                |  4 +++-
 include/lttng/ust-events.h                       |  6 +++---
 liblttng-ust/Makefile.am                         |  1 +
 liblttng-ust/lttng-rb-clients.h                  | 26 ++++++++++++++++++++++++
 liblttng-ust/lttng-ring-buffer-client.h          | 18 +++++++++++++++-
 liblttng-ust/lttng-ring-buffer-metadata-client.h | 18 +++++++++++++++-
 6 files changed, 67 insertions(+), 6 deletions(-)
 create mode 100644 liblttng-ust/lttng-rb-clients.h
include/lttng/ringbuffer-config.h +3 -1
index 3b7d348..9de9a73 100644
@@ -133,7 +133,7 @@ struct lttng_ust_lib_ring_buffer_client_cb {
  * RING_BUFFER_WAKEUP_NONE does not perform any wakeup whatsoever. The client
  * has the responsibility to perform wakeups.
  */
-#define LTTNG_UST_RING_BUFFER_CONFIG_PADDING	32
+#define LTTNG_UST_RING_BUFFER_CONFIG_PADDING	20
 
 enum lttng_ust_lib_ring_buffer_alloc_types {
 	RING_BUFFER_ALLOC_PER_CPU,
@@ -204,6 +204,8 @@ struct lttng_ust_lib_ring_buffer_config {
 	 * callbacks and update the cb pointers.
 	 */
 	int client_type;
+	int _unused1;
+	const struct lttng_ust_lib_ring_buffer_client_cb *cb_ptr;
 	char padding[LTTNG_UST_RING_BUFFER_CONFIG_PADDING];
 };
 
include/lttng/ust-events.h +3 -3
index f40c044..74a3bc6 100644
@@ -569,9 +569,9 @@ int lttng_add_ip_to_ctx(struct lttng_ctx **ctx);
 void lttng_context_vtid_reset(void);
 void lttng_context_vpid_reset(void);
 
-extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
-extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
-extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
+extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
+extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
+extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
 
 struct lttng_transport *lttng_transport_find(const char *name);
 
liblttng-ust/Makefile.am +1 -0
index 1e6401a..5a43cf5 100644
@@ -47,6 +47,7 @@ liblttng_ust_support_la_SOURCES = \
 	lttng-tracer.h \
 	lttng-tracer-core.h \
 	ust-core.c \
+	lttng-rb-clients.h \
 	lttng-ring-buffer-client.h \
 	lttng-ring-buffer-client-discard.c \
 	lttng-ring-buffer-client-discard-rt.c \
liblttng-ust/lttng-rb-clients.h new file +26 -0
new file mode 100644
index 0000000..c9a1619
@@ -0,0 +1,26 @@
+#ifndef _LTTNG_RB_CLIENT_H
+#define _LTTNG_RB_CLIENT_H
+
+/*
+ * Copyright (c) 2013 - Mathieu Desnoyers <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+struct lttng_ust_client_lib_ring_buffer_client_cb {
+	struct lttng_ust_lib_ring_buffer_client_cb parent;
+};
+
+#endif /* _LTTNG_RB_CLIENT_H */
liblttng-ust/lttng-ring-buffer-client.h +17 -1
index 72b6d2c..383fce0 100644
@@ -161,6 +161,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
 }
 
 #include "../libringbuffer/api.h"
+#include "lttng-rb-clients.h"
 
 static
 void lttng_write_event_header_slow(const struct lttng_ust_lib_ring_buffer_config *config,
@@ -385,6 +386,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf, void *
 {
 }
 
+static const
+struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
+	.parent = {
+		.ring_buffer_clock_read = client_ring_buffer_clock_read,
+		.record_header_size = client_record_header_size,
+		.subbuffer_header_size = client_packet_header_size,
+		.buffer_begin = client_buffer_begin,
+		.buffer_end = client_buffer_end,
+		.buffer_create = client_buffer_create,
+		.buffer_finalize = client_buffer_finalize,
+	},
+};
+
 static const struct lttng_ust_lib_ring_buffer_config client_config = {
 	.cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
 	.cb.record_header_size = client_record_header_size,
@@ -404,9 +418,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
 	.ipi = RING_BUFFER_NO_IPI_BARRIER,
 	.wakeup = LTTNG_CLIENT_WAKEUP,
 	.client_type = LTTNG_CLIENT_TYPE,
+
+	.cb_ptr = &client_cb.parent,
 };
 
-const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
+const struct lttng_ust_client_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
 
 static
 struct lttng_channel *_channel_create(const char *name,
liblttng-ust/lttng-ring-buffer-metadata-client.h +17 -1
index 89f2620..0d2a1f8 100644
@@ -61,6 +61,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
 }
 
 #include "../libringbuffer/api.h"
+#include "lttng-rb-clients.h"
 
 static uint64_t client_ring_buffer_clock_read(struct channel *chan)
 {
@@ -153,6 +154,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf,
 {
 }
 
+static const
+struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
+	.parent = {
+		.ring_buffer_clock_read = client_ring_buffer_clock_read,
+		.record_header_size = client_record_header_size,
+		.subbuffer_header_size = client_packet_header_size,
+		.buffer_begin = client_buffer_begin,
+		.buffer_end = client_buffer_end,
+		.buffer_create = client_buffer_create,
+		.buffer_finalize = client_buffer_finalize,
+	},
+};
+
 static const struct lttng_ust_lib_ring_buffer_config client_config = {
 	.cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
 	.cb.record_header_size = client_record_header_size,
@@ -172,9 +186,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
 	.ipi = RING_BUFFER_NO_IPI_BARRIER,
 	.wakeup = RING_BUFFER_WAKEUP_BY_WRITER,
 	.client_type = LTTNG_CLIENT_TYPE,
+
+	 .cb_ptr = &client_cb.parent,
 };
 
-const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
+const struct lttng_ust_client_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
 
 static
 struct lttng_channel *_channel_create(const char *name,
Signature · 1 line
1.8.3.2
Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com