[lttng-dev] [MODULES PATCH 3/4] Per-stream ioctl to get the current timestamp
Julien Desfossez
jdesfossez at efficios.com
Mon Sep 16 11:18:32 EDT 2013
Signed-off-by: Julien Desfossez <jdesfossez at efficios.com>
---
lttng-abi.c | 22 ++++++++++++++++++++++
lttng-abi.h | 5 +++++
lttng-events.h | 3 +++
lttng-ring-buffer-client.h | 10 ++++++++++
lttng-ring-buffer-metadata-client.h | 8 ++++++++
5 files changed, 48 insertions(+)
diff --git a/lttng-abi.c b/lttng-abi.c
index c2560e0..224b352 100644
--- a/lttng-abi.c
+++ b/lttng-abi.c
@@ -1408,6 +1408,17 @@ static long lttng_stream_ring_buffer_ioctl(struct file *filp,
goto error;
return put_u64(si, arg);
}
+ case LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP:
+ {
+ uint64_t ts;
+
+ if (!lttng_chan->ops)
+ goto error;
+ ret = lttng_chan->ops->current_timestamp(config, buf, &ts);
+ if (ret < 0)
+ goto error;
+ return put_u64(ts, arg);
+ }
default:
return lib_ring_buffer_file_operations.unlocked_ioctl(filp,
cmd, arg);
@@ -1497,6 +1508,17 @@ static long lttng_stream_ring_buffer_compat_ioctl(struct file *filp,
goto error;
return put_u64(si, arg);
}
+ case LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP:
+ {
+ uint64_t ts;
+
+ if (!lttng_chan->ops)
+ goto error;
+ ret = lttng_chan->ops->current_timestamp(config, buf, &ts);
+ if (ret < 0)
+ goto error;
+ return put_u64(ts, arg);
+ }
default:
return lib_ring_buffer_file_operations.compat_ioctl(filp,
cmd, arg);
diff --git a/lttng-abi.h b/lttng-abi.h
index b028f1e..3f2aefb 100644
--- a/lttng-abi.h
+++ b/lttng-abi.h
@@ -187,6 +187,8 @@ struct lttng_kernel_context {
#define LTTNG_RING_BUFFER_GET_PACKET_SIZE _IOR(0xF6, 0x24, uint64_t)
/* returns the stream id */
#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)
#ifdef CONFIG_COMPAT
/* returns the timestamp begin of the current sub-buffer */
@@ -207,6 +209,9 @@ struct lttng_kernel_context {
/* returns the stream id */
#define LTTNG_RING_BUFFER_COMPAT_GET_STREAM_ID \
LTTNG_RING_BUFFER_GET_STREAM_ID
+/* returns the current timestamp */
+#define LTTNG_RING_BUFFER_COMPAT_GET_CURRENT_TIMESTAMP \
+ LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP
#endif /* CONFIG_COMPAT */
#endif /* _LTTNG_ABI_H */
diff --git a/lttng-events.h b/lttng-events.h
index bce6507..f0628c4 100644
--- a/lttng-events.h
+++ b/lttng-events.h
@@ -263,6 +263,9 @@ struct lttng_channel_ops {
int (*stream_id) (const struct lib_ring_buffer_config *config,
struct lib_ring_buffer *bufb,
uint64_t *stream_id);
+ int (*current_timestamp) (const struct lib_ring_buffer_config *config,
+ struct lib_ring_buffer *bufb,
+ uint64_t *ts);
};
struct lttng_transport {
diff --git a/lttng-ring-buffer-client.h b/lttng-ring-buffer-client.h
index 167000a..50c47b3 100644
--- a/lttng-ring-buffer-client.h
+++ b/lttng-ring-buffer-client.h
@@ -467,6 +467,15 @@ static int client_stream_id(const struct lib_ring_buffer_config *config,
return 0;
}
+static int client_current_timestamp(const struct lib_ring_buffer_config *config,
+ struct lib_ring_buffer *bufb,
+ uint64_t *ts)
+{
+ *ts = config->cb.ring_buffer_clock_read(bufb->backend.chan);
+
+ 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,
@@ -500,6 +509,7 @@ struct channel *_channel_create(const char *name,
lttng_chan->ops->content_size = client_content_size;
lttng_chan->ops->packet_size = client_packet_size;
lttng_chan->ops->stream_id = client_stream_id;
+ lttng_chan->ops->current_timestamp = client_current_timestamp;
return channel_create(&client_config, name, lttng_chan, buf_addr,
subbuf_size, num_subbuf, switch_timer_interval,
diff --git a/lttng-ring-buffer-metadata-client.h b/lttng-ring-buffer-metadata-client.h
index 6130715..bea482b 100644
--- a/lttng-ring-buffer-metadata-client.h
+++ b/lttng-ring-buffer-metadata-client.h
@@ -168,6 +168,13 @@ static int client_events_discarded(const struct lib_ring_buffer_config *config,
return -ENOSYS;
}
+static int client_current_timestamp(const struct lib_ring_buffer_config *config,
+ struct lib_ring_buffer *bufb,
+ uint64_t *ts)
+{
+ return -ENOSYS;
+}
+
static int client_content_size(const struct lib_ring_buffer_config *config,
struct lib_ring_buffer *bufb,
uint64_t *content_size)
@@ -222,6 +229,7 @@ struct channel *_channel_create(const char *name,
lttng_chan->ops->content_size = client_content_size;
lttng_chan->ops->packet_size = client_packet_size;
lttng_chan->ops->stream_id = client_stream_id;
+ lttng_chan->ops->current_timestamp = client_current_timestamp;
return channel_create(&client_config, name, lttng_chan, buf_addr,
subbuf_size, num_subbuf, switch_timer_interval,
--
1.8.3.2
More information about the lttng-dev
mailing list