Introduce "--blocking-timeout" channel parameter
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 599 lines · Mathieu Desnoyers
Introduce the blocking timeout channel parameter to control blocking behavior for lttng-ust buffers. It only affects applications launched with the
LTTNG_UST_ALLOW_BLOCKINGenvironment variable.The blocking timeout parameter expects:
- 0 (default) which does not block,
- a timeout value in usec,
- -1 (block forever).Signed-off-by Mathieu Desnoyers <[email protected]>--- 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 | 52 +++++++++++++++++++++++++++++ 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 | 13 ++++++++ src/common/defaults.h | 4 +++ src/common/mi-lttng-3.0.xsd | 14 ++++++++ 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, 244 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 16src/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 +52
-0@@ -48,6 +48,10 @@ static struct {bool set;uint32_t interval; } opt_monitor_timer; +static struct { +bool set; +int64_t value; +} opt_blocking_timeout;static struct mi_writer *writer;@@ -70,6 +74,7 @@ enum {OPT_LIST_OPTIONS ,OPT_TRACEFILE_SIZE ,OPT_TRACEFILE_COUNT , + OPT_BLOCKING_TIMEOUT, };static struct lttng_handle *handle;@@ -97,6 +102,7 @@ static struct poptOption long_options[] = { {"buffers-global", 0, POPT_ARG_VAL, &opt_buffer_global, 1, 0, 0}, {"tracefile-size", 'C', POPT_ARG_INT, 0, OPT_TRACEFILE_SIZE, 0, 0}, {"tracefile-count", 'W', POPT_ARG_INT, 0, OPT_TRACEFILE_COUNT, 0, 0}, + {"blocking-timeout", 0, POPT_ARG_INT, 0, OPT_BLOCKING_TIMEOUT, 0, 0}, {0, 0, 0, 0, 0, 0, 0} };@@ -151,6 +157,15 @@ static int enable_channel(char *session_name)memset (&dom,0 ,sizeof (dom)); +/* Validate options. */ +if (opt_kernel) { +if (opt_blocking_timeout.set) { +ERR ("Retry timeout option not supported for kernel domain (-k)" ); + ret =CMD_ERROR ; + goto error; + } + } +/* Create lttng domain */ if (opt_kernel) { dom.type =LTTNG_DOMAIN_KERNEL ;@@ -262,6 +277,15 @@ static int enable_channel(char *session_name) goto error; } } +if (opt_blocking_timeout.set) { + ret =lttng_channel_set_blocking_timeout (channel, + opt_blocking_timeout.value); +if (ret) { +ERR ("Failed to set the channel's blocking timeout" ); + error =1 ; + goto error; + } + }DBG ("Enabling channel %s" , channel_name);@@ -530,6 +554,34 @@ int cmd_enable_channels(int argc, const char **argv)DBG ("Channel monitor timer interval set to %d" , opt_monitor_timer.interval);break ; } +case OPT_BLOCKING_TIMEOUT : + { +long long v;/* in usec */ +long long v_msec; + + errno =0 ; + opt_arg =poptGetOptArg (pc); + v =strtoll (opt_arg,NULL ,0 ); +if (errno !=0 || (!isdigit (opt_arg[0 ]) && opt_arg[0 ] !='-' ) + || v <-1 ) { +ERR ("Wrong value in --blocking_timeout parameter: %s" , opt_arg); + ret =CMD_ERROR ; + goto end; + } +if (v >=0 ) { + v_msec = v /1000 ; +if (v_msec != (int32_t ) v_msec) { +ERR ("32-bit milliseconds overflow in --blocking_timeout parameter: %s" , opt_arg); + ret =CMD_ERROR ; + goto end; + } + } + opt_blocking_timeout.value = (int64_t ) v; + opt_blocking_timeout.set = true; +DBG ("Channel blocking timeout set to %" PRId64" (µs)" , + opt_blocking_timeout.value); +break ; + }case OPT_USERSPACE : opt_userspace =1 ;break ;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 +13
-0@@ -43,6 +43,18 @@ elementFormDefault="qualified" version="2.8"> </xs:restriction> </xs:simpleType> +<!-- +Maps to the range allowed for blocking timeout: -1 (block forever), +0 (do not block), positive integer value (blocking time in usec) limited +by its signed 32-bit representation when converted to msec. +--> +<xs:simpleType name="blocking_timeout_type"> + <xs:restriction base="xs:integer"> + <xs:minInclusive value="-1" /> + <xs:maxInclusive value="2147483648000" /> + </xs:restriction> +</xs:simpleType> + <xs:simpleType name="channel_overwrite_mode_type"> <xs:restriction base="xs:string"> <xs:enumeration value="DISCARD"/>@@ -186,6 +198,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 +14
-0@@ -43,6 +43,19 @@ THE SOFTWARE. </xs:restriction> </xs:simpleType> + <!-- + Maps to the range allowed for blocking timeout: -1 (block + forever), 0 (do not block), positive integer value (blocking + time in usec) limited by its signed 32-bit representation when + converted to msec. + --> + <xs:simpleType name="blocking_timeout_type"> + <xs:restriction base="xs:integer"> + <xs:minInclusive value="-1" /> + <xs:maxInclusive value="2147483648000" /> + </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 +376,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 +7
-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) {
src/common/mi-lttng.c int mi_lttng_channel_attr(struct mi_writer *writer, · line 946
Quoted 4 lines
src/common/mi-lttng.c +1
-0@@ -936,6 +943,14 @@ int mi_lttng_channel_attr(struct mi_writer *writer, goto end; } +/* Retry timeout in usec */
The unit conversion is confusing in this patch.
The user-provided (CLI) argument is in usec and is then converted to msec by the client, before being used as msec with liblttng-ctl functions. Then, it is retrieved and output as-is (in msec) here and in the human-readable listing.
I'll move the unit conversion to a single place (before we hand-off the delay to lttng-ust) since the current convention is to store and expose all timers in usec.
I'll also open an issue to add this property as part of the "save/load" functionality before the realease.
Jérémie
Quoted 245 lines
src/common/mi-lttng.c +7
-0+ 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@@ -2073,6 +2073,8 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain,if (extended) { extended->monitor_timer_interval =DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER ; + extended->blocking_timeout = +DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT ; }break ;case LTTNG_DOMAIN_UST :@@ -2088,6 +2090,8 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain,if (extended) { extended->monitor_timer_interval =DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER ; + extended->blocking_timeout = +DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT ; }break ;case LTTNG_BUFFER_PER_PID :@@ -2102,6 +2106,8 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain,if (extended) { extended->monitor_timer_interval =DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER ; + extended->blocking_timeout = +DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT ; }break ; }@@ -2203,6 +2209,44 @@ end:return ret; } +int lttng_channel_get_blocking_timeout (struct lttng_channel *chan, +int64_t *blocking_timeout) +{ +int ret =0 ; + +if (!chan || !blocking_timeout) { + ret = -LTTNG_ERR_INVALID ; + goto end; + } + +if (!chan->attr.extended.ptr) { + ret = -LTTNG_ERR_INVALID ; + goto end; + } + + *blocking_timeout = ((struct lttng_channel_extended *) + chan->attr.extended.ptr)->blocking_timeout; +end: +return ret; +} + +int lttng_channel_set_blocking_timeout (struct lttng_channel *chan, +int64_t blocking_timeout) +{ +int ret =0 ; + +if (!chan || !chan->attr.extended.ptr) { + ret = -LTTNG_ERR_INVALID ; + goto end; + } + + ((struct lttng_channel_extended *) + chan->attr.extended.ptr)->blocking_timeout = + blocking_timeout; +end: +return ret; +} +/* * Check if session daemon is alive. * tests/regression/ust/blocking/test_blocking +28
-22@@ -20,13 +20,14 @@ TEST_DESC="UST - Blocking mode" CURDIR=$(dirname $0)/ TESTDIR=$CURDIR/../../.. SESSION_NAME="blocking" +CHANNEL_NAME="testchan" TESTAPP_PATH="$TESTDIR/utils/testapp" TESTAPP_NAME="gen-ust-events" TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" EVENT_NAME="tp:tptest" -NUM_TESTS=45 +NUM_TESTS=49 source $TESTDIR/utils/utils.sh@@ -40,11 +41,11 @@ function run_app() function test_ust_implicit_no_blocking() { - NUM_EVENT=500000 + NUM_EVENT=5000000 diag "UST implicit non-blocking mode (default): will hang if fails" - # Test without the plugin start_lttng_sessiond + # session in no-output mode create_lttng_session_no_output $SESSION_NAME enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" start_lttng_tracing_ok $SESSION_NAME@@ -56,17 +57,18 @@ function test_ust_implicit_no_blocking() ok 0 "Does not hang" } -function test_ust_explicit_no_blocking() +function test_ust_implicit_no_blocking_with_channel_blocking() { - NUM_EVENT=500000 - diag "UST explicit non-blocking mode: will hang if fails" + NUM_EVENT=5000000 + diag "UST implicit non-blocking mode (default) with blocking-timeout=-1 channel: will hang if fails" - # Test without the plugin start_lttng_sessiond + # session in no-output mode create_lttng_session_no_output $SESSION_NAME - enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" + enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=-1" + enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME start_lttng_tracing_ok $SESSION_NAME - LTTNG_UST_BLOCKING_RETRY_TIMEOUT=0 run_app + run_app stop_lttng_tracing_ok $SESSION_NAME destroy_lttng_session_ok $SESSION_NAME stop_lttng_sessiond@@ -77,14 +79,16 @@ function test_ust_explicit_no_blocking() function test_ust_timeout_no_blocking() { NUM_EVENT=12500 - diag "UST 1ms timeout retry mode: will hang if fails" + diag "UST 1ms timeout blocking mode: will hang if fails" start_lttng_sessiond + # session in no-output mode create_lttng_session_no_output $SESSION_NAME - enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" + # blocking timeout 1ms + enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=1000" + enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME start_lttng_tracing_ok $SESSION_NAME - # retry timeout 1ms - LTTNG_UST_BLOCKING_RETRY_TIMEOUT=1 run_app + LTTNG_UST_ALLOW_BLOCKING=1 run_app stop_lttng_tracing_ok $SESSION_NAME destroy_lttng_session_ok $SESSION_NAME stop_lttng_sessiond@@ -94,15 +98,17 @@ function test_ust_timeout_no_blocking() function test_ust_snapshot_no_blocking() { - NUM_EVENT=500000 + NUM_EVENT=5000000 diag "UST blocking mode: don't block in snapshot mode" # Test without the plugin start_lttng_sessiond create_lttng_session_ok $SESSION_NAME $TRACE_PATH --snapshot - enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" + # blocking timeout 1ms + enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=1000" + enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME start_lttng_tracing_ok $SESSION_NAME - LTTNG_UST_BLOCKING_RETRY_TIMEOUT=-1 run_app + LTTNG_UST_ALLOW_BLOCKING=1 run_app stop_lttng_tracing_ok $SESSION_NAME destroy_lttng_session_ok $SESSION_NAME stop_lttng_sessiond@@ -112,16 +118,17 @@ function test_ust_snapshot_no_blocking() function test_ust_blocking_no_discard() { - NUM_EVENT=500000 + NUM_EVENT=5000000 diag "UST blocking mode: no event discarded" # Test without the plugin start_lttng_sessiond create_lttng_session_ok $SESSION_NAME $TRACE_PATH - enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" + # infinite blocking timeout + enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=-1" + enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME start_lttng_tracing_ok $SESSION_NAME - # infinite retry timeout - LTTNG_UST_BLOCKING_RETRY_TIMEOUT=-1 run_app + LTTNG_UST_ALLOW_BLOCKING=1 run_app stop_lttng_tracing_ok $SESSION_NAME destroy_lttng_session_ok $SESSION_NAME stop_lttng_sessiond@@ -138,7 +145,7 @@ print_test_banner "$TEST_DESC" TESTS=( "test_ust_implicit_no_blocking" - "test_ust_explicit_no_blocking" + "test_ust_implicit_no_blocking_with_channel_blocking" "test_ust_timeout_no_blocking" "test_ust_snapshot_no_blocking" "test_ust_blocking_no_discard" --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): CA+jJMxs4K7XVqqdUk4CpB8=SDFh7pBAGTtNjHm6z2j0st3uxmg@mail.gmail.com
Quoted 5 lines · ----- On Jun 12, 2017, at 5:28 PM, Jeremie Galarneau…
Quoted 2 lines
+ /* Retry timeout in usec */
The unit conversion is confusing in this patch.
Quoted 9 lines
The user-provided (CLI) argument is in usec and is then converted to msec by the client, before being used as msec with liblttng-ctl functions. Then, it is retrieved and output as-is (in msec) here and in the human-readable listing.
I'll move the unit conversion to a single place (before we hand-off the delay to lttng-ust) since the current convention is to store and expose all timers in usec.
As discussed, the CLI only does an overflow check, not a conversion. Let's simply add this overflow check in the lib too, so we can return "invalid parameter" to the caller.
Quoted 2 lines
I'll also open an issue to add this property as part of the "save/load" functionality before the realease.
OK,
Thanks!
Mathieu
Signature · 7 lines
Mathieu Desnoyers 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 and stable-2.10 with the supplementary checks.
Thanks!
Jérémie
Quoted 37 lines · Mathieu Desnoyers
Quoted 5 lines · ----- On Jun 12, 2017, at 5:28 PM, Jeremie Galarneau…
Quoted 2 lines
+ /* Retry timeout in usec */
The unit conversion is confusing in this patch.
Quoted 9 lines
The user-provided (CLI) argument is in usec and is then converted to msec by the client, before being used as msec with liblttng-ctl functions. Then, it is retrieved and output as-is (in msec) here and in the human-readable listing.
I'll move the unit conversion to a single place (before we hand-off the delay to lttng-ust) since the current convention is to store and expose all timers in usec.
As discussed, the CLI only does an overflow check, not a conversion. Let's simply add this overflow check in the lib too, so we can return "invalid parameter" to the caller.
Quoted 2 lines
I'll also open an issue to add this property as part of the "save/load" functionality before the realease.
OK,
Thanks!
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
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