From owner-svn-doc-all@freebsd.org Mon Oct 24 04:28:41 2016 Return-Path: Delivered-To: svn-doc-all@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 7604CC1FDBE; Mon, 24 Oct 2016 04:28:41 +0000 (UTC) (envelope-from bjk@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 45BBB8C4; Mon, 24 Oct 2016 04:28:41 +0000 (UTC) (envelope-from bjk@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9O4SeHA030171; Mon, 24 Oct 2016 04:28:40 GMT (envelope-from bjk@FreeBSD.org) Received: (from bjk@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9O4SeA5030170; Mon, 24 Oct 2016 04:28:40 GMT (envelope-from bjk@FreeBSD.org) Message-Id: <201610240428.u9O4SeA5030170@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bjk set sender to bjk@FreeBSD.org using -f From: Benjamin Kaduk Date: Mon, 24 Oct 2016 04:28:40 +0000 (UTC) To: doc-committers@freebsd.org, svn-doc-all@freebsd.org, svn-doc-head@freebsd.org Subject: svn commit: r49563 - head/en_US.ISO8859-1/htdocs/news/status X-SVN-Group: doc-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-doc-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire doc trees \(except for " user" , " projects" , and " translations" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Oct 2016 04:28:41 -0000 Author: bjk Date: Mon Oct 24 04:28:40 2016 New Revision: 49563 URL: https://svnweb.freebsd.org/changeset/doc/49563 Log: Add entry on timekeeping code improvements from kib Modified: head/en_US.ISO8859-1/htdocs/news/status/report-2016-07-2016-09.xml Modified: head/en_US.ISO8859-1/htdocs/news/status/report-2016-07-2016-09.xml ============================================================================== --- head/en_US.ISO8859-1/htdocs/news/status/report-2016-07-2016-09.xml Mon Oct 24 03:58:13 2016 (r49562) +++ head/en_US.ISO8859-1/htdocs/news/status/report-2016-07-2016-09.xml Mon Oct 24 04:28:40 2016 (r49563) @@ -1358,4 +1358,70 @@ can.

+ + + Timekeeping Code Improvements + + + + + Konstantin + Belousov + + kib@FreeBSD.org + + + + +

Work was done to properly lock the time-keeping code. The + existing code correctly interoperated with readers, both kernel- + and user-space, giving them lock-less access to the actual data + ('timehands') needed to derive the time of day from the + timecounter hardware, in the presence of updaters. But updates + of the timehands, which are performed by periodic clock + interrupts, the ntpd-driven sys_ntp_adjtime(2) syscall, the + settimeofday(2) syscall, pps sync, and possibly other sources, + were not coordinated. Moreso, the NTP code was locked by Giant, + which did not really serve any purpose.

+ +

As result of the work, locking was applied to ensure that any + timehands adjustments are performed by single mutator. An + interesting case is the parallel modification of the timehands + from the top of the kernel, for instance the settimeoday(2) + syscall, and a simultaneous clock tick event, where the syscall + has already acquired the resources. In this case, it is highly + desirable to not block (spin) in the tick handler, and the + required adjustments are performed by the already executing call + from top half. There, the typical trylock operation is desired, + which was surprisingly lacking from our spinlock implementation. + mtx_trylock_spin(9) was implemented and is used for this + purpose.

+ +

The userspace getttimeofday(2) implementation was enhanced to + allow syscall-less operation on machines that use HPET hardwire + for timecounters. The HPET algorithm coexists with older + RDTSC-based code, allowing dynamic switching of timecounters. + HPET registers a page that is mmap(2)-ed readonly by libc into + userland application programs' address space as needed. + Measurements demonstrated modest improvements in gettimeofday(2) + performance, but not unexpectedly even the syscall-less HPET + timecounter is slower than invoking a syscall for RDTSC.

+ +

Some not strictly interwined but related code is the + time-bound sleep implementation. Handling of races between + callouts and the top-half code that sets and processes the + timeouts depended on the many fine details of the + callout_stop(9) KPI (kernel programming interface). In + particular, races or unpunctual KPI changes usually result in + the "catch-all" unkillable thread state with the + "-" waitchain bug. The sleepqueue timeout code was + rewritten to stop depending on the KPI details, which removed + the source of recurring bugs, and also surprisingly simplified + the code.

+ + + + The FreeBSD Foundation + +