From owner-freebsd-hackers@freebsd.org Wed Oct 11 11:03:44 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 2163CE2880C for ; Wed, 11 Oct 2017 11:03:44 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 ABF0063B66 for ; Wed, 11 Oct 2017 11:03:43 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v9BB3OmL022133 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 11 Oct 2017 14:03:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v9BB3OmL022133 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v9BB3Or3022132; Wed, 11 Oct 2017 14:03:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 11 Oct 2017 14:03:24 +0300 From: Konstantin Belousov To: Sebastian Huber Cc: freebsd-hackers@freebsd.org Subject: Re: [PATCH] Simplify th_bintime update in tc_windup() Message-ID: <20171011110324.GY95911@kib.kiev.ua> References: <20171011064816.20809-1-sebastian.huber@embedded-brains.de> <20171011093101.GX95911@kib.kiev.ua> <94f238ec-4cac-7c27-87ac-bc84d13d2eda@embedded-brains.de> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <94f238ec-4cac-7c27-87ac-bc84d13d2eda@embedded-brains.de> User-Agent: Mutt/1.9.1 (2017-09-22) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home 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 11:03:44 -0000 On Wed, Oct 11, 2017 at 11:49:01AM +0200, Sebastian Huber wrote: > 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) Can you fix your mail client ? The mail body is filled with the \x9a symbols which makes the text unreadable and requiring decyphering. > > <-- 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. Thank you for the explanation. I committed this as r324528. > > > > > 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. s/should// due to synchronity of the updates to bt and th_bootime, as you noted above.