Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Oct 2017 11:49:01 +0200
From:      Sebastian Huber <sebastian.huber@embedded-brains.de>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: [PATCH] Simplify th_bintime update in tc_windup()
Message-ID:  <94f238ec-4cac-7c27-87ac-bc84d13d2eda@embedded-brains.de>
In-Reply-To: <20171011093101.GX95911@kib.kiev.ua>
References:  <20171011064816.20809-1-sebastian.huber@embedded-brains.de> <20171011093101.GX95911@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On 11/10/17 11:31, Konstantin Belousov wrote:

> On Wed, Oct 11, 2017 at 08:48:16AM +0200, Sebastian Huber wrote:
>> The th_bintime, th_microtime and th_nanotime members of the timehand a=
ll
>> cache the last system time (uptime + boottime).  Only the format
>> differs.  Do not re-calculate the bintime and simply use the value use=
d
>> to calculate the microtime and nanotime.
>>
>> Group all the updates under the relevant comment.
> th->th_bintime is recalculated after possible adjustments made by
> the ntp loop to the th_boottime.

The loop is:

 =C2=A0=C2=A0=C2=A0 bt =3D th->th_offset;
 =C2=A0=C2=A0=C2=A0 bintime_add(&bt, &th->th_boottime);

<--- here the bt is our new system time

 =C2=A0=C2=A0=C2=A0 i =3D bt.sec - tho->th_microtime.tv_sec;
 =C2=A0=C2=A0=C2=A0 if (i > LARGE_STEP)
 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 i =3D 2;
 =C2=A0=C2=A0=C2=A0 for (; i > 0; i--) {
 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 t =3D bt.sec;
 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntp_update_second(&th->th_adjustme=
nt, &bt.sec);
 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (bt.sec !=3D t)

<-- here the bt.sec changed

 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 th->th_boottime=
.sec +=3D bt.sec - t;

<-- here we update the boottime seconds, so now bt =3D=3D uptime + bootti=
me
 =C2=A0=C2=A0=C2=A0 }

So, I think the patch is correct.

>
> But your patch makes me consider the two lines after the XXX comment.
> Shouldn't we use the updated th_bintime instead of the pre-adjustment
> bt value ?
>

All values should reflect the same time.

--=20
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine gesch=C3=A4ftliche Mitteilung im Sinne des EHUG=
.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?94f238ec-4cac-7c27-87ac-bc84d13d2eda>