From owner-freebsd-hackers@freebsd.org Fri Oct 4 14:10:54 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 46DA512F858 for ; Fri, 4 Oct 2019 14:10:54 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) (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 46lBcD6N31z4Q1v for ; Fri, 4 Oct 2019 14:10:52 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (v-critter.freebsd.dk [192.168.55.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by phk.freebsd.dk (Postfix) with ESMTPS id 14B4A1AF403; Fri, 4 Oct 2019 14:10:50 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.15.2/8.15.2) with ESMTPS id x94EAn3I060169 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 4 Oct 2019 14:10:49 GMT (envelope-from phk@critter.freebsd.dk) Received: (from phk@localhost) by critter.freebsd.dk (8.15.2/8.15.2/Submit) id x94EAmRs060168; Fri, 4 Oct 2019 14:10:48 GMT (envelope-from phk) To: Sebastian Huber cc: Warner Losh , Konstantin Belousov , Bruce Evans , FreeBSD Subject: Re: Why is tc_get_timecount() called two times in tc_init()? In-reply-to: <141ee0af-2ff4-50fc-b4e4-6d1fc47e04f3@embedded-brains.de> From: "Poul-Henning Kamp" 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> <47834.1570116246@critter.freebsd.dk> <141ee0af-2ff4-50fc-b4e4-6d1fc47e04f3@embedded-brains.de> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <60166.1570198248.1@critter.freebsd.dk> Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Oct 2019 14:10:48 +0000 Message-ID: <60167.1570198248@critter.freebsd.dk> X-Rspamd-Queue-Id: 46lBcD6N31z4Q1v X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of phk@critter.freebsd.dk designates 130.225.244.222 as permitted sender) smtp.mailfrom=phk@critter.freebsd.dk X-Spamd-Result: default: False [-0.10 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.21)[-0.211,0]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; NEURAL_HAM_LONG(-0.95)[-0.949,0]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[freebsd.dk]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; IP_SCORE(0.07)[ip: (0.08), ipnet: 130.225.0.0/16(0.11), asn: 1835(0.15), country: EU(-0.01)]; FORGED_SENDER(0.30)[phk@phk.freebsd.dk,phk@critter.freebsd.dk]; MIME_TRACE(0.00)[0:+]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:1835, ipnet:130.225.0.0/16, country:EU]; SUBJECT_ENDS_QUESTION(1.00)[]; FROM_NEQ_ENVFROM(0.00)[phk@phk.freebsd.dk,phk@critter.freebsd.dk] 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: Fri, 04 Oct 2019 14:10:54 -0000 -------- In message <141ee0af-2ff4-50fc-b4e4-6d1fc47e04f3@embedded-brains.de>, Seba= stian Huber writes: >> I think the original reason for this was (locked) delta-based >> timecounters, (ie counters which roll over rapidly) in order that >> their first "real" use would not return truly bogus values. > >Ok, this explanation makes sense. When I ported the FreeBSD timecounter = >implementation to RTEMS I was a bit surprised how many chips (even a = >Cortex-M has nothing out of the box) lack a simple free running counter. = >Maybe it should be added as a comment to these two tc_get_timecount() cal= ls? As long as the counter can be read atomically and does not roll over in a matter of milliseconds, two reads are not necessary. -- = Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe = Never attribute to malice what can adequately be explained by incompetence= .