Per-stream ioctl to get the current timestamp
authorJulien Desfossez <jdesfossez@efficios.com>
Mon, 16 Sep 2013 15:18:32 +0000 (11:18 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 16 Sep 2013 16:28:12 +0000 (11:28 -0500)
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng-abi.c
lttng-abi.h
lttng-events.h
lttng-ring-buffer-client.h
lttng-ring-buffer-metadata-client.h

index c2560e0573c2a9a5827a8bfb10d18b7642c96f1a..224b35284d859ce1b181c8fbb75ed06596d44f9e 100644 (file)
@@ -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);
index b028f1ec0b840a8ab3806f8798ac5f6ed6e93810..3f2aefbea04cd1fa52909c7a7fe5b76ec047ab6f 100644 (file)
@@ -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 */
index bce6507c77989450f682e983b08856cec3e5ea99..f0628c4cd7a9582e7f2a271c8ddd0b092edd7a54 100644 (file)
@@ -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 {
index 167000a32bf9bc73b8501f0917812dc9c3d777ae..50c47b3bf49f6c2dd24e250cf1a9b97808cd8e27 100644 (file)
@@ -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,
index 61307154ef6ddf75c4927d428d09829e8538e67d..bea482b9a961316460800bb9d4294ef2ea8c7b45 100644 (file)
@@ -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,
This page took 0.028397 seconds and 4 git commands to generate.