From owner-freebsd-hackers@freebsd.org Wed Oct 11 09:49:10 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B799CE269F1 for ; Wed, 11 Oct 2017 09:49:10 +0000 (UTC) (envelope-from sebastian.huber@embedded-brains.de) Received: from dedi548.your-server.de (dedi548.your-server.de [85.10.215.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 731EE1CC9 for ; Wed, 11 Oct 2017 09:49:10 +0000 (UTC) (envelope-from sebastian.huber@embedded-brains.de) Received: from [88.198.220.130] (helo=sslproxy01.your-server.de) by dedi548.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.85_2) (envelope-from ) id 1e2DdT-0001qA-34; Wed, 11 Oct 2017 11:49:07 +0200 Received: from [82.135.62.35] (helo=mail.embedded-brains.de) by sslproxy01.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e2DdS-0001bc-Ry; Wed, 11 Oct 2017 11:49:06 +0200 Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id E09DF2A1677; Wed, 11 Oct 2017 11:49:02 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id b39luOFYEMKq; Wed, 11 Oct 2017 11:48:59 +0200 (CEST) Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id A51F12A1678; Wed, 11 Oct 2017 11:48:59 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id hUs5YazYYUi8; Wed, 11 Oct 2017 11:48:59 +0200 (CEST) Received: from [192.168.96.129] (unknown [192.168.96.129]) by mail.embedded-brains.de (Postfix) with ESMTPSA id 6E0462A1677; Wed, 11 Oct 2017 11:48:59 +0200 (CEST) Subject: Re: [PATCH] Simplify th_bintime update in tc_windup() To: Konstantin Belousov Cc: freebsd-hackers@freebsd.org References: <20171011064816.20809-1-sebastian.huber@embedded-brains.de> <20171011093101.GX95911@kib.kiev.ua> From: Sebastian Huber Message-ID: <94f238ec-4cac-7c27-87ac-bc84d13d2eda@embedded-brains.de> Date: Wed, 11 Oct 2017 11:49:01 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20171011093101.GX95911@kib.kiev.ua> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: quoted-printable X-Authenticated-Sender: smtp-embedded@poldinet.de X-Virus-Scanned: Clear (ClamAV 0.99.2/23935/Wed Oct 11 06:02:35 2017) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Oct 2017 09:49:10 -0000 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= .