Fix: lttng list of channels should return errors
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/3 Fix: lttng list of channels should return errors
--- src/bin/lttng-sessiond/cmd.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
src/bin/lttng-sessiond/cmd.c +14 -6
@@ -243,11 +243,11 @@ end:/* * Fill lttng_channel array of all channels. */ -static void list_lttng_channels (enum lttng_domain_type domain, +static ssize_t list_lttng_channels (enum lttng_domain_type domain,struct ltt_session *session,struct lttng_channel *channels,struct lttng_channel_extended *chan_exts) { -int i =0 , ret; +int i =0 , ret =0 ;struct ltt_kernel_channel *kchan;DBG ("Listing channels for session %s" , session->name);
@@ -322,6 +322,9 @@ static void list_lttng_channels(enum lttng_domain_type domain,break ; } + chan_exts[i].monitor_timer_interval = + uchan->monitor_timer_interval; + ret =get_ust_runtime_stats (session, uchan, &discarded_events, &lost_packets);if (ret <0 ) {
@@ -329,8 +332,6 @@ static void list_lttng_channels(enum lttng_domain_type domain, } chan_exts[i].discarded_events = discarded_events; chan_exts[i].lost_packets = lost_packets; - chan_exts[i].monitor_timer_interval = - uchan->monitor_timer_interval; i++; }rcu_read_unlock ();
@@ -341,7 +342,11 @@ static void list_lttng_channels(enum lttng_domain_type domain, } end: -return ; +if (ret <0 ) { +return -LTTNG_ERR_FATAL ; + }else { +return LTTNG_OK ; + } } static void increment_extended_len(const char *filter_expression,
@@ -2936,7 +2941,10 @@ ssize_t cmd_list_channels(enum lttng_domain_type domain, channel_exts = ((void *) *channels) + (nb_chan *sizeof (struct lttng_channel )); -list_lttng_channels (domain, session, *channels, channel_exts); + ret =list_lttng_channels (domain, session, *channels, channel_exts); +if (ret !=LTTNG_OK ) { + goto end; + } }else { *channels =NULL ; }
Signature · 6 lines
2.1.4 _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
PATCH 3/3 Introduce "--blocking-timeout" channel parameter
In reply to a message not in the archiveIntroduce the blocking timeout channel parameter to control blocking behavior for lttng-ust buffers. It only affects applications launched with the LTTNG_UST_ALLOW_BLOCKING environment variable.
The blocking timeout parameter expects:
- 0 (default) which does not block,
- a timeout value in usec,
- -1 (block forever).
--- configure.ac | 4 +++ doc/man/lttng-enable-channel.1.txt | 14 +++++++- include/lttng/channel-internal.h | 1 + include/lttng/channel.h | 6 ++++ src/bin/lttng-sessiond/channel.c | 17 ++++++++++ src/bin/lttng-sessiond/cmd.c | 3 ++ src/bin/lttng-sessiond/consumer.c | 2 ++ src/bin/lttng-sessiond/consumer.h | 1 + src/bin/lttng-sessiond/lttng-ust-abi.h | 7 +++- src/bin/lttng-sessiond/lttng-ust-ctl.h | 1 + src/bin/lttng-sessiond/trace-ust.c | 2 ++ src/bin/lttng-sessiond/ust-app.c | 4 +++ src/bin/lttng-sessiond/ust-consumer.c | 1 + src/bin/lttng/commands/enable_channels.c | 51 +++++++++++++++++++++++++++++ src/bin/lttng/commands/list.c | 9 +++++ src/common/config/config-session-abi.h | 1 + src/common/config/session-config.c | 1 + src/common/config/session.xsd | 9 +++++ src/common/defaults.h | 4 +++ src/common/mi-lttng-3.0.xsd | 9 +++++ src/common/mi-lttng.c | 15 +++++++++ src/common/sessiond-comm/sessiond-comm.h | 1 + src/common/ust-consumer/ust-consumer.c | 1 + src/lib/lttng-ctl/lttng-ctl.c | 44 +++++++++++++++++++++++++ tests/regression/ust/blocking/test_blocking | 49 +++++++++++++++------------ 25 files changed, 234 insertions(+), 23 deletions(-)
configure.ac +4 -0
@@ -246,6 +246,7 @@ m4_define([_DEFAULT_CHANNEL_SWITCH_TIMER], [0]) m4_define([_DEFAULT_CHANNEL_LIVE_TIMER], [0]) m4_define([_DEFAULT_CHANNEL_READ_TIMER], [200000]) m4_define([_DEFAULT_CHANNEL_MONITOR_TIMER], [1000000]) +m4_define([_DEFAULT_CHANNEL_BLOCKING_TIMEOUT], [0]) _AC_DEFINE_AND_SUBST([DEFAULT_AGENT_TCP_PORT], [5345]) _AC_DEFINE_AND_SUBST([DEFAULT_APP_SOCKET_RW_TIMEOUT], [5]) _AC_DEFINE_AND_SUBST([DEFAULT_CHANNEL_SUBBUF_SIZE], [_DEFAULT_CHANNEL_SUBBUF_SIZE])
@@ -257,6 +258,7 @@ _AC_DEFINE_AND_SUBST([DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM], [_DEFAULT_CHANNEL_SUBB _AC_DEFINE_AND_SUBST([DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE], [1048576]) _AC_DEFINE_AND_SUBST([DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER], [_DEFAULT_CHANNEL_SWITCH_TIMER]) _AC_DEFINE_AND_SUBST([DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER], [_DEFAULT_CHANNEL_MONITOR_TIMER]) +_AC_DEFINE_AND_SUBST([DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT], [_DEFAULT_CHANNEL_BLOCKING_TIMEOUT]) _AC_DEFINE_AND_SUBST([DEFAULT_LTTNG_LIVE_TIMER], [1000000]) _AC_DEFINE_AND_SUBST([DEFAULT_METADATA_CACHE_SIZE], [4096]) _AC_DEFINE_AND_SUBST([DEFAULT_METADATA_READ_TIMER], [0])
@@ -268,12 +270,14 @@ _AC_DEFINE_AND_SUBST([DEFAULT_NETWORK_DATA_PORT], [5343]) _AC_DEFINE_AND_SUBST([DEFAULT_NETWORK_VIEWER_PORT], [5344]) _AC_DEFINE_AND_SUBST([DEFAULT_UST_PID_CHANNEL_LIVE_TIMER], [_DEFAULT_CHANNEL_LIVE_TIMER]) _AC_DEFINE_AND_SUBST([DEFAULT_UST_PID_CHANNEL_READ_TIMER], [0]) +_AC_DEFINE_AND_SUBST([DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT], [0]) _AC_DEFINE_AND_SUBST([DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM], [_DEFAULT_CHANNEL_SUBBUF_NUM]) _AC_DEFINE_AND_SUBST([DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE], [_DEFAULT_CHANNEL_SUBBUF_SIZE]) _AC_DEFINE_AND_SUBST([DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER], [_DEFAULT_CHANNEL_SWITCH_TIMER]) _AC_DEFINE_AND_SUBST([DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER], [_DEFAULT_CHANNEL_MONITOR_TIMER]) _AC_DEFINE_AND_SUBST([DEFAULT_UST_UID_CHANNEL_LIVE_TIMER], [_DEFAULT_CHANNEL_LIVE_TIMER]) _AC_DEFINE_AND_SUBST([DEFAULT_UST_UID_CHANNEL_READ_TIMER], [0]) +_AC_DEFINE_AND_SUBST([DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT], [0]) _AC_DEFINE_AND_SUBST([DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM], [_DEFAULT_CHANNEL_SUBBUF_NUM]) _AC_DEFINE_AND_SUBST([DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE], [524288]) _AC_DEFINE_AND_SUBST([DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER], [_DEFAULT_CHANNEL_SWITCH_TIMER])
doc/man/lttng-enable-channel.1.txt +13 -1
@@ -26,6 +26,7 @@ Create a user space channel: [option:--overwrite] [option:--buffers-pid] [option:--subbuf-size='SIZE'] [option:--num-subbuf='COUNT'] [option:--switch-timer='PERIODUS'] [option:--read-timer='PERIODUS'] + [option:--blocking-timeout='TIMEOUTUS'] [option:--tracefile-size='SIZE'] [option:--tracefile-count='COUNT'] [option:--session='SESSION'] 'CHANNEL'
@@ -358,6 +359,16 @@ Default values: * option:--kernel option: {default_kernel_channel_switch_timer} * `metadata` channel: {default_metadata_switch_timer} +Timeouts +~~~~~~~~ +option:--blocking-timeout: + Set the channel's blocking timeout value to 'TIMEOUTUS' µs. 0 + (default) does not block. -1 blocks forever until room is + available in the buffer to write the event. Positive + values are a timeout bounding the maximum blocking time + when trying to write into the buffer. Note that this option + only affects applications launched with the + LTTNG_UST_ALLOW_BLOCKING environment variable set. include::common-cmd-help-options.txt[]
@@ -385,4 +396,5 @@ include::common-cmd-footer.txt[] SEE ALSO -------- man:lttng-disable-channel(1), -man:lttng(1) +man:lttng(1), +man:lttng-ust(3)
include/lttng/channel-internal.h +1 -0
@@ -22,6 +22,7 @@ struct lttng_channel_extended {uint64_t discarded_events;uint64_t lost_packets;uint64_t monitor_timer_interval; + int64_t blocking_timeout; }LTTNG_PACKED ;#endif /* LTTNG_CHANNEL_INTERNAL_H */
include/lttng/channel.h +6 -0
@@ -138,6 +138,12 @@ extern int lttng_channel_get_monitor_timer_interval(struct lttng_channel *chan,extern int lttng_channel_set_monitor_timer_interval (struct lttng_channel *chan,uint64_t monitor_timer_interval); +extern int lttng_channel_get_blocking_timeout (struct lttng_channel *chan, +int64_t *blocking_timeout); + +extern int lttng_channel_set_blocking_timeout (struct lttng_channel *chan, +int64_t blocking_timeout); + #ifdef __cplusplus }#endif
src/bin/lttng-sessiond/channel.c +17 -0
@@ -72,6 +72,7 @@ struct lttng_channel *channel_new_default_attr(int dom, chan->attr.switch_timer_interval =DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER ; chan->attr.read_timer_interval =DEFAULT_KERNEL_CHANNEL_READ_TIMER ; chan->attr.live_timer_interval =DEFAULT_KERNEL_CHANNEL_LIVE_TIMER ; + extended_attr->blocking_timeout =DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT ; extended_attr->monitor_timer_interval =DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER ;break ;
@@ -97,6 +98,7 @@ common_ust:DEFAULT_UST_UID_CHANNEL_READ_TIMER ; chan->attr.live_timer_interval =DEFAULT_UST_UID_CHANNEL_LIVE_TIMER ; + extended_attr->blocking_timeout =DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT ; extended_attr->monitor_timer_interval =DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER ;break ;
@@ -111,6 +113,7 @@ common_ust:DEFAULT_UST_PID_CHANNEL_READ_TIMER ; chan->attr.live_timer_interval =DEFAULT_UST_PID_CHANNEL_LIVE_TIMER ; + extended_attr->blocking_timeout =DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT ; extended_attr->monitor_timer_interval =DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER ;break ;
@@ -217,6 +220,15 @@ static int channel_validate(struct lttng_channel *attr)return 0 ; } +static int channel_validate_kernel (struct lttng_channel *attr) +{ +/* Kernel channels do not support blocking timeout. */ +if (((struct lttng_channel_extended *)attr->attr.extended.ptr)->blocking_timeout) { +return -1 ; + } +return 0 ; +} +/* * Create kernel channel of the kernel session and notify kernel thread. */
@@ -258,6 +270,11 @@ int channel_kernel_create(struct ltt_kernel_session *ksession, goto error; } +if (channel_validate_kernel (attr) <0 ) { + ret =LTTNG_ERR_INVALID ; + goto error; + } +/* Channel not found, creating it */ ret =kernel_create_channel (ksession, attr);if (ret <0 ) {
src/bin/lttng-sessiond/cmd.c +3 -0
@@ -277,6 +277,7 @@ static ssize_t list_lttng_channels(enum lttng_domain_type domain, chan_exts[i].lost_packets = lost_packets; chan_exts[i].monitor_timer_interval = extended->monitor_timer_interval; + chan_exts[i].blocking_timeout =0 ; i++; } }
@@ -324,6 +325,8 @@ static ssize_t list_lttng_channels(enum lttng_domain_type domain, chan_exts[i].monitor_timer_interval = uchan->monitor_timer_interval; + chan_exts[i].blocking_timeout = + uchan->attr.u.s.blocking_timeout; ret =get_ust_runtime_stats (session, uchan, &discarded_events, &lost_packets);
src/bin/lttng-sessiond/consumer.c +2 -0
@@ -822,6 +822,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg,uint64_t session_id_per_pid, unsigned int monitor, uint32_t ust_app_uid, + int64_t blocking_timeout, const char *root_shm_path, const char *shm_path) {
@@ -851,6 +852,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, msg->u.ask_channel.tracefile_count = tracefile_count; msg->u.ask_channel.monitor = monitor; msg->u.ask_channel.ust_app_uid = ust_app_uid; + msg->u.ask_channel.blocking_timeout = blocking_timeout;memcpy (msg->u.ask_channel.uuid, uuid,sizeof (msg->u.ask_channel.uuid));
src/bin/lttng-sessiond/consumer.h +1 -0
@@ -256,6 +256,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg,uint64_t session_id_per_pid, unsigned int monitor, uint32_t ust_app_uid, + int64_t blocking_timeout, const char *root_shm_path, const char *shm_path); void consumer_init_stream_comm_msg(struct lttcomm_consumer_msg *msg,
src/bin/lttng-sessiond/lttng-ust-abi.h +6 -1
@@ -181,7 +181,12 @@ struct lttng_ust_channel_attr {unsigned int switch_timer_interval;/* usec */ unsigned int read_timer_interval;/* usec */ enum lttng_ust_output output;/* splice, mmap */ -char padding[LTTNG_UST_CHANNEL_ATTR_PADDING ]; +union { +struct { +int64_t blocking_timeout;/* Retry timeout (usec) */ + } s; +char padding[LTTNG_UST_CHANNEL_ATTR_PADDING ]; + } u; }LTTNG_PACKED ;#define LTTNG_UST_TRACEPOINT_ITER_PADDING 16
src/bin/lttng-sessiond/lttng-ust-ctl.h +1 -0
@@ -53,6 +53,7 @@ struct ustctl_consumer_channel_attr {enum lttng_ust_output output;/* splice, mmap */ uint32_t chan_id;/* channel ID */ unsigned char uuid[LTTNG_UST_UUID_LEN ];/* Trace session unique ID */ +int64_t blocking_timeout;/* Retry timeout (usec) */ }LTTNG_PACKED ;/*
src/bin/lttng-sessiond/trace-ust.c +2 -0
@@ -358,6 +358,8 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, luc->attr.output = (enum lttng_ust_output ) chan->attr.output; luc->monitor_timer_interval = ((struct lttng_channel_extended *) chan->attr.extended.ptr)->monitor_timer_interval; + luc->attr.u.s.blocking_timeout = ((struct lttng_channel_extended *) + chan->attr.extended.ptr)->blocking_timeout;/* Translate to UST output enum */ switch (luc->attr.output) {
src/bin/lttng-sessiond/ust-app.c +4 -0
@@ -92,6 +92,7 @@ static void copy_channel_attr_to_ustctl( attr->switch_timer_interval = uattr->switch_timer_interval; attr->read_timer_interval = uattr->read_timer_interval; attr->output = uattr->output; + attr->blocking_timeout = uattr->u.s.blocking_timeout; }/*
@@ -1035,6 +1036,7 @@ struct ust_app_channel *alloc_ust_app_channel(char *name, ua_chan->attr.switch_timer_interval = attr->switch_timer_interval; ua_chan->attr.read_timer_interval = attr->read_timer_interval; ua_chan->attr.output = attr->output; + ua_chan->attr.blocking_timeout = attr->u.s.blocking_timeout; }/* By default, the channel is a per cpu channel. */ ua_chan->attr.type =LTTNG_UST_CHAN_PER_CPU ;
@@ -1798,6 +1800,8 @@ static void shadow_copy_channel(struct ust_app_channel *ua_chan, ua_chan->attr.read_timer_interval = uchan->attr.read_timer_interval; ua_chan->monitor_timer_interval = uchan->monitor_timer_interval; ua_chan->attr.output = uchan->attr.output; + ua_chan->attr.blocking_timeout = uchan->attr.u.s.blocking_timeout; +/* * Note that the attribute channel type is not set since the channel on the * tracing registry side does not have this information.
src/bin/lttng-sessiond/ust-consumer.c +1 -0
@@ -192,6 +192,7 @@ static int ask_channel_creation(struct ust_app_session *ua_sess, ua_sess->id, ua_sess->output_traces, ua_sess->uid, + ua_chan->attr.blocking_timeout, root_shm_path, shm_path);health_code_update ();
src/bin/lttng/commands/enable_channels.c +51 -0
87 lines not on this page · raw message
src/bin/lttng/commands/list.c +9 -0
@@ -1173,6 +1173,7 @@ static void print_channel(struct lttng_channel *channel) {int ret;uint64_t discarded_events, lost_packets, monitor_timer_interval; +int64_t blocking_timeout; ret =lttng_channel_get_discarded_event_count (channel, &discarded_events);
@@ -1195,6 +1196,13 @@ static void print_channel(struct lttng_channel *channel)return ; } + ret =lttng_channel_get_blocking_timeout (channel, + &blocking_timeout); +if (ret) { +ERR ("Failed to retrieve blocking timeout of channel" ); +return ; + } +MSG ("- %s:%s\n" , channel->name,enabled_string (channel->enabled));MSG ("%sAttributes:" , indent4);
@@ -1204,6 +1212,7 @@ static void print_channel(struct lttng_channel *channel)MSG ("%sswitch timer interval: %u" , indent6, channel->attr.switch_timer_interval);MSG ("%sread timer interval: %u" , indent6, channel->attr.read_timer_interval);MSG ("%smonitor timer interval: %" PRIu64, indent6, monitor_timer_interval); +MSG ("%sblocking timeout (µs): %" PRId64, indent6, blocking_timeout);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, discarded_events);
src/common/config/config-session-abi.h +1 -0
@@ -42,6 +42,7 @@ extern const char * const config_element_num_subbuf;extern const char *const config_element_switch_timer_interval;extern const char *const config_element_read_timer_interval;extern const char *const config_element_monitor_timer_interval; +extern const char *const config_element_blocking_timeout;extern const char *const config_element_output;extern const char *const config_element_output_type;extern const char *const config_element_tracefile_size;
src/common/config/session-config.c +1 -0
@@ -92,6 +92,7 @@ const char * const config_element_num_subbuf = "subbuffer_count";const char *const config_element_switch_timer_interval ="switch_timer_interval" ;const char *const config_element_read_timer_interval ="read_timer_interval" ;const char *const config_element_monitor_timer_interval ="monitor_timer_interval" ; +const char *const config_element_blocking_timeout ="blocking_timeout" ;const char *const config_element_output ="output" ;const char *const config_element_output_type ="output_type" ;const char *const config_element_tracefile_size ="tracefile_size" ;
src/common/config/session.xsd +9 -0
@@ -43,6 +43,14 @@ elementFormDefault="qualified" version="2.8"> </xs:restriction> </xs:simpleType> +<!-- Maps to the range allowed for blocking timeout --> +<xs:simpleType name="blocking_timeout_type"> + <xs:restriction base="xs:integer"> + <xs:minInclusive value="-1" /> + <xs:maxInclusive value="4294967296000" /> + </xs:restriction> +</xs:simpleType> + <xs:simpleType name="channel_overwrite_mode_type"> <xs:restriction base="xs:string"> <xs:enumeration value="DISCARD"/>
@@ -186,6 +194,7 @@ elementFormDefault="qualified" version="2.8"> <xs:element name="subbuffer_count" type="uint64_type" default="4" minOccurs="0"/> <xs:element name="switch_timer_interval" type="uint32_type" default="0" minOccurs="0"/> <!-- usec --> <xs:element name="read_timer_interval" type="uint32_type"/> <!-- usec --> + <xs:element name="blocking_timeout" type="blocking_timeout_type" default="0" minOccurs="0" /> <!-- usec --> <xs:element name="output_type" type="event_output_type"/> <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"/>
src/common/defaults.h +4 -0
@@ -221,6 +221,7 @@#define DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER CONFIG_DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER#define DEFAULT_KERNEL_CHANNEL_READ_TIMER CONFIG_DEFAULT_KERNEL_CHANNEL_READ_TIMER#define DEFAULT_KERNEL_CHANNEL_LIVE_TIMER CONFIG_DEFAULT_KERNEL_CHANNEL_LIVE_TIMER +#define DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT CONFIG_DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT/* User space defaults */
@@ -244,6 +245,9 @@#define DEFAULT_UST_PID_CHANNEL_READ_TIMER CONFIG_DEFAULT_UST_PID_CHANNEL_READ_TIMER#define DEFAULT_UST_UID_CHANNEL_READ_TIMER CONFIG_DEFAULT_UST_UID_CHANNEL_READ_TIMER +#define DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT CONFIG_DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT +#define DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT CONFIG_DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT +/* * Default timeout value for the sem_timedwait() call. Blocking forever is not * wanted so a timeout is used to control the data flow and not freeze the
src/common/mi-lttng-3.0.xsd +9 -0
@@ -43,6 +43,14 @@ THE SOFTWARE. </xs:restriction> </xs:simpleType> + <!-- Maps to the range allowed for blocking timeout --> + <xs:simpleType name="blocking_timeout_type"> + <xs:restriction base="xs:integer"> + <xs:minInclusive value="-1" /> + <xs:maxInclusive value="4294967296000" /> + </xs:restriction> + </xs:simpleType> + <!-- Maps to the char name[LTTNG_SYMBOL_NAME_LEN] --> <xs:simpleType name="name_type"> <xs:restriction base="xs:string">
@@ -363,6 +371,7 @@ THE SOFTWARE. <xs:element name="discarded_events" type="tns:uint64_type" default="0" minOccurs="0" /> <xs:element name="lost_packets" type="tns:uint64_type" default="0" minOccurs="0" /> <xs:element name="monitor_timer_interval" type="tns:uint64_type" default="0" minOccurs="0" /> + <xs:element name="blocking_timeout" type="tns:blocking_timeout_type" default="0" minOccurs="0" /> </xs:all> </xs:complexType>
src/common/mi-lttng.c +15 -0
@@ -863,6 +863,7 @@ int mi_lttng_channel_attr(struct mi_writer *writer,struct lttng_channel *chan =caa_container_of (attr, struct lttng_channel, attr);uint64_t discarded_events, lost_packets, monitor_timer_interval; +int64_t blocking_timeout;assert (attr);
@@ -882,6 +883,12 @@ int mi_lttng_channel_attr(struct mi_writer *writer, goto end; } + ret =lttng_channel_get_blocking_timeout (chan, + &blocking_timeout); +if (ret) { + goto end; + } +/* Opening Attributes */ ret =mi_lttng_writer_open_element (writer, config_element_attributes);if (ret) {
@@ -936,6 +943,14 @@ int mi_lttng_channel_attr(struct mi_writer *writer, goto end; } +/* Retry timeout in usec */ + ret =mi_lttng_writer_write_element_signed_int (writer, + config_element_blocking_timeout, + blocking_timeout); +if (ret) { + goto end; + } +/* Event output */ ret = mi_lttng_writer_write_element_string(writer, config_element_output_type,
src/common/sessiond-comm/sessiond-comm.h +1 -0
@@ -482,6 +482,7 @@ struct lttcomm_consumer_msg {* because the application can be in the tracing for instance. */ uint32_t ust_app_uid; +int64_t blocking_timeout;char root_shm_path[PATH_MAX ];char shm_path[PATH_MAX ]; }LTTNG_PACKED ask_channel;
src/common/ust-consumer/ust-consumer.c +1 -0
@@ -1456,6 +1456,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, attr.read_timer_interval = msg.u.ask_channel.read_timer_interval; attr.chan_id = msg.u.ask_channel.chan_id;memcpy (attr.uuid, msg.u.ask_channel.uuid,sizeof (attr.uuid)); + attr.blocking_timeout= msg.u.ask_channel.blocking_timeout;/* Match channel buffer type to the UST abi. */ switch (msg.u.ask_channel.output) {
src/lib/lttng-ctl/lttng-ctl.c +44 -0
68 lines not on this page · raw message
tests/regression/ust/blocking/test_blocking +28 -21
121 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH lttng-tools 3/3 master, 2.10-rc] Introduce "--blocking-timeout" channel parameter
Hi,
Comments bellow, only kept relevant part of the patch.
Quoted 13 lines · Mathieu Desnoyers
src/bin/lttng-sessiond/channel.c +1
-0@@ -72,6 +72,7 @@ struct lttng_channel *channel_new_default_attr(int dom, chan->attr.switch_timer_interval =DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER ; chan->attr.read_timer_interval =DEFAULT_KERNEL_CHANNEL_READ_TIMER ; chan->attr.live_timer_interval =DEFAULT_KERNEL_CHANNEL_LIVE_TIMER ; + extended_attr->blocking_timeout =DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT ; extended_attr->monitor_timer_interval =DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER ;break ;
src/bin/lttng-sessiond/channel.c common_ust: · line 101
Quoted 4 lines
src/bin/lttng-sessiond/channel.c +1
-0@@ -97,6 +98,7 @@ common_ust:DEFAULT_UST_UID_CHANNEL_READ_TIMER ; chan->attr.live_timer_interval =DEFAULT_UST_UID_CHANNEL_LIVE_TIMER ; + extended_attr->blocking_timeout =DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT ;
Put on two lines.
src/bin/lttng-sessiond/channel.c common_ust: · line 115
Quoted 7 lines
src/bin/lttng-sessiond/channel.c +0
-0extended_attr->monitor_timer_interval =DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER ;break ;@@ -111,6 +113,7 @@ common_ust:DEFAULT_UST_PID_CHANNEL_READ_TIMER ; chan->attr.live_timer_interval =DEFAULT_UST_PID_CHANNEL_LIVE_TIMER ;
Same here.
Quoted 13 lines
src/bin/lttng-sessiond/channel.c +1
-0+ extended_attr->blocking_timeout =DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT ; extended_attr->monitor_timer_interval =DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER ;break ;@@ -217,6 +220,15 @@ static int channel_validate(struct lttng_channel *attr)return 0 ; }src/bin/lttng-sessiond/lttng-ust-abi.h +0
-0
src/bin/lttng-sessiond/lttng-ust-abi.h struct lttng_ust_channel_attr { · line 187
Quoted 8 lines
src/bin/lttng-sessiond/lttng-ust-abi.h +4
-1@@ -181,7 +181,12 @@ struct lttng_ust_channel_attr {unsigned int switch_timer_interval;/* usec */ unsigned int read_timer_interval;/* usec */ enum lttng_ust_output output;/* splice, mmap */ -char padding[LTTNG_UST_CHANNEL_ATTR_PADDING ]; +union { +struct { +int64_t blocking_timeout;/* Retry timeout (usec) */ + } s;
Should "s" be a more meaningful identifier here?
Quoted 10 lines
src/bin/lttng-sessiond/lttng-ust-abi.h +2
-0+char padding[LTTNG_UST_CHANNEL_ATTR_PADDING ]; + } u; }LTTNG_PACKED ;#define LTTNG_UST_TRACEPOINT_ITER_PADDING 16src/bin/lttng-sessiond/lttng-ust-ctl.h +0
-0
src/bin/lttng-sessiond/lttng-ust-ctl.h struct ustctl_consumer_channel_attr { · line 56
Quoted 4 lines
src/bin/lttng-sessiond/lttng-ust-ctl.h +1
-0@@ -53,6 +53,7 @@ struct ustctl_consumer_channel_attr {enum lttng_ust_output output;/* splice, mmap */ uint32_t chan_id;/* channel ID */ unsigned char uuid[LTTNG_UST_UUID_LEN ];/* Trace session unique ID */ +int64_t blocking_timeout;/* Retry timeout (usec) */
Only one/two tab here for style consistency or fix the previous lines.
Quoted 8 lines
src/bin/lttng-sessiond/lttng-ust-ctl.h +0
-0}LTTNG_PACKED ;/* src/common/config/session.xsd +0
-0
src/common/config/session.xsd elementFormDefault="qualified" version="2.8"> · line 49
Quoted 7 lines
src/common/config/session.xsd +4
-0@@ -43,6 +43,14 @@ elementFormDefault="qualified" version="2.8"> </xs:restriction> </xs:simpleType> +<!-- Maps to the range allowed for blocking timeout --> +<xs:simpleType name="blocking_timeout_type"> + <xs:restriction base="xs:integer"> + <xs:minInclusive value="-1" />
Please add a comment here regarding the restriction on 4294967296000. Which is due to the (int32) milliseconds overflow check.
Quoted 42 lines
src/common/config/session.xsd +5
-0+ <xs:maxInclusive value="4294967296000" /> + </xs:restriction> +</xs:simpleType> + <xs:simpleType name="channel_overwrite_mode_type"> <xs:restriction base="xs:string"> <xs:enumeration value="DISCARD"/>@@ -186,6 +194,7 @@ elementFormDefault="qualified" version="2.8"> <xs:element name="subbuffer_count" type="uint64_type" default="4" minOccurs="0"/> <xs:element name="switch_timer_interval" type="uint32_type" default="0" minOccurs="0"/> <!-- usec --> <xs:element name="read_timer_interval" type="uint32_type"/> <!-- usec --> + <xs:element name="blocking_timeout" type="blocking_timeout_type" default="0" minOccurs="0" /> <!-- usec --> <xs:element name="output_type" type="event_output_type"/> <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"/>src/common/defaults.h +4
-0@@ -221,6 +221,7 @@#define DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER CONFIG_DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER#define DEFAULT_KERNEL_CHANNEL_READ_TIMER CONFIG_DEFAULT_KERNEL_CHANNEL_READ_TIMER#define DEFAULT_KERNEL_CHANNEL_LIVE_TIMER CONFIG_DEFAULT_KERNEL_CHANNEL_LIVE_TIMER +#define DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT CONFIG_DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT/* User space defaults */ @@ -244,6 +245,9 @@#define DEFAULT_UST_PID_CHANNEL_READ_TIMER CONFIG_DEFAULT_UST_PID_CHANNEL_READ_TIMER#define DEFAULT_UST_UID_CHANNEL_READ_TIMER CONFIG_DEFAULT_UST_UID_CHANNEL_READ_TIMER +#define DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT CONFIG_DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT +#define DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT CONFIG_DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT +/* * Default timeout value for the sem_timedwait() call. Blocking forever is not * wanted so a timeout is used to control the data flow and not freeze the src/common/mi-lttng-3.0.xsd +0
-0
src/common/mi-lttng-3.0.xsd THE SOFTWARE. · line 49
Quoted 7 lines
src/common/mi-lttng-3.0.xsd +4
-0@@ -43,6 +43,14 @@ THE SOFTWARE. </xs:restriction> </xs:simpleType> + <!-- Maps to the range allowed for blocking timeout --> + <xs:simpleType name="blocking_timeout_type"> + <xs:restriction base="xs:integer"> + <xs:minInclusive value="-1" />
Same comment regarding the max value restriction found in session.xsd .
Quoted 15 lines
src/common/mi-lttng-3.0.xsd +5
-0+ <xs:maxInclusive value="4294967296000" /> + </xs:restriction> + </xs:simpleType> + <!-- Maps to the char name[LTTNG_SYMBOL_NAME_LEN] --> <xs:simpleType name="name_type"> <xs:restriction base="xs:string">@@ -363,6 +371,7 @@ THE SOFTWARE. <xs:element name="discarded_events" type="tns:uint64_type" default="0" minOccurs="0" /> <xs:element name="lost_packets" type="tns:uint64_type" default="0" minOccurs="0" /> <xs:element name="monitor_timer_interval" type="tns:uint64_type" default="0" minOccurs="0" /> + <xs:element name="blocking_timeout" type="tns:blocking_timeout_type" default="0" minOccurs="0" /> </xs:all> </xs:complexType>
Signature · 6 lines
Jonathan Rajotte-Julien EfficiOS _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Re: [PATCH lttng-tools 1/3 master, 2.10-rc] Fix: discard event/lost packet counters
In reply to a message not in the archiveMerged in master, stable-2.10, stable-2.9, and stable-2.8.
Thanks!
Jérémie
Quoted 95 lines · Mathieu Desnoyers
For per-pid buffers, we need to sum the counters for each application.
For per-uid buffers, if no application has launched yet, it should not be considered as an error (which stops iteration on all other channels), but rather as values of 0.
Signed-off-by Mathieu Desnoyers <[email protected]>--- src/bin/lttng-sessiond/ust-app.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-)src/bin/lttng-sessiond/ust-app.c +24
-12@@ -6083,21 +6083,24 @@ int ust_app_uid_get_channel_runtime_stats(uint64_t ust_session_id,int ret;uint64_t consumer_chan_key; + *discarded =0 ; + *lost =0 ; + ret =buffer_reg_uid_consumer_channel_key ( buffer_reg_uid_list, ust_session_id, uchan_id, &consumer_chan_key);if (ret <0 ) { +/* Not found */ + ret =0 ; goto end; }if (overwrite) { ret =consumer_get_lost_packets (ust_session_id, consumer_chan_key, consumer, lost); - *discarded =0 ; }else { ret =consumer_get_discarded_events (ust_session_id, consumer_chan_key, consumer, discarded); - *lost =0 ; } end:@@ -6116,10 +6119,13 @@ int ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess,struct ust_app_session *ua_sess;struct ust_app_channel *ua_chan; + *discarded =0 ; + *lost =0 ; +rcu_read_lock ();/* -* Iterate over every registered applications, return when we -* found one in the right session and channel. +* Iterate over every registered applications. Sum counters for +* all applications containing requested session and channel. */ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {struct lttng_ht_iter uiter;@@ -6138,19 +6144,26 @@ int ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess, ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);if (overwrite) { +uint64_t _lost; + ret =consumer_get_lost_packets (usess->id, ua_chan->key, - consumer, lost); - *discarded =0 ; - goto end; + consumer, &_lost); +if (ret <0 ) { +break ; + } + (*lost) += _lost; }else { +uint64_t _discarded; + ret =consumer_get_discarded_events (usess->id, - ua_chan->key, consumer, discarded); - *lost =0 ; - goto end; + ua_chan->key, consumer, &_discarded); +if (ret <0 ) { +break ; + } + (*discarded) += _discarded; } } -end:rcu_read_unlock ();return ret; } --2.1.4
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Merged in master, stable-2.10, stable-2.9, and stable-2.8 with a leak fix, read on.
Thanks!
Jérémie
Quoted 56 lines · Mathieu Desnoyers
Signed-off-by Mathieu Desnoyers <[email protected]>--- src/bin/lttng-sessiond/cmd.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)src/bin/lttng-sessiond/cmd.c +10
-5@@ -243,11 +243,11 @@ end:/* * Fill lttng_channel array of all channels. */ -static void list_lttng_channels (enum lttng_domain_type domain, +static ssize_t list_lttng_channels (enum lttng_domain_type domain,struct ltt_session *session,struct lttng_channel *channels,struct lttng_channel_extended *chan_exts) { -int i =0 , ret; +int i =0 , ret =0 ;struct ltt_kernel_channel *kchan;DBG ("Listing channels for session %s" , session->name);@@ -322,6 +322,9 @@ static void list_lttng_channels(enum lttng_domain_type domain,break ; } + chan_exts[i].monitor_timer_interval = + uchan->monitor_timer_interval; + ret =get_ust_runtime_stats (session, uchan, &discarded_events, &lost_packets);if (ret <0 ) {@@ -329,8 +332,6 @@ static void list_lttng_channels(enum lttng_domain_type domain, } chan_exts[i].discarded_events = discarded_events; chan_exts[i].lost_packets = lost_packets; - chan_exts[i].monitor_timer_interval = - uchan->monitor_timer_interval; i++; }rcu_read_unlock ();@@ -341,7 +342,11 @@ static void list_lttng_channels(enum lttng_domain_type domain, } end: -return ; +if (ret <0 ) { +return -LTTNG_ERR_FATAL ; + }else { +return LTTNG_OK ; + } } static void increment_extended_len(const char *filter_expression,
src/bin/lttng-sessiond/cmd.c ssize_t cmd_list_channels(enum lttng_domain_type domain, · line 2945
Quoted 6 lines
src/bin/lttng-sessiond/cmd.c +2
-1@@ -2936,7 +2941,10 @@ ssize_t cmd_list_channels(enum lttng_domain_type domain, channel_exts = ((void *) *channels) + (nb_chan *sizeof (struct lttng_channel )); -list_lttng_channels (domain, session, *channels, channel_exts); + ret =list_lttng_channels (domain, session, *channels, channel_exts); +if (ret !=LTTNG_OK ) {
The caller of cmd_list_channels(), process_client_msg(), does not expect *channels to have been modified on error. Therefore, it is not free'd in the error path.
I modified the patch so that the "channels" output parameter of cmd_list_channels() is only affected on success. The function thus handles the clean-up itself in case of failure.
Quoted 8 lines
src/bin/lttng-sessiond/cmd.c +2
-1+ goto end; + } }else { *channels =NULL ; } --2.1.4
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev