Re: [PATCH linux-evl] evl/latmus: fix spurious overrun on first measurement sample
Philippe Gerum <[email protected]>
| Newsgroups | dev.linux.lists.xenomai |
|---|---|
| Message-ID | <[email protected]> |
Tobias Schaffner <[email protected]> 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 <[email protected]> > --- > 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.