From: Julien Desfossez Date: Mon, 16 Sep 2013 15:18:32 +0000 (-0400) Subject: Per-stream ioctl to get the current timestamp X-Git-Tag: v2.4.0-rc1~13 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=2348ca17d04c122d21f9329faa6941d0b147b378;p=lttng-modules.git Per-stream ioctl to get the current timestamp Signed-off-by: Julien Desfossez Signed-off-by: Mathieu Desnoyers --- diff --git a/lttng-abi.c b/lttng-abi.c index c2560e05..224b3528 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 b028f1ec..3f2aefbe 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 bce6507c..f0628c4c 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 167000a3..50c47b3b 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 61307154..bea482b9 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,