From owner-svn-src-head@freebsd.org Mon Sep 9 18:48:13 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7FC44DBF2C; Mon, 9 Sep 2019 18:48:13 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 46Rxxn1s6rz4Pgx; Mon, 9 Sep 2019 18:48:12 +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 x89Im5Ue083856 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 9 Sep 2019 21:48:08 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x89Im5Ue083856 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x89Im5iB083855; Mon, 9 Sep 2019 21:48:05 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 9 Sep 2019 21:48:05 +0300 From: Konstantin Belousov To: Conrad Meyer Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r352059 - head/sys/kern Message-ID: <20190909184805.GV2559@kib.kiev.ua> References: <201909091129.x89BTxvw061871@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-Rspamd-Queue-Id: 46Rxxn1s6rz4Pgx X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-6.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 09 Sep 2019 18:48:13 -0000 On Mon, Sep 09, 2019 at 11:31:32AM -0700, Conrad Meyer wrote: > What’s the motivation for using more timehands? See the thread titled 'Is it a good idea to use a usb-serial adapter for PPS input? Yes, it is.' on arm@ and usb@. In short, there are some reports of timecounters misbehaving on single-core systems when only two timehands are enabled. The change eases the experimentation and provides a workaround which does not require modifying the sources to apply. > > On Mon, Sep 9, 2019 at 04:30 Konstantin Belousov wrote: > > > Author: kib > > Date: Mon Sep 9 11:29:58 2019 > > New Revision: 352059 > > URL: https://svnweb.freebsd.org/changeset/base/352059 > > > > Log: > > Make timehands count selectable at boottime. > > > > Tested by: O'Connor, Daniel > > Sponsored by: The FreeBSD Foundation > > MFC after: 1 week > > Differential revision: https://reviews.freebsd.org/D21563 > > > > Modified: > > head/sys/kern/kern_tc.c > > > > Modified: head/sys/kern/kern_tc.c > > > > ============================================================================== > > --- head/sys/kern/kern_tc.c Mon Sep 9 11:22:38 2019 (r352058) > > +++ head/sys/kern/kern_tc.c Mon Sep 9 11:29:58 2019 (r352059) > > @@ -83,19 +83,16 @@ struct timehands { > > struct timehands *th_next; > > }; > > > > -static struct timehands th0; > > -static struct timehands th1 = { > > - .th_next = &th0 > > -}; > > -static struct timehands th0 = { > > +static struct timehands ths[16] = { > > + [0] = { > > .th_counter = &dummy_timecounter, > > .th_scale = (uint64_t)-1 / 1000000, > > .th_offset = { .sec = 1 }, > > .th_generation = 1, > > - .th_next = &th1 > > + }, > > }; > > > > -static struct timehands *volatile timehands = &th0; > > +static struct timehands *volatile timehands = &ths[0]; > > struct timecounter *timecounter = &dummy_timecounter; > > static struct timecounter *timecounters = &dummy_timecounter; > > > > @@ -115,6 +112,10 @@ static int timestepwarnings; > > SYSCTL_INT(_kern_timecounter, OID_AUTO, stepwarnings, CTLFLAG_RW, > > ×tepwarnings, 0, "Log time steps"); > > > > +static int timehands_count = 2; > > +SYSCTL_INT(_kern_timecounter, OID_AUTO, timehands_count, CTLFLAG_RDTUN, > > + &timehands_count, 0, "Count of timehands in rotation"); > > + > > struct bintime bt_timethreshold; > > struct bintime bt_tickthreshold; > > sbintime_t sbt_timethreshold; > > @@ -1960,8 +1961,9 @@ done: > > static void > > inittimecounter(void *dummy) > > { > > + struct timehands *thp; > > u_int p; > > - int tick_rate; > > + int i, tick_rate; > > > > /* > > * Set the initial timeout to > > @@ -1987,6 +1989,16 @@ inittimecounter(void *dummy) > > #ifdef FFCLOCK > > ffclock_init(); > > #endif > > + > > + /* Set up the requested number of timehands. */ > > + if (timehands_count < 1) > > + timehands_count = 1; > > + if (timehands_count > nitems(ths)) > > + timehands_count = nitems(ths); > > + for (i = 1, thp = &ths[0]; i < timehands_count; thp = &ths[i++]) > > + thp->th_next = &ths[i]; > > + thp->th_next = &ths[0]; > > + > > /* warm up new timecounter (again) and get rolling. */ > > (void)timecounter->tc_get_timecount(timecounter); > > (void)timecounter->tc_get_timecount(timecounter); > > > >