[lttng-dev] [PATCH lttng-ust] Implement LTTNG_UST_BLOCKING_RETRY_TIMEOUT
Jonathan Rajotte Julien
Jonathan.rajotte-julien at efficios.com
Fri Nov 4 14:23:57 UTC 2016
On 2016-11-04 10:22 AM, Philippe Proulx wrote:
> On Fri, Nov 4, 2016 at 10:13 AM, Jonathan Rajotte Julien
> <Jonathan.rajotte-julien at efficios.com> wrote:
>> Nitpicking:
>>
>> Should this be RETRY_DELAY_MS since other name scheme use the *_MS suffix ?
>>
>> e.g:
>> LTTNG_UST_RING_BUFFER_RETRY_DELAY_MS
>> CONFIG_LTTNG_UST_DEFAULT_BLOCKING_RETRY_TIMEOUT_MS
>> timeout_left_ms
> Counterexample: LTTNG_UST_REGISTER_TIMEOUT.
>
> Phil
Well we have a problem.
Jonathan
>
>>
>>> /*
>>> * Non-static to ensure the compiler does not optimize away the xor.
>>> @@ -149,6 +150,14 @@ static struct timer_signal_data timer_signal = {
>>> .lock = PTHREAD_MUTEX_INITIALIZER,
>>> };
>>> +int lttng_ust_blocking_retry_timeout =
>>> + CONFIG_LTTNG_UST_DEFAULT_BLOCKING_RETRY_TIMEOUT_MS;
>>> +
>>> +void lttng_ust_ringbuffer_set_retry_timeout(int timeout)
>>> +{
>>> + lttng_ust_blocking_retry_timeout = timeout;
>>> +}
>>> +
>>> /**
>>> * lib_ring_buffer_reset - Reset ring buffer to initial values.
>>> * @buf: Ring buffer.
>>> @@ -1985,6 +1994,23 @@ void lib_ring_buffer_switch_slow(struct
>>> lttng_ust_lib_ring_buffer *buf, enum swi
>>> lib_ring_buffer_switch_old_end(buf, chan, &offsets, tsc, handle);
>>> }
>>> +static
>>> +bool handle_blocking_retry(int *timeout_left_ms)
>>> +{
>>> + int timeout = *timeout_left_ms, delay;
>>> +
>>> + if (caa_likely(!timeout))
>>> + return false; /* Do not retry, discard event. */
>>> + if (timeout < 0) /* Wait forever. */
>>> + delay = RETRY_DELAY;
>>> + else
>>> + delay = min_t(int, timeout, RETRY_DELAY);
>>> + (void) poll(NULL, 0, delay);
>>> + if (timeout > 0)
>>> + *timeout_left_ms -= delay;
>>> + return true; /* Retry. */
>>> +}
>>> +
>>> /*
>>> * Returns :
>>> * 0 if ok
>>> @@ -2001,6 +2027,7 @@ int lib_ring_buffer_try_reserve_slow(struct
>>> lttng_ust_lib_ring_buffer *buf,
>>> 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;
>>> retry:
>>> offsets->begin = offset_cmp = v_read(config, &buf->offset);
>>> @@ -2083,6 +2110,9 @@ retry:
>>> >= chan->backend.buf_size)) {
>>> unsigned long nr_lost;
>>> + if
>>> (handle_blocking_retry(&timeout_left_ms))
>>> + goto retry;
>>> +
>>> /*
>>> * We do not overwrite non consumed
>>> buffers
>>> * and we are full : record is lost.
>>
>> --
>> Jonathan R. Julien
>> Efficios
>>
>>
>> _______________________________________________
>> lttng-dev mailing list
>> lttng-dev at lists.lttng.org
>> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
--
Jonathan R. Julien
Efficios
More information about the lttng-dev
mailing list