From owner-svn-src-head@freebsd.org Sun Aug 5 07:09:09 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 65F65106C5B3; Sun, 5 Aug 2018 07:09:09 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail109.syd.optusnet.com.au (mail109.syd.optusnet.com.au [211.29.132.80]) by mx1.freebsd.org (Postfix) with ESMTP id AF03682C79; Sun, 5 Aug 2018 07:09:08 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail109.syd.optusnet.com.au (Postfix) with ESMTPS id 14FE0D69B89; Sun, 5 Aug 2018 17:08:58 +1000 (AEST) Date: Sun, 5 Aug 2018 17:08:57 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Conrad Meyer cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r337334 - head/lib/libc/sys In-Reply-To: <201808042208.w74M8OmD057603@repo.freebsd.org> Message-ID: <20180805161913.C1770@besplex.bde.org> References: <201808042208.w74M8OmD057603@repo.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=I9sVfJog c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=kj9zAlcOel0A:10 a=JAFv7INFKiA87vfPrSIA:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Aug 2018 07:09:09 -0000 On Sat, 4 Aug 2018, Conrad Meyer wrote: > Log: > settimeofday(2): Remove stale note about timezone > > Contrary to the removed comment, the kernel does appear to use the timezone > argument of settimeofday. The comment dates to the BSD4.4 import; I assume it > is just stale. The kernel not only appears to use the timezone set by settimeofday(), but does use it. Applications may use it too, and adjkerntz(8) does use it. The kernel and adjkerntz also use the machdep.adjkerntz and machdep.wall_cmos_clock sysctls (these are MI but have old names for compatibility), and the final utc_offset() is: (tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0)) adjkerntz(8) does very little when wall_cmos_clock == 0. Otherwise, it manages tz_minuteswest, but I think this is only to compensate for other applications setting it. It gets the correct offset from userland and normally just puts that in adjkerntz, leaving tz_minuteswest as 0, but if tz_minuteswest != 0 then I think it preserves this mistake but compensates for it but adjusting adjkerntz so that the final offset comes out right. The broken comment applied to both gettimeofday() and settimeofday(), and is wrongest for gettimeofday(). The kernel really does use tz_minuteswest, and gettimeofday() is the only way to determine its setting. adjkerntz makes critical use of reading it even if it doesn't change it, to compensate for the foot shooting of other applications setting it. Of course, adjkerntz can't do much if other applications set it after adjkerntz(8) runs. adjkerntz normally runs at boot time before other applications have had much chance to clobber tz_minuteswest. Then it is possible for another application to clobber it. adjkerntz might be confused when it runs about 6 months later to adjust the dst, but the time becomong wrong immediately when the other application clobbers tz_minuteswest is a larger problem. The comment was almost correct in 4.4BSD-Lite2. get/settimeofday() supported the timezone parameter, but the kernel didn't use tz_minuteswest except in the i386 inittodr() which was only called at boot time before settimeofday() can run, and in some hp code where the use seems to be read-only. > Modified: head/lib/libc/sys/gettimeofday.2 > ============================================================================== > --- head/lib/libc/sys/gettimeofday.2 Sat Aug 4 21:57:17 2018 (r337333) > +++ head/lib/libc/sys/gettimeofday.2 Sat Aug 4 22:08:24 2018 (r337334) > @@ -28,7 +28,7 @@ > .\" @(#)gettimeofday.2 8.2 (Berkeley) 5/26/95 > .\" $FreeBSD$ > .\" > -.Dd December 27, 2015 > +.Dd August 4, 2018 > .Dt GETTIMEOFDAY 2 > .Os > .Sh NAME > @@ -44,11 +44,6 @@ > .Ft int > .Fn settimeofday "const struct timeval *tp" "const struct timezone *tzp" > .Sh DESCRIPTION > -.Bf -symbolic > -Note: timezone is no longer used; this information is kept outside > -the kernel. > -.Ef > -.Pp > The system's notion of the current Greenwich time and the current time > zone is obtained with the > .Fn gettimeofday The note should have been placed after this section to more obviously cancel what this section says about time zones. This section also doesn't say anything about the wall_cmos_clock and adjkerntz sysctls or there interaction with tz_minuteswest which is what actually determines the system's notion of the current time zone. Bruce