public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2] fzsync: drop pair->spins_avg.avg check
Date: Sat, 7 Sep 2019 05:31:40 -0400 (EDT)	[thread overview]
Message-ID: <1901271176.10519481.1567848700739.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <87sgpbkjst.fsf@rpws.prws.suse.cz>



----- Original Message -----
> Hello,
> 
> Jan Stancek <jstancek@redhat.com> writes:
> 
> > tst_fzsync_pair.spins is increased at least by one on every iteration.
> > If during all calibration loops, both A and B manage to complete at
> > nearly same time, then spins is increased only by one.
> >
> > spins_avg starts as 0, and tst_exp_moving_avg() will move it closer
> > and closer to 1, but it will never be 1:
> >         float f = 0; int i;
> >         for (i = 0; i < 4096; i++)
> >                 f = tst_exp_moving_avg(0.25f, 1, f);
> >         printf("%.15f %d\n", f, f >= 1);
> > 	$ 0.999999880790710 0
> > which on rare occasion can cause: "Can't calculate random delay".
> >
> > Drop check and use MAX(pair->spins_avg.avg, 1f) to calculate per_spin_time.
> > Also print stats one more time when we hit the warning.
> >
> > Suggested-by: Richard Palethorpe <rpalethorpe@suse.com>
> > Signed-off-by: Jan Stancek <jstancek@redhat.com>
> > ---
> >  include/tst_fuzzy_sync.h | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/tst_fuzzy_sync.h b/include/tst_fuzzy_sync.h
> > index de0402c9bbe9..f9a1947c7542 100644
> > --- a/include/tst_fuzzy_sync.h
> > +++ b/include/tst_fuzzy_sync.h
> > @@ -477,8 +477,8 @@ static void tst_fzsync_pair_update(struct
> > tst_fzsync_pair *pair)
> >  			tst_res(TINFO, "Minimum sampling period ended");
> >  			tst_fzsync_pair_info(pair);
> >  		}
> > -	} else if (fabsf(pair->diff_ab.avg) >= 1 && pair->spins_avg.avg >= 1) {
> > -		per_spin_time = fabsf(pair->diff_ab.avg) / pair->spins_avg.avg;
> > +	} else if (fabsf(pair->diff_ab.avg) >= 1) {
> > +		per_spin_time = fabsf(pair->diff_ab.avg) / MAX(pair->spins_avg.avg,
> > 1.0f);
> >  		time_delay = drand48() * (pair->diff_sa.avg + pair->diff_sb.avg)
> >  			- pair->diff_sb.avg;
> >  		pair->delay += (int)(time_delay / per_spin_time);
> > @@ -495,6 +495,7 @@ static void tst_fzsync_pair_update(struct
> > tst_fzsync_pair *pair)
> >  		}
> >  	} else if (!pair->sampling) {
> >  		tst_res(TWARN, "Can't calculate random delay");
> > +		tst_fzsync_pair_info(pair);
> >  		pair->sampling = -1;
> >  	}
> 
> LGTM

Pushed.

      reply	other threads:[~2019-09-07  9:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-04 14:20 [LTP] [PATCH] fzsync: don't compare spins_avg (float) against 1 (int) Jan Stancek
2019-09-05  7:23 ` Richard Palethorpe
2019-09-05  7:39   ` Jan Stancek
2019-09-05 12:08 ` [LTP] [PATCH v2] fzsync: drop pair->spins_avg.avg check Jan Stancek
2019-09-05 12:29   ` Richard Palethorpe
2019-09-07  9:31     ` Jan Stancek [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=1901271176.10519481.1567848700739.JavaMail.zimbra@redhat.com \
    --to=jstancek@redhat.com \
    --cc=ltp@lists.linux.it \
    /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