From owner-freebsd-hackers@freebsd.org Thu Oct 3 15:10:30 2019 Return-Path: Delivered-To: freebsd-hackers@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 66D1E138960 for ; Thu, 3 Oct 2019 15:10:30 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46kbzT3md3z4FjM for ; Thu, 3 Oct 2019 15:10:29 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qt1-x832.google.com with SMTP id d16so4047025qtq.8 for ; Thu, 03 Oct 2019 08:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1JzW2++7GTE3s7qUmep7JvHCH58b4SQhkqVQTNfGLhU=; b=SPoHGhLG5fiqHQfp3YiB6qrk/bs2n5w3lux8lbJA/XneZHj2QUwQO7m6NttCXb3gEC 75+cVTFembBPnhWClLSFrwi7/fhontRRBy53qbGbwDxALm3+ho8J2Xtz9+n980BwD8L8 pcDk9u3boE67sRSpsLI6Q97cKCorMkcUfZFNx5NlGYLGDuTHms9314zAAOcWad9rElmE fQUcN8WMDwz4Ys9D9q3tA2zKkIKs6hBcWzhL2jKgmYfxRSfunzjyqFXpbr7O6MPPFzmU etAxA8VACp9RdvOPEE1sWKfi8GeicJ92WKf0xcbt3nXcXZDUhB13AUS4ZXbM7M5irc+Q Mt0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1JzW2++7GTE3s7qUmep7JvHCH58b4SQhkqVQTNfGLhU=; b=h1WZFJL3rV32AlDPYfjG66cxyY3d6eU6NI0uqn4j+ZkcYU9Xr8sJh43HpLdbO2mcEd TB3E3q9aB80BTviasr/nARoDvrs1RGDsP8oUu/BNwZZXwN0CWLJKn26u0+g1MZb7fJ7B t55FlgwtHlDYhyz/BpWH/iCkzLdiuJIr7/ZxT1wPlKzFz9c99fD1PSfODFSi3UO6abFj ElKi0qWrXHfcMz5QDLSxb0tM7oZ5AkBVn+XITywXoKswAGD6Z2KY7vpXeVfyUtpXeHTM IFCuDiWBTdb+t32vM8nXYEH8xXry3J/txvCHF5pgpReXCePckTdaV6QmV7yslvhJuvrd yQ6w== X-Gm-Message-State: APjAAAXsUsTgrz+vEWUwh/C7NFZwgPdvA+AXxxzO9KQZBbcwtckKPQHD +1lfF4GTUrJ82FV/B6/irk6La3tKjXCGTesx6mZWQA== X-Google-Smtp-Source: APXvYqwylLPRPTbyh03Ahl4TfEQlxCLikQDLWcAP9J1ZiXKFKi0hrM1jN7rHnzAc91Syqtpw8Sle7vY3s1ITAlmjPLY= X-Received: by 2002:a0c:9ba8:: with SMTP id o40mr8907647qve.125.1570115427957; Thu, 03 Oct 2019 08:10:27 -0700 (PDT) MIME-Version: 1.0 References: <0e27fb3e-0f60-68e1-dbba-f17c3d91c332@embedded-brains.de> <20191002140040.GA44691@kib.kiev.ua> <20191003013314.O2151@besplex.bde.org> <20191002163946.GE44691@kib.kiev.ua> <20191003030837.C2787@besplex.bde.org> <20191003084021.GI44691@kib.kiev.ua> In-Reply-To: <20191003084021.GI44691@kib.kiev.ua> From: Warner Losh Date: Thu, 3 Oct 2019 09:10:16 -0600 Message-ID: Subject: Re: Why is tc_get_timecount() called two times in tc_init()? To: Konstantin Belousov Cc: Bruce Evans , Sebastian Huber , FreeBSD X-Rspamd-Queue-Id: 46kbzT3md3z4FjM X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=SPoHGhLG; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::832) smtp.mailfrom=wlosh@bsdimp.com X-Spamd-Result: default: False [-2.82 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.99)[-0.990,0]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_COUNT_TWO(0.00)[2]; IP_SCORE(-2.83)[ip: (-9.39), ipnet: 2607:f8b0::/32(-2.57), asn: 15169(-2.16), country: US(-0.05)]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; URI_COUNT_ODD(1.00)[3]; NEURAL_HAM_LONG(-1.00)[-0.997,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; RCVD_IN_DNSWL_NONE(0.00)[2.3.8.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; FREEMAIL_TO(0.00)[gmail.com]; SUBJECT_ENDS_QUESTION(1.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; RCVD_TLS_ALL(0.00)[]; FREEMAIL_CC(0.00)[optusnet.com.au] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Oct 2019 15:10:30 -0000 I think this is a good fix. I recall phk saying it was more paranoia for edge cases than really needed in a private email to me, but it's in the 'gap' of email that I lost in a disk crash 12 years ago so I can't find it for sure. Warner On Thu, Oct 3, 2019 at 2:40 AM Konstantin Belousov wrote: > On Thu, Oct 03, 2019 at 03:12:26AM +1000, Bruce Evans wrote: > > On Wed, 2 Oct 2019, Konstantin Belousov wrote: > > > > > On Thu, Oct 03, 2019 at 02:25:46AM +1000, Bruce Evans wrote: > > >> On Wed, 2 Oct 2019, Konstantin Belousov wrote: > > > So the conclusion is that the second call can be removed, am I right ? > > > > Yes. > > > > All tc_get_timecount() functions should be checked for doing sufficient > > initialization in one call (so that deltas for subsequent calls are > > correct). > > This should be it. > > But, is even a single call to tc_get_timecount() needed for "warmup" ? > > diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c > index 382d139617d..28d0d738a58 100644 > --- a/sys/dev/acpica/acpi.c > +++ b/sys/dev/acpica/acpi.c > @@ -3191,7 +3191,6 @@ acpi_resync_clock(struct acpi_softc *sc) > * Warm up timecounter again and reset system clock. > */ > (void)timecounter->tc_get_timecount(timecounter); > - (void)timecounter->tc_get_timecount(timecounter); > inittodr(time_second + sc->acpi_sleep_delay); > } > > diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c > index 34a832089a2..d768397a785 100644 > --- a/sys/dev/acpica/acpi_timer.c > +++ b/sys/dev/acpica/acpi_timer.c > @@ -274,7 +274,6 @@ acpi_timer_resume_handler(struct timecounter *newtc) > "restoring timecounter, %s -> %s\n", > tc->tc_name, newtc->tc_name); > (void)newtc->tc_get_timecount(newtc); > - (void)newtc->tc_get_timecount(newtc); > timecounter = newtc; > } > } > diff --git a/sys/dev/xen/control/control.c b/sys/dev/xen/control/control.c > index 98ab5bf3a6b..1e132f4d866 100644 > --- a/sys/dev/xen/control/control.c > +++ b/sys/dev/xen/control/control.c > @@ -303,7 +303,6 @@ xctrl_suspend() > * Warm up timecounter again and reset system clock. > */ > timecounter->tc_get_timecount(timecounter); > - timecounter->tc_get_timecount(timecounter); > inittodr(time_second); > > #ifdef EARLY_AP_STARTUP > diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c > index 9920a9a9304..847fbbbf35d 100644 > --- a/sys/kern/kern_tc.c > +++ b/sys/kern/kern_tc.c > @@ -1257,7 +1257,6 @@ tc_init(struct timecounter *tc) > tc->tc_frequency < timecounter->tc_frequency) > return; > (void)tc->tc_get_timecount(tc); > - (void)tc->tc_get_timecount(tc); > timecounter = tc; > } > > @@ -1519,7 +1518,6 @@ sysctl_kern_timecounter_hardware(SYSCTL_HANDLER_ARGS) > > /* Warm up new timecounter. */ > (void)newtc->tc_get_timecount(newtc); > - (void)newtc->tc_get_timecount(newtc); > > timecounter = newtc; > > @@ -2011,7 +2009,6 @@ inittimecounter(void *dummy) > > /* warm up new timecounter (again) and get rolling. */ > (void)timecounter->tc_get_timecount(timecounter); > - (void)timecounter->tc_get_timecount(timecounter); > mtx_lock_spin(&tc_setclock_mtx); > tc_windup(NULL); > mtx_unlock_spin(&tc_setclock_mtx); > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >