Reference pointers from ust_app_chan to parent structs
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/9 Move lttng utils count_order function to common utils
Part of this code was already duplicated for utils_get_count_order_u32, move the rest of the functions in the common utils since they are going to be useful for the consumer. Adapt the only user to use the new version.
--- src/bin/lttng/commands/enable_channels.c | 4 +- src/bin/lttng/utils.c | 152 ------------------------------- src/bin/lttng/utils.h | 18 ---- src/common/utils.c | 89 ++++++++++++++++++ src/common/utils.h | 2 + 5 files changed, 93 insertions(+), 172 deletions(-)
src/bin/lttng/commands/enable_channels.c +2 -2
@@ -425,7 +425,7 @@ int cmd_enable_channels(int argc, const char **argv) goto end; } - order =get_count_order_u64 (chan.attr.subbuf_size); + order =utils_get_count_order_u64 (chan.attr.subbuf_size);assert (order >=0 ); rounded_size =1ULL << order;if (rounded_size < chan.attr.subbuf_size) {
@@ -461,7 +461,7 @@ int cmd_enable_channels(int argc, const char **argv) goto end; } - order =get_count_order_u64 (chan.attr.num_subbuf); + order =utils_get_count_order_u64 (chan.attr.num_subbuf);assert (order >=0 ); rounded_size =1ULL << order;if (rounded_size < chan.attr.num_subbuf) {
src/bin/lttng/utils.c +0 -152
158 lines not on this page · raw message
src/bin/lttng/utils.h +0 -18
@@ -32,24 +32,6 @@ char *get_session_name_quiet(void);void list_commands (struct cmd_struct *commands,FILE *ofp);void list_cmd_options (FILE *ofp,struct poptOption *options); -/* -* Return the minimum order for which x <= (1UL << order). -* Return -1 if x is 0. -*/ -int get_count_order_u32 (uint32_t x); - -/* -* Return the minimum order for which x <= (1UL << order). -* Return -1 if x is 0. -*/ -int get_count_order_u64 (uint64_t x); - -/* -* Return the minimum order for which x <= (1UL << order). -* Return -1 if x is 0. -*/ -int get_count_order_ulong (unsigned long x); -const char *get_domain_str (enum lttng_domain_type domain); static inline
src/common/utils.c +89 -0
101 lines not on this page · raw message
src/common/utils.h +2 -0
@@ -45,6 +45,8 @@ int utils_rotate_stream_file(char *path_name, char *file_name, uint64_t size, int *stream_fd);int utils_parse_size_suffix (char const *const str,uint64_t *const size);int utils_get_count_order_u32 (uint32_t x); +int utils_get_count_order_u64 (uint64_t x); +int utils_get_count_order_ulong (unsigned long x);char *utils_get_home_dir (void );char *utils_get_user_home_dir (uid_t uid);char *utils_get_kmod_probes_list (void );
Signature · 1 line
1.9.1
PATCH 2/9 Explicitely stop the session on lttng destroy
In reply to a message not in the archiveThis is going to be useful for the upcoming feature that checks and eventually displays the amount of lost packets/discarded events.
If we don't do that, more events might be lost/discarded between the "lttng destroy" command and the time the trace is actually stopped.
--- src/bin/lttng/commands/destroy.c | 7 +++++++ 1 file changed, 7 insertions(+)
src/bin/lttng/commands/destroy.c +7 -0
@@ -78,6 +78,13 @@ static int destroy_session(struct lttng_session *session)int ret;char *session_name =NULL ; + ret =lttng_stop_tracing_no_wait (session->name); +if (ret <0 ) { +if (ret != -LTTNG_ERR_TRACE_ALREADY_STOPPED ) { +ERR ("%s" ,lttng_strerror (ret)); + } + } + ret =lttng_destroy_session (session->name);if (ret <0 ) {switch (-ret) {
Signature · 1 line
1.9.1
PATCH 3/9 Reference pointers from ust_app_chan to parent structs
In reply to a message not in the archiveTo extract the lost packets and discarded events counters in per-pid channels when an application unregisters, we need a reference to the parent channel and session. These pointers are only there as reference and do not provide any kind of ownership.
--- src/bin/lttng-sessiond/ust-app.c | 5 +++++ src/bin/lttng-sessiond/ust-app.h | 6 ++++++ 2 files changed, 11 insertions(+)
src/bin/lttng-sessiond/ust-app.c +5 -0
@@ -1702,6 +1702,11 @@ static void shadow_copy_session(struct ust_app_session *ua_sess,* channel and not metadata. */ ua_chan->attr.type =LTTNG_UST_CHAN_PER_CPU ; +/* +* Back pointers to the ust session and channel. +*/ + ua_chan->usess = usess; + ua_chan->uchan = uchan;lttng_ht_add_unique_str (ua_sess->channels, &ua_chan->node); }
src/bin/lttng-sessiond/ust-app.h +6 -0
@@ -168,6 +168,12 @@ struct ust_app_channel {struct lttng_ht_node_ulong ust_objd_node;/* For delayed reclaim */ struct rcu_head rcu_head; +/* +* Back pointers to the parent channel and session, no ownership, +* just references. +*/ +struct ltt_ust_channel *uchan; +struct ltt_ust_session *usess; };struct ust_app_session {
Signature · 1 line
1.9.1
PATCH 4/9 Metadata for instance_id and packet_seq_num
In reply to a message not in the archiveThe UST tracer now stores a stream_instance_id in each packet to allow the viewers to match streams split in multiple trace files.
Also, a sequence_number is stored in each packet so it is possible to compute the number of lost packets in overwrite mode.
This is a locked-step with the corresponding lttng-ust commits.
--- src/bin/lttng-sessiond/ust-app.c | 3 ++- src/bin/lttng-sessiond/ust-metadata.c | 51 ++++++++++++++++++++++++----------- src/bin/lttng-sessiond/ust-registry.h | 3 ++- 3 files changed, 39 insertions(+), 18 deletions(-)
src/bin/lttng-sessiond/ust-app.c +2 -1
@@ -4829,7 +4829,8 @@ static int reply_ust_register_channel(int sock, int sobjd, int cobjd,/* Append to metadata */ if (!chan_reg->metadata_dumped) { - ret_code =ust_metadata_channel_statedump (registry, chan_reg); + ret_code =ust_metadata_channel_statedump (registry, chan_reg, + &ua_chan->attr);if (ret_code) {ERR ("Error appending channel metadata (errno = %d)" , ret_code); goto reply;
src/bin/lttng-sessiond/ust-metadata.c +35 -16
102 lines not on this page · raw message
src/bin/lttng-sessiond/ust-registry.h +2 -1
@@ -256,7 +256,8 @@ void ust_registry_destroy_event(struct ust_registry_channel *chan,int ust_metadata_session_statedump (struct ust_registry_session *session,struct ust_app *app,uint32_t major,uint32_t minor);int ust_metadata_channel_statedump (struct ust_registry_session *session, -struct ust_registry_channel *chan); +struct ust_registry_channel *chan, +struct ustctl_consumer_channel_attr *attr);int ust_metadata_event_statedump (struct ust_registry_session *session,struct ust_registry_channel *chan,struct ust_registry_event *event);
Signature · 1 line
1.9.1
PATCH 5/9 Extract the lost packets and discarded events counters
In reply to a message not in the archivelttng list, now shows the number of discarded events (discard mode) or lost packets (overwrite mode).
--- include/lttng/channel.h | 5 +- src/bin/lttng-sessiond/buffer-registry.c | 39 +++++++ src/bin/lttng-sessiond/buffer-registry.h | 5 + src/bin/lttng-sessiond/cmd.c | 94 ++++++++++++++- src/bin/lttng-sessiond/consumer.c | 108 +++++++++++++++++ src/bin/lttng-sessiond/consumer.h | 4 + src/bin/lttng-sessiond/trace-ust.h | 2 + src/bin/lttng-sessiond/ust-app.c | 122 ++++++++++++++++++- src/bin/lttng-sessiond/ust-app.h | 25 ++++ src/bin/lttng/commands/list.c | 2 + src/common/config/config-session-abi.h | 2 + src/common/config/config.c | 2 + src/common/config/session.xsd | 2 + src/common/consumer.c | 1 + src/common/consumer.h | 13 +++ src/common/kernel-consumer/kernel-consumer.c | 114 ++++++++++++++++++ src/common/kernel-ctl/kernel-ctl.c | 6 + src/common/kernel-ctl/kernel-ctl.h | 1 + src/common/kernel-ctl/kernel-ioctl.h | 2 + src/common/mi-lttng.c | 16 +++ src/common/mi_lttng.xsd | 2 + src/common/sessiond-comm/sessiond-comm.h | 8 ++ src/common/ust-consumer/ust-consumer.c | 167 +++++++++++++++++++++++++++ src/common/ust-consumer/ust-consumer.h | 7 ++ 24 files changed, 743 insertions(+), 6 deletions(-)
include/lttng/channel.h +4 -1
@@ -30,7 +30,7 @@ extern "C" {* * The structures should be initialized to zero before use. */ -#define LTTNG_CHANNEL_ATTR_PADDING1 LTTNG_SYMBOL_NAME_LEN + 12 +#define LTTNG_CHANNEL_ATTR_PADDING1 LTTNG_SYMBOL_NAME_LEN - 4/* 252 */ struct lttng_channel_attr {int overwrite;/* 1: overwrite, 0: discard */ uint64_t subbuf_size;/* bytes */
@@ -43,6 +43,9 @@ struct lttng_channel_attr {uint64_t tracefile_count;/* number of tracefiles */ /* LTTng 2.3 padding limit */ unsigned int live_timer_interval;/* usec */ +/* LTTng 2.7 padding limit */ +uint64_t discarded_events;/* events */ +uint64_t lost_packets;/* packets */ char padding[LTTNG_CHANNEL_ATTR_PADDING1 ]; };
src/bin/lttng-sessiond/buffer-registry.c +39 -0
@@ -329,6 +329,45 @@ end: }/* +* Find the consumer channel key from a UST session per-uid channel key. +* +* Return the matching key or -1 if not found. +*/ +int buffer_reg_uid_consumer_channel_key ( +struct cds_list_head *buffer_reg_uid_list, +uint64_t usess_id,uint64_t chan_key, +uint64_t *consumer_chan_key) +{ +struct lttng_ht_iter iter; +struct buffer_reg_uid *uid_reg =NULL ; +struct buffer_reg_session *session_reg =NULL ; +struct buffer_reg_channel *reg_chan; +int ret; + +rcu_read_lock (); +/* +* For the per-uid registry, we have to iterate since we don't have the +* uid and bitness key. +*/ +cds_list_for_each_entry (uid_reg, buffer_reg_uid_list, lnode) { + session_reg = uid_reg->registry; +cds_lfht_for_each_entry (session_reg->channels->ht, + &iter.iter, reg_chan, node.node) { +if (reg_chan->key == chan_key) { + *consumer_chan_key = reg_chan->consumer_key; + ret =0 ; + goto end; + } + } + } + ret =-1 ; + +end: +rcu_read_unlock (); +return ret; +} + +/* * Allocate and initialize a buffer registry channel with the given key. Set * regp with the object pointer. *
src/bin/lttng-sessiond/buffer-registry.h +5 -0
@@ -150,4 +150,9 @@ void buffer_reg_stream_destroy(struct buffer_reg_stream *regp,/* Global registry. */ void buffer_reg_destroy_registries (void ); +int buffer_reg_uid_consumer_channel_key ( +struct cds_list_head *buffer_reg_uid_list, +uint64_t usess_id,uint64_t chan_key, +uint64_t *consumer_chan_key); +#endif /* LTTNG_BUFFER_REGISTRY_H */
src/bin/lttng-sessiond/cmd.c +93 -1
123 lines not on this page · raw message
src/bin/lttng-sessiond/consumer.c +108 -0
111 lines not on this page · raw message
src/bin/lttng-sessiond/consumer.h +4 -0
@@ -277,6 +277,10 @@ int consumer_push_metadata(struct consumer_socket *socket, uint64_t metadata_key, char *metadata_str, size_t len, size_t target_offset);int consumer_flush_channel (struct consumer_socket *socket,uint64_t key); +int consumer_get_discarded_events (uint64_t session_id,uint64_t channel_key, +struct consumer_output *consumer,uint64_t *discarded); +int consumer_get_lost_packets (uint64_t session_id,uint64_t channel_key, +struct consumer_output *consumer,uint64_t *lost);/* Snapshot command. */ int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key,
src/bin/lttng-sessiond/trace-ust.h +2 -0
@@ -66,6 +66,8 @@ struct ltt_ust_channel {struct lttng_ht_node_str node;uint64_t tracefile_size;uint64_t tracefile_count; +uint64_t per_pid_closed_app_discarded; +uint64_t per_pid_closed_app_lost; };/* UST domain global (LTTNG_DOMAIN_UST) */
src/bin/lttng-sessiond/ust-app.c +118 -4
167 lines not on this page · raw message
src/bin/lttng-sessiond/ust-app.h +25 -0
@@ -341,6 +341,14 @@ int ust_app_snapshot_record(struct ltt_ust_session *usess,uint64_t ust_app_get_size_one_more_packet_per_stream (struct ltt_ust_session *usess,uint64_t cur_nr_packets);struct ust_app *ust_app_find_by_sock (int sock); +int ust_app_uid_channel_runtime_stats (uint64_t ust_session_id, +struct cds_list_head *buffer_reg_uid_list, +struct consumer_output *consumer,uint64_t uchan_id, +int overwrite,uint64_t *discarded,uint64_t *lost); +int ust_app_pid_channel_runtime_stats (struct ltt_ust_session *usess, +struct ltt_ust_channel *uchan, +struct consumer_output *consumer, +int overwrite,uint64_t *discarded,uint64_t *lost);static inline int ust_app_supported (void )
@@ -555,6 +563,23 @@ uint64_t ust_app_get_size_one_more_packet_per_stream( struct ltt_ust_session *usess, uint64_t cur_nr_packets) {return 0 ; } +static inline +int ust_app_uid_channel_runtime_stats (uint64_t ust_session_id, +struct cds_list_head *buffer_reg_uid_list, +struct consumer_output *consumer,int overwrite, +uint64_t uchan_id,uint64_t *discarded) +{ +return 0 ; +} + +static inline +int ust_app_pid_channel_runtime_stats (struct ltt_ust_session *usess, +struct ltt_ust_channel *uchan, +struct consumer_output *consumer, +int overwrite,uint64_t *discarded,uint64_t *lost) +{ +return 0 ; +}#endif /* HAVE_LIBLTTNG_UST_CTL */
src/bin/lttng/commands/list.c +2 -0
@@ -1082,6 +1082,8 @@ static void print_channel(struct lttng_channel *channel)MSG ("%sread timer interval: %u" , indent6, channel->attr.read_timer_interval);MSG ("%strace file count: %" PRIu64, indent6, channel->attr.tracefile_count);MSG ("%strace file size (bytes): %" PRIu64, indent6, channel->attr.tracefile_size); +MSG ("%sdiscarded events: %" PRIu64, indent6, channel->attr.discarded_events); +MSG ("%slost packets: %" PRIu64, indent6, channel->attr.lost_packets);switch (channel->attr.output) {case LTTNG_EVENT_SPLICE :MSG ("%soutput: splice()" , indent6);
src/common/config/config-session-abi.h +2 -0
@@ -46,6 +46,8 @@ extern const char * const config_element_output_type;extern const char *const config_element_tracefile_size;extern const char *const config_element_tracefile_count;extern const char *const config_element_live_timer_interval; +extern const char *const config_element_discarded_events; +extern const char *const config_element_lost_packets;extern const char *const config_element_type;extern const char *const config_element_buffer_type;extern const char *const config_element_session;
src/common/config/config.c +2 -0
@@ -96,6 +96,8 @@ const char * const config_element_output_type = "output_type";const char *const config_element_tracefile_size ="tracefile_size" ;const char *const config_element_tracefile_count ="tracefile_count" ;const char *const config_element_live_timer_interval ="live_timer_interval" ; +const char *const config_element_discarded_events ="discarded_events" ; +const char *const config_element_lost_packets ="lost_packets" ;const char *const config_element_type ="type" ;const char *const config_element_buffer_type ="buffer_type" ;const char *const config_element_session ="session" ;
src/common/config/session.xsd +2 -0
@@ -181,6 +181,8 @@ elementFormDefault="qualified" version="2.5"> <xs:element name="tracefile_size" type="uint64_type" default="0" minOccurs="0"/> <!-- bytes --> <xs:element name="tracefile_count" type="uint64_type" default="0" minOccurs="0"/> <xs:element name="live_timer_interval" type="uint32_type" default="0" minOccurs="0"/> <!-- usec --> + <xs:element name="discarded_events" type="uint64_type" default="0" minOccurs="0"/> + <xs:element name="lost_packets" type="uint64_type" default="0" minOccurs="0"/> <xs:element name="events" type="event_list_type" minOccurs="0"/> <xs:element name="contexts" type="event_context_list_type" minOccurs="0"/> </xs:all>
src/common/consumer.c +1 -0
@@ -562,6 +562,7 @@ struct lttng_consumer_stream *consumer_allocate_stream(uint64_t channel_key, stream->monitor = monitor; stream->endpoint_status =CONSUMER_ENDPOINT_ACTIVE ; stream->index_fd =-1 ; + stream->last_sequence_number =-1ULL ;pthread_mutex_init (&stream->lock,NULL );/* If channel is the metadata, flag this stream as metadata. */
src/common/consumer.h +13 -0
@@ -58,6 +58,8 @@ enum lttng_consumer_command {LTTNG_CONSUMER_SNAPSHOT_CHANNEL ,LTTNG_CONSUMER_SNAPSHOT_METADATA ,LTTNG_CONSUMER_STREAMS_SENT , +LTTNG_CONSUMER_DISCARDED_EVENTS , + LTTNG_CONSUMER_LOST_PACKETS, };/* State of each fd in consumer */
@@ -211,6 +213,10 @@ struct lttng_consumer_channel {int nr_stream_fds;char root_shm_path[PATH_MAX ];char shm_path[PATH_MAX ]; +/* Total number of discarded events for that channel. */ +uint64_t discarded_events; +/* Total number of missed packets due to overwriting (overwrite). */ +uint64_t lost_packets; };/*
@@ -337,6 +343,13 @@ struct lttng_consumer_stream {*/ uint64_t ust_metadata_pushed;/* +* Copy of the last discarded event value to detect the overflow of +* the counter. +*/ +unsigned long last_discarded_events; +/* Copy of the sequence number of the last packet extracted. */ +uint64_t last_sequence_number; +/* * FD of the index file for this stream. */ int index_fd;
src/common/kernel-consumer/kernel-consumer.c +114 -0
132 lines not on this page · raw message
src/common/kernel-ctl/kernel-ctl.c +6 -0
@@ -533,3 +533,9 @@ int kernctl_get_current_timestamp(int fd, uint64_t *ts) {return ioctl (fd,LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP , ts); } + +/* Returns the packet sequence number of the current sub-buffer. */ +int kernctl_get_sequence_number (int fd,uint64_t *seq) +{ +return ioctl (fd,LTTNG_RING_BUFFER_GET_SEQ_NUM , seq); +}
src/common/kernel-ctl/kernel-ctl.h +1 -0
@@ -99,5 +99,6 @@ int kernctl_get_content_size(int fd, uint64_t *content_size);int kernctl_get_packet_size (int fd,uint64_t *packet_size);int kernctl_get_stream_id (int fd,uint64_t *stream_id);int kernctl_get_current_timestamp (int fd,uint64_t *ts); +int kernctl_get_sequence_number (int fd,uint64_t *seq);#endif /* _LTTNG_KERNEL_CTL_H */
src/common/kernel-ctl/kernel-ioctl.h +2 -0
@@ -64,6 +64,8 @@#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) +/* returns the packet sequence number */ +#define LTTNG_RING_BUFFER_GET_SEQ_NUM _IOR(0xF6, 0x27, uint64_t)/* Old ABI (without support for 32/64 bits compat) */ /* LTTng file descriptor ioctl */
src/common/mi-lttng.c +16 -0
@@ -903,6 +903,22 @@ int mi_lttng_channel_attr(struct mi_writer *writer, goto end; } +/* Discarded events */ + ret =mi_lttng_writer_write_element_unsigned_int (writer, + config_element_discarded_events, + attr->discarded_events); +if (ret) { + goto end; + } + +/* Lost packets */ + ret =mi_lttng_writer_write_element_unsigned_int (writer, + config_element_lost_packets, + attr->lost_packets); +if (ret) { + goto end; + } +/* Closing attributes */ ret =mi_lttng_writer_close_element (writer);if (ret) {
src/common/mi_lttng.xsd +2 -0
@@ -313,6 +313,8 @@ THE SOFTWARE. <xs:element name="tracefile_size" type="uint64_type" default="0" minOccurs="0" /> <!-- bytes --> <xs:element name="tracefile_count" type="uint64_type" default="0" minOccurs="0" /> <xs:element name="live_timer_interval" type="uint32_type" default="0" minOccurs="0" /> <!-- usec --> + <xs:element name="discarded_events" type="uint64_type" default="0" minOccurs="0" /> + <xs:element name="lost_packets" type="uint64_type" default="0" minOccurs="0" /> </xs:all> </xs:complexType>
src/common/sessiond-comm/sessiond-comm.h +8 -0
@@ -470,6 +470,14 @@ struct lttcomm_consumer_msg {uint64_t channel_key;uint64_t net_seq_idx; }LTTNG_PACKED sent_streams; +struct { +uint64_t session_id; +uint64_t channel_key; + } LTTNG_PACKED discarded_events; +struct { +uint64_t session_id; +uint64_t channel_key; + } LTTNG_PACKED lost_packets; } u; }LTTNG_PACKED ;
src/common/ust-consumer/ust-consumer.c +167 -0
191 lines not on this page · raw message
src/common/ust-consumer/ust-consumer.h +7 -0
@@ -67,6 +67,8 @@ void lttng_ustconsumer_flush_buffer(struct lttng_consumer_stream *stream, int producer);int lttng_ustconsumer_get_current_timestamp (struct lttng_consumer_stream *stream,uint64_t *ts); +int lttng_ustconsumer_get_sequence_number ( +struct lttng_consumer_stream *stream,uint64_t *seq);#else /* HAVE_LIBLTTNG_UST_CTL */
@@ -206,6 +208,11 @@ int lttng_ustconsumer_get_current_timestamp( {return -ENOSYS ; } +int lttng_ustconsumer_get_sequence_number ( +struct lttng_consumer_stream *stream,uint64_t *seq) +{ +return -ENOSYS ; +}static inline int lttng_ustconsumer_get_stream_id (struct lttng_consumer_stream *stream,uint64_t *stream_id)
Signature · 1 line
1.9.1
PATCH 6/9 Display discarded and lost events at destroy and stop
In reply to a message not in the archive--- src/bin/lttng/commands/destroy.c | 1 + src/bin/lttng/commands/stop.c | 1 + src/bin/lttng/utils.c | 46 ++++++++++++++++++++++++++++++++++++++++ src/bin/lttng/utils.h | 1 + 4 files changed, 49 insertions(+)
src/bin/lttng/commands/destroy.c +1 -0
@@ -84,6 +84,7 @@ static int destroy_session(struct lttng_session *session)ERR ("%s" ,lttng_strerror (ret)); } } +get_session_stats (session->name); ret =lttng_destroy_session (session->name);if (ret <0 ) {
src/bin/lttng/commands/stop.c +1 -0
@@ -156,6 +156,7 @@ static int stop_tracing(void) ret =CMD_SUCCESS ; +get_session_stats (session_name);MSG ("Tracing stopped for session %s" , session_name);if (lttng_opt_mi) { ret =mi_print_session (session_name,0 );
src/bin/lttng/utils.c +46 -0
55 lines not on this page · raw message
src/bin/lttng/utils.h +1 -0
@@ -42,5 +42,6 @@ void print_missing_domain(void)int spawn_relayd (const char *pathname,int port);int check_relayd (void ); +void get_session_stats (const char *session_name);#endif /* _LTTNG_UTILS_H */
Signature · 1 line
1.9.1
PATCH 7/9 Account the lost packets in snapshot mode
In reply to a message not in the archiveWhen working in flight-recorder, we cannot rely on the absolute sequence number because we only extract the content of the ring buffer periodically. Moreover, we don't want to account the lost packets at the beginning or the end of the snapshot since the "holes" don't appear in the resulting snapshot, so we make sure we only account lost packets locate between extracted packets.
--- src/common/kernel-consumer/kernel-consumer.c | 23 ++++++++++++++++++++++- src/common/ust-consumer/ust-consumer.c | 23 ++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-)
src/common/kernel-consumer/kernel-consumer.c +22 -1
@@ -118,7 +118,7 @@ int lttng_kconsumer_snapshot_channel(uint64_t key, char *path, uint64_t relayd_id, uint64_t nb_packets_per_stream, struct lttng_consumer_local_data *ctx) { - int ret; + int ret, first, lost;unsigned long consumed_pos, produced_pos;struct lttng_consumer_channel *channel;struct lttng_consumer_stream *stream;
@@ -225,6 +225,8 @@ int lttng_kconsumer_snapshot_channel(uint64_t key, char *path, produced_pos, nb_packets_per_stream, stream->max_sb_size); + first =1 ; + lost =0 ;while (consumed_pos < produced_pos) {ssize_t read_len;unsigned long len, padded_len;
@@ -242,6 +244,15 @@ int lttng_kconsumer_snapshot_channel(uint64_t key, char *path, }DBG ("Kernel consumer get subbuf failed. Skipping it." ); consumed_pos += stream->max_sb_size; + +/* +* Start accounting lost packets only when we +* already have extracted packets (to match the +* content of the final snapshot). +*/ +if (!first) { + lost++; + }continue ; }
@@ -285,6 +296,16 @@ int lttng_kconsumer_snapshot_channel(uint64_t key, char *path, goto end_unlock; } consumed_pos += stream->max_sb_size; + +/* +* Only account lost packets located between +* succesfully extracted packets (do not account before +* and after since they are not visible in the +* resulting snapshot). +*/ + stream->chan->lost_packets += lost; + lost =0 ; + first =0 ; }if (relayd_id == (uint64_t )-1ULL ) {
src/common/ust-consumer/ust-consumer.c +22 -1
@@ -1001,7 +1001,7 @@ error:static int snapshot_channel (uint64_t key,char *path,uint64_t relayd_id,uint64_t nb_packets_per_stream,struct lttng_consumer_local_data *ctx) { -int ret; +int ret, first, lost;unsigned use_relayd =0 ;unsigned long consumed_pos, produced_pos;struct lttng_consumer_channel *channel;
@@ -1089,6 +1089,8 @@ static int snapshot_channel(uint64_t key, char *path, uint64_t relayd_id, produced_pos, nb_packets_per_stream, stream->max_sb_size); + first =1 ; + lost =0 ;while (consumed_pos < produced_pos) {ssize_t read_len;unsigned long len, padded_len;
@@ -1105,6 +1107,15 @@ static int snapshot_channel(uint64_t key, char *path, uint64_t relayd_id, }DBG ("UST consumer get subbuf failed. Skipping it." ); consumed_pos += stream->max_sb_size; + +/* +* Start accounting lost packets only when we +* already have extracted packets (to match the +* content of the final snapshot). +*/ +if (!first) { + lost++; + }continue ; }
@@ -1140,6 +1151,16 @@ static int snapshot_channel(uint64_t key, char *path, uint64_t relayd_id, goto error_close_stream; } consumed_pos += stream->max_sb_size; + +/* +* Only account lost packets located between +* succesfully extracted packets (do not account before +* and after since they are not visible in the +* resulting snapshot). +*/ + stream->chan->lost_packets += lost; + lost =0 ; + first =0 ; }/* Simply close the stream so we can use it on the next snapshot. */
Signature · 1 line
1.9.1
PATCH 8/9 kernctl commands to extract the stream instance id
In reply to a message not in the archive--- src/common/kernel-ctl/kernel-ctl.c | 6 ++++++ src/common/kernel-ctl/kernel-ctl.h | 1 + src/common/kernel-ctl/kernel-ioctl.h | 2 ++ 3 files changed, 9 insertions(+)
src/common/kernel-ctl/kernel-ctl.c +6 -0
@@ -539,3 +539,9 @@ int kernctl_get_sequence_number(int fd, uint64_t *seq) {return ioctl (fd,LTTNG_RING_BUFFER_GET_SEQ_NUM , seq); } + +/* Returns the stream instance id. */ +int kernctl_get_instance_id (int fd,uint64_t *id) +{ +return ioctl (fd,LTTNG_RING_BUFFER_INSTANCE_ID , id); +}
src/common/kernel-ctl/kernel-ctl.h +1 -0
@@ -100,5 +100,6 @@ int kernctl_get_packet_size(int fd, uint64_t *packet_size);int kernctl_get_stream_id (int fd,uint64_t *stream_id);int kernctl_get_current_timestamp (int fd,uint64_t *ts);int kernctl_get_sequence_number (int fd,uint64_t *seq); +int kernctl_get_instance_id (int fd,uint64_t *seq);#endif /* _LTTNG_KERNEL_CTL_H */
src/common/kernel-ctl/kernel-ioctl.h +2 -0
@@ -66,6 +66,8 @@#define LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP _IOR(0xF6, 0x26, uint64_t)/* returns the packet sequence number */ #define LTTNG_RING_BUFFER_GET_SEQ_NUM _IOR(0xF6, 0x27, uint64_t) +/* returns the stream instance id */ +#define LTTNG_RING_BUFFER_INSTANCE_ID _IOR(0xF6, 0x28, uint64_t)/* Old ABI (without support for 32/64 bits compat) */ /* LTTng file descriptor ioctl */
Signature · 1 line
1.9.1
PATCH 9/9 Store the instance id and packet_seq_num in indexes
In reply to a message not in the archive--- src/bin/lttng-relayd/main.c | 12 +++++++++--- src/common/index/ctf-index.h | 7 +++++-- src/common/kernel-consumer/kernel-consumer.c | 14 ++++++++++++++ src/common/relayd/relayd.c | 5 +++++ src/common/sessiond-comm/relayd.h | 2 ++ src/common/ust-consumer/ust-consumer.c | 14 ++++++++++++++ 6 files changed, 49 insertions(+), 5 deletions(-)
src/bin/lttng-relayd/main.c +9 -3
@@ -1127,7 +1127,8 @@ static void destroy_session(struct relay_session *session,* Copy index data from the control port to a given index object. */ static void copy_index_control_data (struct relay_index *index, -struct lttcomm_relayd_index *data) +struct lttcomm_relayd_index *data, +struct relay_connection *conn) {assert (index);assert (data);
@@ -1143,6 +1144,11 @@ static void copy_index_control_data(struct relay_index *index, index->index_data.timestamp_end = data->timestamp_end; index->index_data.events_discarded = data->events_discarded; index->index_data.stream_id = data->stream_id; + +if (conn->minor >=7 ) { + index->index_data.stream_instance_id = data->stream_instance_id; + index->index_data.packet_seq_num = data->packet_seq_num; + } }/*
@@ -2041,7 +2047,7 @@ int relay_recv_index(struct lttcomm_relayd_hdr *recv_hdr, stream->indexes_in_flight++; } -copy_index_control_data (index, &index_info); +copy_index_control_data (index, &index_info, conn);if (stream->ctf_stream_id ==-1ULL ) { stream->ctf_stream_id =be64toh (index_info.stream_id); }
@@ -2054,7 +2060,7 @@ int relay_recv_index(struct lttcomm_relayd_hdr *recv_hdr,*/ relay_index_add (index, &wr_index);if (wr_index) { -copy_index_control_data (wr_index, &index_info); +copy_index_control_data (wr_index, &index_info, conn);free (index); } }else {
src/common/index/ctf-index.h +5 -2
@@ -29,7 +29,7 @@#define CTF_INDEX_MAGIC 0xC1F1DCC1#define CTF_INDEX_MAJOR 1 -#define CTF_INDEX_MINOR 0 +#define CTF_INDEX_MINOR 1/* * Header at the beginning of each index file.
@@ -54,7 +54,10 @@ struct ctf_packet_index {uint64_t timestamp_begin;uint64_t timestamp_end;uint64_t events_discarded; -uint64_t stream_id; +uint64_t stream_id;/* ID of the channel */ +/* CTF_INDEX 1.0 limit */ +uint64_t stream_instance_id;/* ID of the channel instance */ +uint64_t packet_seq_num;/* packet sequence number */ } __attribute__((__packed__));#endif /* LTTNG_INDEX_H */
src/common/kernel-consumer/kernel-consumer.c +14 -0
@@ -1093,6 +1093,20 @@ static int get_index_values(struct ctf_packet_index *index, int infd) } index->stream_id =htobe64 (index->stream_id); + ret =kernctl_get_instance_id (infd, &index->stream_instance_id); +if (ret <0 ) { +PERROR ("kernctl_get_instance_id" ); + goto error; + } + index->stream_instance_id =htobe64 (index->stream_instance_id); + + ret =kernctl_get_sequence_number (infd, &index->packet_seq_num); +if (ret <0 ) { +PERROR ("kernctl_get_sequence_number" ); + goto error; + } + index->packet_seq_num =htobe64 (index->packet_seq_num); + error:return ret; }
src/common/relayd/relayd.c +5 -0
@@ -828,6 +828,11 @@ int relayd_send_index(struct lttcomm_relayd_sock *rsock, msg.events_discarded = index->events_discarded; msg.stream_id = index->stream_id; +if (rsock->minor >=7 ) { + msg.stream_instance_id = index->stream_instance_id; + msg.packet_seq_num = index->packet_seq_num; + } +/* Send command */ ret =send_command (rsock,RELAYD_SEND_INDEX , &msg,sizeof (msg),0 );if (ret <0 ) {
src/common/sessiond-comm/relayd.h +2 -0
@@ -162,6 +162,8 @@ struct lttcomm_relayd_index {uint64_t timestamp_end;uint64_t events_discarded;uint64_t stream_id; +uint64_t stream_instance_id; +uint64_t packet_seq_num; }LTTNG_PACKED ;/*
src/common/ust-consumer/ust-consumer.c +14 -0
@@ -2053,6 +2053,20 @@ static int get_index_values(struct ctf_packet_index *index, } index->stream_id =htobe64 (index->stream_id); + ret =ustctl_get_instance_id (ustream, &index->stream_instance_id); +if (ret <0 ) { +PERROR ("ustctl_get_instance_id" ); + goto error; + } + index->stream_instance_id =htobe64 (index->stream_instance_id); + + ret =ustctl_get_sequence_number (ustream, &index->packet_seq_num); +if (ret <0 ) { +PERROR ("ustctl_get_sequence_number" ); + goto error; + } + index->packet_seq_num =htobe64 (index->packet_seq_num); + error:return ret; }
Signature · 1 line
1.9.1