# This is the library version of liblttng-ust-ctl, used internally by
# liblttng-ust, lttng-sessiond, and lttng-consumerd.
-AC_SUBST([LTTNG_UST_CTL_LIBRARY_VERSION], [3:0:1])
+AC_SUBST([LTTNG_UST_CTL_LIBRARY_VERSION], [4:0:0])
AC_CONFIG_HEADERS([config.h include/lttng/ust-config.h])
AC_CONFIG_AUX_DIR([config])
])
_AC_DEFINE_AND_SUBST([LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS], [3000])
-# By default, do not retry on buffer full condition.
-_AC_DEFINE_AND_SUBST([LTTNG_UST_DEFAULT_BLOCKING_RETRY_TIMEOUT_MS], [0])
AM_CFLAGS="-Wall"
AC_SUBST(AM_CFLAGS)
# Tools to execute:
ADOC = $(ASCIIDOC) -f $(ASCIIDOC_CONF) -d manpage \
-a lttng_version="$(PACKAGE_VERSION)" \
- -a lttng_ust_register_timeout="@LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS@" \
- -a lttng_ust_blocking_retry_timeout="@LTTNG_UST_DEFAULT_BLOCKING_RETRY_TIMEOUT_MS@"
+ -a lttng_ust_register_timeout="@LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS@"
ADOC_DOCBOOK = $(ADOC) -b docbook
XTO = $(XMLTO) -m $(firstword $(XSL_SRC_FILES)) man
are located in a specific directory under `$LTTNG_HOME` (or `$HOME` if
`$LTTNG_HOME` is not set).
-`LTTNG_UST_BLOCKING_RETRY_TIMEOUT`::
- Maximum duration (milliseconds) to retry event tracing when
- there's no space left for the event record in the sub-buffer.
-+
---
-`0`::
- Never block the application.
-
-Positive value::
- Block the application for the specified number of milliseconds. If
- there's no space left after this duration, discard the event
- record.
-
-Negative value::
- Block the application until there's space left for the event record.
---
-+
-Default: {lttng_ust_blocking_retry_timeout}.
+`LTTNG_UST_ALLOW_BLOCKING`::
+ If set, allow application to retry event tracing when there's
+ no space left for the event record in the sub-buffer, therefore
+ effectively blocking the application until space is made available
+ or timeout is reached. This only has effect on channels with
+ `blocking-timeout` set.
+
This option can be useful in workloads generating very large trace data
throughput, where blocking the application is an acceptable trade-off to
prevent discarding event records.
+
-WARNING: Setting this environment variable to a non-zero value may
-significantly affect application timings.
+WARNING: Setting this environment variable may significantly
+affect application timings.
`LTTNG_UST_CLOCK_PLUGIN`::
Path to the shared object which acts as the clock override plugin.
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; /* Blocking timeout (usec) */
+ } s;
+ char padding[LTTNG_UST_CHANNEL_ATTR_PADDING];
+ } u;
} LTTNG_PACKED;
#define LTTNG_UST_TRACEPOINT_ITER_PADDING 16
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; /* Blocking timeout (usec) */
} LTTNG_PACKED;
/*
unsigned int read_timer_interval,
unsigned char *uuid,
uint32_t chan_id,
- const int *stream_fds, int nr_stream_fds);
+ const int *stream_fds, int nr_stream_fds,
+ int64_t blocking_timeout);
void (*channel_destroy)(struct lttng_channel *chan);
union {
void *_deprecated1;
attr->switch_timer_interval,
attr->read_timer_interval,
attr->uuid, attr->chan_id,
- stream_fds, nr_stream_fds);
+ stream_fds, nr_stream_fds,
+ attr->blocking_timeout);
if (!chan->chan) {
goto chan_error;
}
/* Env. var. which are not fetched in setuid/setgid executables. */
{ "LTTNG_UST_CLOCK_PLUGIN", LTTNG_ENV_SECURE, NULL, },
{ "LTTNG_UST_GETCPU_PLUGIN", LTTNG_ENV_SECURE, NULL, },
- { "LTTNG_UST_BLOCKING_RETRY_TIMEOUT", LTTNG_ENV_SECURE, NULL, },
+ { "LTTNG_UST_ALLOW_BLOCKING", LTTNG_ENV_SECURE, NULL, },
{ "HOME", LTTNG_ENV_SECURE, NULL, },
{ "LTTNG_HOME", LTTNG_ENV_SECURE, NULL, },
};
unsigned int read_timer_interval,
unsigned char *uuid,
uint32_t chan_id,
- const int *stream_fds, int nr_stream_fds)
+ const int *stream_fds, int nr_stream_fds,
+ int64_t blocking_timeout)
{
struct lttng_channel chan_priv_init;
struct lttng_ust_shm_handle *handle;
&chan_priv_init,
buf_addr, subbuf_size, num_subbuf,
switch_timer_interval, read_timer_interval,
- stream_fds, nr_stream_fds);
+ stream_fds, nr_stream_fds, blocking_timeout);
if (!handle)
return NULL;
lttng_chan = priv;
unsigned int read_timer_interval,
unsigned char *uuid,
uint32_t chan_id,
- const int *stream_fds, int nr_stream_fds)
+ const int *stream_fds, int nr_stream_fds,
+ int64_t blocking_timeout)
{
struct lttng_channel chan_priv_init;
struct lttng_ust_shm_handle *handle;
&chan_priv_init,
buf_addr, subbuf_size, num_subbuf,
switch_timer_interval, read_timer_interval,
- stream_fds, nr_stream_fds);
+ stream_fds, nr_stream_fds, blocking_timeout);
if (!handle)
return NULL;
lttng_chan = priv;
}
static
-void get_blocking_retry_timeout(void)
+void get_allow_blocking(void)
{
- const char *str_blocking_retry_timeout =
- lttng_getenv("LTTNG_UST_BLOCKING_RETRY_TIMEOUT");
-
- if (str_blocking_retry_timeout) {
- long timeout = strtol(str_blocking_retry_timeout, NULL, 10);
-
- if (timeout < 0)
- timeout = -1;
- if (timeout > INT_MAX) {
- WARN("Saturating %s value from %ld to %d\n",
- "LTTNG_UST_BLOCKING_RETRY_TIMEOUT",
- timeout, INT_MAX);
- timeout = INT_MAX;
- }
- DBG("%s environment variable value is %ld",
- "LTTNG_UST_BLOCKING_RETRY_TIMEOUT",
- timeout);
- lttng_ust_ringbuffer_set_retry_timeout(timeout);
+ const char *str_allow_blocking =
+ lttng_getenv("LTTNG_UST_ALLOW_BLOCKING");
+
+ if (str_allow_blocking) {
+ DBG("%s environment variable is set",
+ "LTTNG_UST_ALLOW_BLOCKING");
+ lttng_ust_ringbuffer_set_allow_blocking();
}
}
timeout_mode = get_constructor_timeout(&constructor_timeout);
- get_blocking_retry_timeout();
+ get_allow_blocking();
ret = sem_init(&constructor_wait, 0, 0);
if (ret) {
size_t subbuf_size, size_t num_subbuf,
unsigned int switch_timer_interval,
unsigned int read_timer_interval,
- const int *stream_fds, int nr_stream_fds);
+ const int *stream_fds, int nr_stream_fds,
+ int64_t blocking_timeout);
/*
* channel_destroy finalizes all channel's buffers, waits for readers to
size_t priv_data_offset;
unsigned int nr_streams; /* Number of streams */
struct lttng_ust_shm_handle *handle;
- char padding[RB_CHANNEL_PADDING];
+ /* Extended options. */
+ union {
+ struct {
+ int32_t blocking_timeout_ms;
+ } s;
+ char padding[RB_CHANNEL_PADDING];
+ } u;
/*
* Associated backend contains a variable-length array. Needs to
* be last member.
*/
void lttng_fixup_ringbuffer_tls(void);
-void lttng_ust_ringbuffer_set_retry_timeout(int timeout);
+void lttng_ust_ringbuffer_set_allow_blocking(void);
#endif /* _LTTNG_UST_LIB_RINGBUFFER_RB_INIT_H */
.lock = PTHREAD_MUTEX_INITIALIZER,
};
-int lttng_ust_blocking_retry_timeout =
- CONFIG_LTTNG_UST_DEFAULT_BLOCKING_RETRY_TIMEOUT_MS;
+static bool lttng_ust_allow_blocking;
-void lttng_ust_ringbuffer_set_retry_timeout(int timeout)
+void lttng_ust_ringbuffer_set_allow_blocking(void)
{
- lttng_ust_blocking_retry_timeout = timeout;
+ lttng_ust_allow_blocking = true;
+}
+
+/* Get blocking timeout, in ms */
+static int lttng_ust_ringbuffer_get_timeout(struct channel *chan)
+{
+ if (!lttng_ust_allow_blocking)
+ return 0;
+ return chan->u.s.blocking_timeout_ms;
}
/**
void *buf_addr, size_t subbuf_size,
size_t num_subbuf, unsigned int switch_timer_interval,
unsigned int read_timer_interval,
- const int *stream_fds, int nr_stream_fds)
+ const int *stream_fds, int nr_stream_fds,
+ int64_t blocking_timeout)
{
int ret;
size_t shmsize, chansize;
struct lttng_ust_shm_handle *handle;
struct shm_object *shmobj;
unsigned int nr_streams;
+ int64_t blocking_timeout_ms;
if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
nr_streams = num_possible_cpus();
if (nr_stream_fds != nr_streams)
return NULL;
+ if (blocking_timeout < -1) {
+ return NULL;
+ }
+ /* usec to msec */
+ if (blocking_timeout == -1) {
+ blocking_timeout_ms = -1;
+ } else {
+ blocking_timeout_ms = blocking_timeout / 1000;
+ if (blocking_timeout_ms != (int32_t) blocking_timeout_ms) {
+ return NULL;
+ }
+ }
+
if (lib_ring_buffer_check_config(config, switch_timer_interval,
read_timer_interval))
return NULL;
*priv_data = NULL;
}
+ chan->u.s.blocking_timeout_ms = (int32_t) blocking_timeout_ms;
+
ret = channel_backend_init(&chan->backend, name, config,
subbuf_size, num_subbuf, handle,
stream_fds);
const struct lttng_ust_lib_ring_buffer_config *config = &chan->backend.config;
struct lttng_ust_shm_handle *handle = ctx->handle;
unsigned long reserve_commit_diff, offset_cmp;
- int timeout_left_ms = lttng_ust_blocking_retry_timeout;
+ int timeout_left_ms = lttng_ust_ringbuffer_get_timeout(chan);
retry:
offsets->begin = offset_cmp = v_read(config, &buf->offset);