LTTng ringbuffer ABI calls for index generation
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/4 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
--- lttng-abi.c | 174 ++++++++++++++++++++++++++++++++++-- lttng-abi.h | 35 ++++++++ lttng-events.c | 2 +- lttng-events.h | 19 ++++ lttng-ring-buffer-client.h | 84 +++++++++++++++++ lttng-ring-buffer-metadata-client.h | 48 ++++++++++ 6 files changed, 355 insertions(+), 7 deletions(-)
lttng-abi.c +168 -6
@@ -52,6 +52,7 @@#include "lttng-abi-old.h" #include "lttng-events.h" #include "lttng-tracer.h" +#include "lib/ringbuffer/frontend_types.h" /* * This is LTTng's own personal way to create a system call as an external
@@ -1323,25 +1324,186 @@ static const struct file_operations lttng_event_fops = {#endif }; +static int put_u64 (uint64_t val,unsigned long arg) +{ +return put_user (val, (uint64_t __user *) arg); +} +static long lttng_stream_ring_buffer_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { +struct lib_ring_buffer *buf = filp->private_data; +struct channel *chan = buf->backend.chan; +const struct lib_ring_buffer_config *config = &chan->backend.config; +struct lttng_channel *lttng_chan =channel_get_private (chan); +int ret; + +if (atomic_read (&chan->record_disabled)) +return -EIO ; +switch (cmd) { -default : -return lib_ring_buffer_file_operations.unlocked_ioctl (filp, - cmd, arg); +case LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN : + { +uint64_t ts; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->timestamp_begin (config, buf, &ts); +if (ret <0 ) + goto error; +return put_u64 (ts, arg); } +case LTTNG_RING_BUFFER_GET_TIMESTAMP_END : + { +uint64_t ts; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->timestamp_end (config, buf, &ts); +if (ret <0 ) + goto error; +return put_u64 (ts, arg); + } +case LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED : + { +uint64_t ed; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->events_discarded (config, buf, &ed); +if (ret <0 ) + goto error; +return put_u64 (ed, arg); + } +case LTTNG_RING_BUFFER_GET_CONTENT_SIZE : + { +uint64_t cs; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->content_size (config, buf, &cs); +if (ret <0 ) + goto error; +return put_u64 (cs, arg); + } +case LTTNG_RING_BUFFER_GET_PACKET_SIZE : + { +uint64_t ps; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->packet_size (config, buf, &ps); +if (ret <0 ) + goto error; +return put_u64 (ps, arg); + } +case LTTNG_RING_BUFFER_GET_STREAM_ID : + { +uint64_t si; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->stream_id (config, buf, &si); +if (ret <0 ) + goto error; +return put_u64 (si, arg); + } +default : +return lib_ring_buffer_file_operations.unlocked_ioctl (filp, + cmd, arg); + } + +error: +return -ENOSYS ; }#ifdef CONFIG_COMPAT static long lttng_stream_ring_buffer_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { +struct lib_ring_buffer *buf = filp->private_data; +struct channel *chan = buf->backend.chan; +const struct lib_ring_buffer_config *config = &chan->backend.config; +struct lttng_channel *lttng_chan =channel_get_private (chan); +int ret; + +if (atomic_read (&chan->record_disabled)) +return -EIO ; +switch (cmd) { -default : -return lib_ring_buffer_file_operations.compat_ioctl (filp, - cmd, arg); +case LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_BEGIN : + { +uint64_t ts; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->timestamp_begin (config, buf, &ts); +if (ret <0 ) + goto error; +return put_u64 (ts, arg); + } +case LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_END : + { +uint64_t ts; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->timestamp_end (config, buf, &ts); +if (ret <0 ) + goto error; +return put_u64 (ts, arg); + } +case LTTNG_RING_BUFFER_COMPAT_GET_EVENTS_DISCARDED : + { +uint64_t ed; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->events_discarded (config, buf, &ed); +if (ret <0 ) + goto error; +return put_u64 (ed, arg); } +case LTTNG_RING_BUFFER_COMPAT_GET_CONTENT_SIZE : + { +uint64_t cs; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->content_size (config, buf, &cs); +if (ret <0 ) + goto error; +return put_u64 (cs, arg); + } +case LTTNG_RING_BUFFER_COMPAT_GET_PACKET_SIZE : + { +uint64_t ps; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->packet_size (config, buf, &ps); +if (ret <0 ) + goto error; +return put_u64 (ps, arg); + } +case LTTNG_RING_BUFFER_COMPAT_GET_STREAM_ID : + { +uint64_t si; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->stream_id (config, buf, &si); +if (ret <0 ) + goto error; +return put_u64 (si, arg); + } +default : +return lib_ring_buffer_file_operations.compat_ioctl (filp, + cmd, arg); + } + +error: +return -ENOSYS ; }#endif /* CONFIG_COMPAT */
lttng-abi.h +35 -0
@@ -174,4 +174,39 @@ struct lttng_kernel_context {#define LTTNG_KERNEL_ENABLE _IO(0xF6, 0x82)#define LTTNG_KERNEL_DISABLE _IO(0xF6, 0x83) +/* LTTng-specific ioctls for the lib ringbuffer */ +/* returns the timestamp begin of the current sub-buffer */ +#define LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN _IOR(0xF6, 0x20, uint64_t) +/* returns the timestamp end of the current sub-buffer */ +#define LTTNG_RING_BUFFER_GET_TIMESTAMP_END _IOR(0xF6, 0x21, uint64_t) +/* returns the number of events discarded */ +#define LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED _IOR(0xF6, 0x22, uint64_t) +/* returns the packet payload size */ +#define LTTNG_RING_BUFFER_GET_CONTENT_SIZE _IOR(0xF6, 0x23, uint64_t) +/* returns the actual packet size */ +#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) + +#ifdef CONFIG_COMPAT +/* returns the timestamp begin of the current sub-buffer */ +#define LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_BEGIN \ + LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN +/* returns the timestamp end of the current sub-buffer */ +#define LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_END \ + LTTNG_RING_BUFFER_GET_TIMESTAMP_END +/* returns the number of events discarded */ +#define LTTNG_RING_BUFFER_COMPAT_GET_EVENTS_DISCARDED \ + LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED +/* returns the packet payload size */ +#define LTTNG_RING_BUFFER_COMPAT_GET_CONTENT_SIZE \ + LTTNG_RING_BUFFER_GET_CONTENT_SIZE +/* returns the actual packet size */ +#define LTTNG_RING_BUFFER_COMPAT_GET_PACKET_SIZE \ + LTTNG_RING_BUFFER_GET_PACKET_SIZE +/* returns the stream id */ +#define LTTNG_RING_BUFFER_COMPAT_GET_STREAM_ID \ + LTTNG_RING_BUFFER_GET_STREAM_ID +#endif /* CONFIG_COMPAT */ +#endif /* _LTTNG_ABI_H */
lttng-events.c +1 -1
@@ -285,6 +285,7 @@ struct lttng_channel *lttng_channel_create(struct lttng_session *session, goto nomem; chan->session = session; chan->id = session->free_chan_id++; + chan->ops = &transport->ops;/* * Note: the channel creation op already writes into the packet * headers. Therefore the "chan" information used as input
@@ -296,7 +297,6 @@ struct lttng_channel *lttng_channel_create(struct lttng_session *session,if (!chan->chan) goto create_error; chan->enabled =1 ; - chan->ops = &transport->ops; chan->transport = transport; chan->channel_type = channel_type;list_add (&chan->list, &session->chan);
lttng-events.h +19 -0
@@ -39,6 +39,7 @@ struct lttng_metadata_cache;struct lib_ring_buffer_ctx ;struct perf_event ;struct perf_event_attr ; +struct lib_ring_buffer_config ;/* Type description */
@@ -244,6 +245,24 @@ struct lttng_channel_ops {wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);int (*is_finalized)(struct channel *chan);int (*is_disabled)(struct channel *chan); +int (*timestamp_begin) (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *bufb, +uint64_t *timestamp_begin); +int (*timestamp_end) (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *bufb, +uint64_t *timestamp_end); +int (*events_discarded) (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *bufb, +uint64_t *events_discarded); +int (*content_size) (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *bufb, +uint64_t *content_size); +int (*packet_size) (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *bufb, +uint64_t *packet_size); +int (*stream_id) (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *bufb, +uint64_t *stream_id); };struct lttng_transport {
lttng-ring-buffer-client.h +84 -0
96 lines not on this page · raw message
lttng-ring-buffer-metadata-client.h +48 -0
60 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH 3/4 Per-stream ioctl to get the current timestamp
In reply to a message not in the archive--- 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(+)
lttng-abi.c +22 -0
@@ -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);
lttng-abi.h +5 -0
@@ -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 */
lttng-events.h +3 -0
@@ -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 {
lttng-ring-buffer-client.h +10 -0
@@ -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,
lttng-ring-buffer-metadata-client.h +8 -0
@@ -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,
Signature · 1 line
1.8.3.2
PATCH 4/4 Metadata flush writes data from the cache
In reply to a message not in the archiveWhen doing a flush on a metadata stream we first check if we can fill the current subbuffer with data from the cache before doing the actual flush.
--- lttng-abi.c | 56 +++++++++++++++++++++++++++++++++----------------------- lttng-events.c | 2 ++ 2 files changed, 35 insertions(+), 23 deletions(-)
lttng-abi.c +33 -23
@@ -549,23 +549,6 @@ unsigned int lttng_metadata_ring_buffer_poll(struct file *filp, }static -int lttng_metadata_ring_buffer_ioctl_get_next_subbuf (struct file *filp, -unsigned int cmd,unsigned long arg) -{ -struct lttng_metadata_stream *stream = filp->private_data; -struct lib_ring_buffer *buf = stream->priv; -struct channel *chan = buf->backend.chan; -int ret; - - ret =lttng_metadata_output_channel (stream, chan); -if (ret >0 ) { -lib_ring_buffer_switch_slow (buf,SWITCH_ACTIVE ); - ret =0 ; - } -return ret; -} - -static void lttng_metadata_ring_buffer_ioctl_put_next_subbuf (struct file *filp,unsigned int cmd,unsigned long arg) {
@@ -585,9 +568,15 @@ long lttng_metadata_ring_buffer_ioctl(struct file *filp,switch (cmd) {case RING_BUFFER_GET_NEXT_SUBBUF : { - ret =lttng_metadata_ring_buffer_ioctl_get_next_subbuf (filp, - cmd, arg); -if (ret <0 ) +struct lttng_metadata_stream *stream = filp->private_data; +struct lib_ring_buffer *buf = stream->priv; +struct channel *chan = buf->backend.chan; + + ret =lttng_metadata_output_channel (stream, chan); +if (ret >0 ) { +lib_ring_buffer_switch_slow (buf,SWITCH_ACTIVE ); + ret =0 ; + }else if (ret <0 ) goto err;break ; }
@@ -598,6 +587,21 @@ long lttng_metadata_ring_buffer_ioctl(struct file *filp,*/ return -ENOSYS ; } +case RING_BUFFER_FLUSH : + { +struct lttng_metadata_stream *stream = filp->private_data; +struct lib_ring_buffer *buf = stream->priv; +struct channel *chan = buf->backend.chan; + +/* +* Before doing the actual ring buffer flush, write up to one +* packet of metadata in the ring buffer. +*/ + ret =lttng_metadata_output_channel (stream, chan); +if (ret <0 ) + goto err; +break ; + }default :break ; }
@@ -634,9 +638,15 @@ long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp,switch (cmd) {case RING_BUFFER_GET_NEXT_SUBBUF : { - ret =lttng_metadata_ring_buffer_ioctl_get_next_subbuf (filp, - cmd, arg); -if (ret <0 ) +struct lttng_metadata_stream *stream = filp->private_data; +struct lib_ring_buffer *buf = stream->priv; +struct channel *chan = buf->backend.chan; + + ret =lttng_metadata_output_channel (stream, chan); +if (ret >0 ) { +lib_ring_buffer_switch_slow (buf,SWITCH_ACTIVE ); + ret =0 ; + }else if (ret <0 ) goto err;break ; }
lttng-events.c +2 -0
@@ -553,6 +553,8 @@ void _lttng_event_destroy(struct lttng_event *event)* sessions_mutex), so we can do racy operations such as looking for * remaining space left in packet and write, since mutual exclusion * protects us from concurrent writes. +* Returns the number of bytes written in the channel, 0 if no data +* was written and a negative value on error. */ int lttng_metadata_output_channel (struct lttng_metadata_stream *stream,struct channel *chan)
Signature · 1 line
1.8.3.2
Mathieu Desnoyers
AppliedRe: [MODULES PATCH 1/4] Prepare LTTng override of ring buffer fops
In reply to a message not in the archivemerged, thanks!
Mathieu
Quoted 96 lines · * Julien Desfossez ([email protected]) wrote:
This patch allows LTTng to override the file operations of the lib ring buffer.
For now it does not provide any additional functions, but it prepares the work of adding LTTng-specific ioctls to the ring buffer.Signed-off-by Julien Desfossez <[email protected]>--- lttng-abi.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-)lttng-abi.c +49
-1@@ -64,6 +64,7 @@ static const struct file_operations lttng_session_fops;static const struct file_operations lttng_channel_fops;static const struct file_operations lttng_metadata_fops;static const struct file_operations lttng_event_fops; +static struct file_operations lttng_stream_ring_buffer_file_operations;/* * Teardown management: opened file descriptors keep a refcount on the module, @@ -792,7 +793,7 @@ int lttng_abi_open_stream(struct file *channel_file) stream_priv = buf; ret =lttng_abi_create_stream_fd (channel_file, stream_priv, - &lib_ring_buffer_file_operations); + <tng_stream_ring_buffer_file_operations);if (ret <0 ) goto fd_error;@@ -1322,6 +1323,51 @@ static const struct file_operations lttng_event_fops = {#endif }; +static long lttng_stream_ring_buffer_ioctl (struct file *filp, +unsigned int cmd,unsigned long arg) +{ +switch (cmd) { +default : +return lib_ring_buffer_file_operations.unlocked_ioctl (filp, + cmd, arg); + } +} + +#ifdef CONFIG_COMPAT +static long lttng_stream_ring_buffer_compat_ioctl (struct file *filp, +unsigned int cmd,unsigned long arg) +{ +switch (cmd) { +default : +return lib_ring_buffer_file_operations.compat_ioctl (filp, + cmd, arg); + } +} +#endif /* CONFIG_COMPAT */ + +static void lttng_stream_override_ring_buffer_fops (void ) +{ + lttng_stream_ring_buffer_file_operations.owner =THIS_MODULE ; + lttng_stream_ring_buffer_file_operations.open = + lib_ring_buffer_file_operations.open; + lttng_stream_ring_buffer_file_operations.release = + lib_ring_buffer_file_operations.release; + lttng_stream_ring_buffer_file_operations.poll = + lib_ring_buffer_file_operations.poll; + lttng_stream_ring_buffer_file_operations.splice_read = + lib_ring_buffer_file_operations.splice_read; + lttng_stream_ring_buffer_file_operations.mmap = + lib_ring_buffer_file_operations.mmap; + lttng_stream_ring_buffer_file_operations.unlocked_ioctl = + lttng_stream_ring_buffer_ioctl; + lttng_stream_ring_buffer_file_operations.llseek = + lib_ring_buffer_file_operations.llseek; +#ifdef CONFIG_COMPAT + lttng_stream_ring_buffer_file_operations.compat_ioctl = + lttng_stream_ring_buffer_compat_ioctl; +#endif +} +int __init lttng_abi_init (void ) {int ret =0 ;@@ -1335,6 +1381,8 @@ int __init lttng_abi_init(void) ret = -ENOMEM ; goto error; } +lttng_stream_override_ring_buffer_fops (); + error:return ret; }Signature · 1 line
1.8.3.2
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]
Mathieu Desnoyers
AppliedMerged, thanks!
Mathieu
Quoted 497 lines · * Julien Desfossez ([email protected]) wrote:
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 idSigned-off-by Julien Desfossez <[email protected]>--- lttng-abi.c | 174 ++++++++++++++++++++++++++++++++++-- lttng-abi.h | 35 ++++++++ lttng-events.c | 2 +- lttng-events.h | 19 ++++ lttng-ring-buffer-client.h | 84 +++++++++++++++++ lttng-ring-buffer-metadata-client.h | 48 ++++++++++ 6 files changed, 355 insertions(+), 7 deletions(-)lttng-abi.c +168
-6@@ -52,6 +52,7 @@#include "lttng-abi-old.h" #include "lttng-events.h" #include "lttng-tracer.h" +#include "lib/ringbuffer/frontend_types.h" /* * This is LTTng's own personal way to create a system call as an external @@ -1323,25 +1324,186 @@ static const struct file_operations lttng_event_fops = {#endif }; +static int put_u64 (uint64_t val,unsigned long arg) +{ +return put_user (val, (uint64_t __user *) arg); +} +static long lttng_stream_ring_buffer_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { +struct lib_ring_buffer *buf = filp->private_data; +struct channel *chan = buf->backend.chan; +const struct lib_ring_buffer_config *config = &chan->backend.config; +struct lttng_channel *lttng_chan =channel_get_private (chan); +int ret; + +if (atomic_read (&chan->record_disabled)) +return -EIO ; +switch (cmd) { -default : -return lib_ring_buffer_file_operations.unlocked_ioctl (filp, - cmd, arg); +case LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN : + { +uint64_t ts; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->timestamp_begin (config, buf, &ts); +if (ret <0 ) + goto error; +return put_u64 (ts, arg); } +case LTTNG_RING_BUFFER_GET_TIMESTAMP_END : + { +uint64_t ts; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->timestamp_end (config, buf, &ts); +if (ret <0 ) + goto error; +return put_u64 (ts, arg); + } +case LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED : + { +uint64_t ed; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->events_discarded (config, buf, &ed); +if (ret <0 ) + goto error; +return put_u64 (ed, arg); + } +case LTTNG_RING_BUFFER_GET_CONTENT_SIZE : + { +uint64_t cs; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->content_size (config, buf, &cs); +if (ret <0 ) + goto error; +return put_u64 (cs, arg); + } +case LTTNG_RING_BUFFER_GET_PACKET_SIZE : + { +uint64_t ps; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->packet_size (config, buf, &ps); +if (ret <0 ) + goto error; +return put_u64 (ps, arg); + } +case LTTNG_RING_BUFFER_GET_STREAM_ID : + { +uint64_t si; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->stream_id (config, buf, &si); +if (ret <0 ) + goto error; +return put_u64 (si, arg); + } +default : +return lib_ring_buffer_file_operations.unlocked_ioctl (filp, + cmd, arg); + } + +error: +return -ENOSYS ; }#ifdef CONFIG_COMPAT static long lttng_stream_ring_buffer_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { +struct lib_ring_buffer *buf = filp->private_data; +struct channel *chan = buf->backend.chan; +const struct lib_ring_buffer_config *config = &chan->backend.config; +struct lttng_channel *lttng_chan =channel_get_private (chan); +int ret; + +if (atomic_read (&chan->record_disabled)) +return -EIO ; +switch (cmd) { -default : -return lib_ring_buffer_file_operations.compat_ioctl (filp, - cmd, arg); +case LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_BEGIN : + { +uint64_t ts; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->timestamp_begin (config, buf, &ts); +if (ret <0 ) + goto error; +return put_u64 (ts, arg); + } +case LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_END : + { +uint64_t ts; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->timestamp_end (config, buf, &ts); +if (ret <0 ) + goto error; +return put_u64 (ts, arg); + } +case LTTNG_RING_BUFFER_COMPAT_GET_EVENTS_DISCARDED : + { +uint64_t ed; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->events_discarded (config, buf, &ed); +if (ret <0 ) + goto error; +return put_u64 (ed, arg); } +case LTTNG_RING_BUFFER_COMPAT_GET_CONTENT_SIZE : + { +uint64_t cs; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->content_size (config, buf, &cs); +if (ret <0 ) + goto error; +return put_u64 (cs, arg); + } +case LTTNG_RING_BUFFER_COMPAT_GET_PACKET_SIZE : + { +uint64_t ps; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->packet_size (config, buf, &ps); +if (ret <0 ) + goto error; +return put_u64 (ps, arg); + } +case LTTNG_RING_BUFFER_COMPAT_GET_STREAM_ID : + { +uint64_t si; + +if (!lttng_chan->ops) + goto error; + ret = lttng_chan->ops->stream_id (config, buf, &si); +if (ret <0 ) + goto error; +return put_u64 (si, arg); + } +default : +return lib_ring_buffer_file_operations.compat_ioctl (filp, + cmd, arg); + } + +error: +return -ENOSYS ; }#endif /* CONFIG_COMPAT */ lttng-abi.h +35
-0@@ -174,4 +174,39 @@ struct lttng_kernel_context {#define LTTNG_KERNEL_ENABLE _IO(0xF6, 0x82)#define LTTNG_KERNEL_DISABLE _IO(0xF6, 0x83) +/* LTTng-specific ioctls for the lib ringbuffer */ +/* returns the timestamp begin of the current sub-buffer */ +#define LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN _IOR(0xF6, 0x20, uint64_t) +/* returns the timestamp end of the current sub-buffer */ +#define LTTNG_RING_BUFFER_GET_TIMESTAMP_END _IOR(0xF6, 0x21, uint64_t) +/* returns the number of events discarded */ +#define LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED _IOR(0xF6, 0x22, uint64_t) +/* returns the packet payload size */ +#define LTTNG_RING_BUFFER_GET_CONTENT_SIZE _IOR(0xF6, 0x23, uint64_t) +/* returns the actual packet size */ +#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) + +#ifdef CONFIG_COMPAT +/* returns the timestamp begin of the current sub-buffer */ +#define LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_BEGIN \ + LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN +/* returns the timestamp end of the current sub-buffer */ +#define LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_END \ + LTTNG_RING_BUFFER_GET_TIMESTAMP_END +/* returns the number of events discarded */ +#define LTTNG_RING_BUFFER_COMPAT_GET_EVENTS_DISCARDED \ + LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED +/* returns the packet payload size */ +#define LTTNG_RING_BUFFER_COMPAT_GET_CONTENT_SIZE \ + LTTNG_RING_BUFFER_GET_CONTENT_SIZE +/* returns the actual packet size */ +#define LTTNG_RING_BUFFER_COMPAT_GET_PACKET_SIZE \ + LTTNG_RING_BUFFER_GET_PACKET_SIZE +/* returns the stream id */ +#define LTTNG_RING_BUFFER_COMPAT_GET_STREAM_ID \ + LTTNG_RING_BUFFER_GET_STREAM_ID +#endif /* CONFIG_COMPAT */ +#endif /* _LTTNG_ABI_H */ lttng-events.c +1
-1@@ -285,6 +285,7 @@ struct lttng_channel *lttng_channel_create(struct lttng_session *session, goto nomem; chan->session = session; chan->id = session->free_chan_id++; + chan->ops = &transport->ops;/* * Note: the channel creation op already writes into the packet * headers. Therefore the "chan" information used as input @@ -296,7 +297,6 @@ struct lttng_channel *lttng_channel_create(struct lttng_session *session,if (!chan->chan) goto create_error; chan->enabled =1 ; - chan->ops = &transport->ops; chan->transport = transport; chan->channel_type = channel_type;list_add (&chan->list, &session->chan);lttng-events.h +19
-0@@ -39,6 +39,7 @@ struct lttng_metadata_cache;struct lib_ring_buffer_ctx ;struct perf_event ;struct perf_event_attr ; +struct lib_ring_buffer_config ;/* Type description */ @@ -244,6 +245,24 @@ struct lttng_channel_ops {wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);int (*is_finalized)(struct channel *chan);int (*is_disabled)(struct channel *chan); +int (*timestamp_begin) (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *bufb, +uint64_t *timestamp_begin); +int (*timestamp_end) (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *bufb, +uint64_t *timestamp_end); +int (*events_discarded) (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *bufb, +uint64_t *events_discarded); +int (*content_size) (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *bufb, +uint64_t *content_size); +int (*packet_size) (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *bufb, +uint64_t *packet_size); +int (*stream_id) (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *bufb, +uint64_t *stream_id); };struct lttng_transport {lttng-ring-buffer-client.h +84
-0@@ -390,6 +390,83 @@ static void client_buffer_finalize(struct lib_ring_buffer *buf, void *priv, int { } +static struct packet_header *client_packet_header ( +const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *buf) +{ +struct lib_ring_buffer_backend *bufb; +unsigned long sb_bindex; +struct packet_header *header; + + bufb = &buf->backend; + sb_bindex =subbuffer_id_get_index (config, bufb->buf_rsb.id); + header = (struct packet_header *) +lib_ring_buffer_offset_address (bufb, + sb_bindex * bufb->chan->backend.subbuf_size); + +return header; +} + +static int client_timestamp_begin (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *buf, +uint64_t *timestamp_begin) +{ +struct packet_header *header =client_packet_header (config, buf); + *timestamp_begin = header->ctx.timestamp_begin; + +return 0 ; +} + +static int client_timestamp_end (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *buf, +uint64_t *timestamp_end) +{ +struct packet_header *header =client_packet_header (config, buf); + *timestamp_end = header->ctx.timestamp_end; + +return 0 ; +} + +static int client_events_discarded (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *buf, +uint64_t *events_discarded) +{ +struct packet_header *header =client_packet_header (config, buf); + *events_discarded = header->ctx.events_discarded; + +return 0 ; +} + +static int client_content_size (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *buf, +uint64_t *content_size) +{ +struct packet_header *header =client_packet_header (config, buf); + *content_size = header->ctx.content_size; + +return 0 ; +} + +static int client_packet_size (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *buf, +uint64_t *packet_size) +{ +struct packet_header *header =client_packet_header (config, buf); + *packet_size = header->ctx.packet_size; + +return 0 ; +} + +static int client_stream_id (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *buf, +uint64_t *stream_id) +{ +struct packet_header *header =client_packet_header (config, buf); + *stream_id = header->stream_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,@@ -417,6 +494,13 @@ struct channel *_channel_create(const char *name,unsigned int switch_timer_interval, unsigned int read_timer_interval) { + lttng_chan->ops->timestamp_begin = client_timestamp_begin; + lttng_chan->ops->timestamp_end = client_timestamp_end; + lttng_chan->ops->events_discarded = client_events_discarded; + lttng_chan->ops->content_size = client_content_size; + lttng_chan->ops->packet_size = client_packet_size; + lttng_chan->ops->stream_id = client_stream_id; +return channel_create (&client_config, name, lttng_chan, buf_addr, subbuf_size, num_subbuf, switch_timer_interval, read_timer_interval);lttng-ring-buffer-metadata-client.h +48
-0@@ -148,6 +148,47 @@ static void client_buffer_finalize(struct lib_ring_buffer *buf, void *priv, int { } +static int client_timestamp_begin (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *buf,uint64_t *timestamp_begin) +{ +return -ENOSYS ; +} + +static int client_timestamp_end (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *bufb, +uint64_t *timestamp_end) +{ +return -ENOSYS ; +} + +static int client_events_discarded (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *bufb, +uint64_t *events_discarded) +{ +return -ENOSYS ; +} + +static int client_content_size (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *bufb, +uint64_t *content_size) +{ +return -ENOSYS ; +} + +static int client_packet_size (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *bufb, +uint64_t *packet_size) +{ +return -ENOSYS ; +} + +static int client_stream_id (const struct lib_ring_buffer_config *config, +struct lib_ring_buffer *bufb, +uint64_t *stream_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,@@ -175,6 +216,13 @@ struct channel *_channel_create(const char *name,unsigned int switch_timer_interval, unsigned int read_timer_interval) { + lttng_chan->ops->timestamp_begin = client_timestamp_begin; + lttng_chan->ops->timestamp_end = client_timestamp_end; + lttng_chan->ops->events_discarded = client_events_discarded; + lttng_chan->ops->content_size = client_content_size; + lttng_chan->ops->packet_size = client_packet_size; + lttng_chan->ops->stream_id = client_stream_id; +return channel_create (&client_config, name, lttng_chan, buf_addr, subbuf_size, num_subbuf, switch_timer_interval, read_timer_interval);Signature · 1 line
1.8.3.2
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]
Mathieu Desnoyers
AppliedRe: [MODULES PATCH 3/4] Per-stream ioctl to get the current timestamp
Merged, thanks!
Mathieu
Quoted 143 lines · * Julien Desfossez ([email protected]) wrote:
Signed-off-by Julien Desfossez <[email protected]>--- 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(+)lttng-abi.c +22
-0@@ -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);lttng-abi.h +5
-0@@ -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 */ lttng-events.h +3
-0@@ -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 {lttng-ring-buffer-client.h +10
-0@@ -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,lttng-ring-buffer-metadata-client.h +8
-0@@ -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,Signature · 1 line
1.8.3.2
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]
Re: [MODULES PATCH 4/4] Metadata flush writes data from the cache
Quoted 3 lines · * Julien Desfossez ([email protected]) wrote:
When doing a flush on a metadata stream we first check if we can fill the current subbuffer with data from the cache before doing the actual flush.
Comments below,
Quoted 57 lines
Signed-off-by Julien Desfossez <[email protected]>--- lttng-abi.c | 56 +++++++++++++++++++++++++++++++++----------------------- lttng-events.c | 2 ++ 2 files changed, 35 insertions(+), 23 deletions(-)lttng-abi.c +9
-20@@ -549,23 +549,6 @@ unsigned int lttng_metadata_ring_buffer_poll(struct file *filp, }static -int lttng_metadata_ring_buffer_ioctl_get_next_subbuf (struct file *filp, -unsigned int cmd,unsigned long arg) -{ -struct lttng_metadata_stream *stream = filp->private_data; -struct lib_ring_buffer *buf = stream->priv; -struct channel *chan = buf->backend.chan; -int ret; - - ret =lttng_metadata_output_channel (stream, chan); -if (ret >0 ) { -lib_ring_buffer_switch_slow (buf,SWITCH_ACTIVE ); - ret =0 ; - } -return ret; -} - -static void lttng_metadata_ring_buffer_ioctl_put_next_subbuf (struct file *filp,unsigned int cmd,unsigned long arg) {@@ -585,9 +568,15 @@ long lttng_metadata_ring_buffer_ioctl(struct file *filp,switch (cmd) {case RING_BUFFER_GET_NEXT_SUBBUF : { - ret =lttng_metadata_ring_buffer_ioctl_get_next_subbuf (filp, - cmd, arg); -if (ret <0 ) +struct lttng_metadata_stream *stream = filp->private_data; +struct lib_ring_buffer *buf = stream->priv; +struct channel *chan = buf->backend.chan; + + ret =lttng_metadata_output_channel (stream, chan); +if (ret >0 ) { +lib_ring_buffer_switch_slow (buf,SWITCH_ACTIVE ); + ret =0 ; + }else if (ret <0 ) goto err;break ; }@@ -598,6 +587,21 @@ long lttng_metadata_ring_buffer_ioctl(struct file *filp,*/ return -ENOSYS ;
lttng-abi.c long lttng_metadata_ring_buffer_ioctl(struct file *filp, · line 598
Quoted 10 lines
lttng-abi.c +9
-0} +case RING_BUFFER_FLUSH : + { +struct lttng_metadata_stream *stream = filp->private_data; +struct lib_ring_buffer *buf = stream->priv; +struct channel *chan = buf->backend.chan; + +/* +* Before doing the actual ring buffer flush, write up to one +* packet of metadata in the ring buffer.
This comment says "Before doing the actual rb flush". But where is it done ? Do we need it at all, or is it done by the following get_subbuf ? I think the code might be right, but the comment does not match the implementation.
Thanks,
Mathieu
Quoted 44 lines
lttng-abi.c +15
-3+*/ + ret =lttng_metadata_output_channel (stream, chan); +if (ret <0 ) + goto err; +break ; + }default :break ; }@@ -634,9 +638,15 @@ long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp,switch (cmd) {case RING_BUFFER_GET_NEXT_SUBBUF : { - ret =lttng_metadata_ring_buffer_ioctl_get_next_subbuf (filp, - cmd, arg); -if (ret <0 ) +struct lttng_metadata_stream *stream = filp->private_data; +struct lib_ring_buffer *buf = stream->priv; +struct channel *chan = buf->backend.chan; + + ret =lttng_metadata_output_channel (stream, chan); +if (ret >0 ) { +lib_ring_buffer_switch_slow (buf,SWITCH_ACTIVE ); + ret =0 ; + }else if (ret <0 ) goto err;break ; }lttng-events.c +2
-0@@ -553,6 +553,8 @@ void _lttng_event_destroy(struct lttng_event *event)* sessions_mutex), so we can do racy operations such as looking for * remaining space left in packet and write, since mutual exclusion * protects us from concurrent writes. +* Returns the number of bytes written in the channel, 0 if no data +* was written and a negative value on error. */ int lttng_metadata_output_channel (struct lttng_metadata_stream *stream,struct channel *chan)Signature · 1 line
1.8.3.2
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): 20130916163632.GD25275@Krystal
Re: [MODULES PATCH 4/4] Metadata flush writes data from the cache
Hi,
Quoted 71 lines · Mathieu Desnoyers
Quoted 3 lines · * Julien Desfossez ([email protected]) wrote:
When doing a flush on a metadata stream we first check if we can fill the current subbuffer with data from the cache before doing the actual flush.
Comments below,
Quoted 64 lines
Signed-off-by Julien Desfossez <[email protected]>--- lttng-abi.c | 56 +++++++++++++++++++++++++++++++++----------------------- lttng-events.c | 2 ++ 2 files changed, 35 insertions(+), 23 deletions(-)lttng-abi.c +15
-20@@ -549,23 +549,6 @@ unsigned int lttng_metadata_ring_buffer_poll(struct file *filp, }static -int lttng_metadata_ring_buffer_ioctl_get_next_subbuf (struct file *filp, -unsigned int cmd,unsigned long arg) -{ -struct lttng_metadata_stream *stream = filp->private_data; -struct lib_ring_buffer *buf = stream->priv; -struct channel *chan = buf->backend.chan; -int ret; - - ret =lttng_metadata_output_channel (stream, chan); -if (ret >0 ) { -lib_ring_buffer_switch_slow (buf,SWITCH_ACTIVE ); - ret =0 ; - } -return ret; -} - -static void lttng_metadata_ring_buffer_ioctl_put_next_subbuf (struct file *filp,unsigned int cmd,unsigned long arg) {@@ -585,9 +568,15 @@ long lttng_metadata_ring_buffer_ioctl(struct file *filp,switch (cmd) {case RING_BUFFER_GET_NEXT_SUBBUF : { - ret =lttng_metadata_ring_buffer_ioctl_get_next_subbuf (filp, - cmd, arg); -if (ret <0 ) +struct lttng_metadata_stream *stream = filp->private_data; +struct lib_ring_buffer *buf = stream->priv; +struct channel *chan = buf->backend.chan; + + ret =lttng_metadata_output_channel (stream, chan); +if (ret >0 ) { +lib_ring_buffer_switch_slow (buf,SWITCH_ACTIVE ); + ret =0 ; + }else if (ret <0 ) goto err;break ; }@@ -598,6 +587,21 @@ long lttng_metadata_ring_buffer_ioctl(struct file *filp,*/ return -ENOSYS ; } +case RING_BUFFER_FLUSH : + { +struct lttng_metadata_stream *stream = filp->private_data; +struct lib_ring_buffer *buf = stream->priv; +struct channel *chan = buf->backend.chan; +
Quoted 8 lines
lttng-abi.c long lttng_metadata_ring_buffer_ioctl(struct file *filp, · line 598
Quoted 3 lines
lttng-abi.c +3
-0+/* +* Before doing the actual ring buffer flush, write up to one +* packet of metadata in the ring buffer. This comment says "Before doing the actual rb flush". But where is it done ? Do we need it at all, or is it done by the following
get_subbuf? I think the code might be right, but the comment does not match the implementation.
When we exit this switch, we end up in lib_ring_buffer_ioctl() performs the RB flush.
Is it ok ?
Thanks,
Julien
Quoted 50 lines
Thanks,
Mathieu
Quoted 44 lines
lttng-abi.c +15
-3+*/ + ret =lttng_metadata_output_channel (stream, chan); +if (ret <0 ) + goto err; +break ; + }default :break ; }@@ -634,9 +638,15 @@ long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp,switch (cmd) {case RING_BUFFER_GET_NEXT_SUBBUF : { - ret =lttng_metadata_ring_buffer_ioctl_get_next_subbuf (filp, - cmd, arg); -if (ret <0 ) +struct lttng_metadata_stream *stream = filp->private_data; +struct lib_ring_buffer *buf = stream->priv; +struct channel *chan = buf->backend.chan; + + ret =lttng_metadata_output_channel (stream, chan); +if (ret >0 ) { +lib_ring_buffer_switch_slow (buf,SWITCH_ACTIVE ); + ret =0 ; + }else if (ret <0 ) goto err;break ; }lttng-events.c +2
-0@@ -553,6 +553,8 @@ void _lttng_event_destroy(struct lttng_event *event)* sessions_mutex), so we can do racy operations such as looking for * remaining space left in packet and write, since mutual exclusion * protects us from concurrent writes. +* Returns the number of bytes written in the channel, 0 if no data +* was written and a negative value on error. */ int lttng_metadata_output_channel (struct lttng_metadata_stream *stream,struct channel *chan)Signature · 1 line
1.8.3.2
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [MODULES PATCH 4/4] Metadata flush writes data from the cache
Quoted 3 lines · * Julien Desfossez ([email protected]) wrote:
Hi,
On 13-09-16 12:36 PM, Mathieu Desnoyers wrote:
[...]
Quoted 8 lines
Quoted 4 lines
This comment says "Before doing the actual rb flush". But where is it done ? Do we need it at all, or is it done by the following
get_subbuf? I think the code might be right, but the comment does not match the implementation.When we exit this switch, we end up in
lib_ring_buffer_ioctl()performs the RB flush.Is it ok ?
yep, I missed that. All good then, merging,
Thanks,
Mathieu
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com