[PATCH] Simplify th_bintime update in tc_windup()

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Oct 11 09:49:10 UTC 2017


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 all
>> cache the last system time (uptime + boottime).  Only the format
>> differs.  Do not re-calculate the bintime and simply use the value used
>> 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:

     bt = th->th_offset;
     bintime_add(&bt, &th->th_boottime);

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

     i = bt.sec - tho->th_microtime.tv_sec;
     if (i > LARGE_STEP)
         i = 2;
     for (; i > 0; i--) {
         t = bt.sec;
         ntp_update_second(&th->th_adjustment, &bt.sec);
         if (bt.sec != t)

<-- here the bt.sec changed

             th->th_boottime.sec += bt.sec - t;

<-- here we update the boottime seconds, so now bt == uptime + boottime
     }

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.

-- 
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 at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the freebsd-hackers mailing list