public inbox for xenomai@lists.linux.dev
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Tobias Schaffner <tobias.schaffner@siemens.com>
Cc: xenomai@lists.linux.dev
Subject: Re: [PATCH linux-evl] evl/latmus: fix spurious overrun on first measurement sample
Date: Wed, 25 Mar 2026 16:11:54 +0100	[thread overview]
Message-ID: <871ph8j64l.fsf@xenomai.org> (raw)
In-Reply-To: <20260320211713.2150855-1-tobias.schaffner@siemens.com> (Tobias Schaffner's message of "Fri, 20 Mar 2026 22:17:13 +0100")

Tobias Schaffner <tobias.schaffner@siemens.com> writes:

> This delta is not fixed up during the warmup phase leading to spourious
> overruns in the first measurement sample.
>
> Also apply the fixup in the warmup phase.
>
> Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com>
> ---
>  drivers/evl/latmus.c | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/evl/latmus.c b/drivers/evl/latmus.c
> index 9a0295044443..9c581d80db68 100644
> --- a/drivers/evl/latmus.c
> +++ b/drivers/evl/latmus.c
> @@ -166,14 +166,23 @@ static int add_measurement_sample(struct latmus_runner *runner,
>  	ktime_t period = runner->period;
>  	int delta, cell, offset_delta;
>  
> +	delta = (int)ktime_to_ns(ktime_sub(timestamp, state->ideal));
> +	state->ideal = ktime_add(state->ideal, period);
> +
> +	while (delta > 0 &&
> +		(unsigned int)delta > ktime_to_ns(period)) { /* period > 0 */
> +		if (runner->warmup_samples >= runner->warmup_limit)
> +			state->overruns++;
> +		state->ideal = ktime_add(state->ideal, period);
> +		delta -= ktime_to_ns(period);
> +	}
> +
>  	/* Skip samples in warmup time. */
>  	if (runner->warmup_samples < runner->warmup_limit) {
>  		runner->warmup_samples++;
> -		state->ideal = ktime_add(state->ideal, period);
>  		return 0;
>  	}
>  
> -	delta = (int)ktime_to_ns(ktime_sub(timestamp, state->ideal));
>  	offset_delta = delta - state->offset;
>  	if (offset_delta < state->min_lat)
>  		state->min_lat = offset_delta;
> @@ -193,14 +202,6 @@ static int add_measurement_sample(struct latmus_runner *runner,
>  	}
>  
>  	state->sum += offset_delta;
> -	state->ideal = ktime_add(state->ideal, period);
> -
> -	while (delta > 0 &&
> -		(unsigned int)delta > ktime_to_ns(period)) { /* period > 0 */
> -		state->overruns++;
> -		state->ideal = ktime_add(state->ideal, period);
> -		delta -= ktime_to_ns(period);
> -	}
>  
>  	if (++state->cur_samples >= state->max_samples)
>  		send_measurement(runner);

Merged, thanks.

-- 
Philippe.

      reply	other threads:[~2026-03-25 15:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20 21:17 [PATCH linux-evl] evl/latmus: fix spurious overrun on first measurement sample Tobias Schaffner
2026-03-25 15:11 ` Philippe Gerum [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871ph8j64l.fsf@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=tobias.schaffner@siemens.com \
    --cc=xenomai@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox