From owner-freebsd-current Sun Feb 17 16:52:45 2002 Delivered-To: freebsd-current@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 7B51437B400 for ; Sun, 17 Feb 2002 16:52:40 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id LAA12778; Mon, 18 Feb 2002 11:52:27 +1100 Date: Mon, 18 Feb 2002 11:52:26 +1100 (EST) From: Bruce Evans X-X-Sender: To: Matthew Dillon Cc: Poul-Henning Kamp , Subject: Re: Success! Sorta! (was Re: 'microuptime() went backwards ...' using ACPI timer. Shouldn't that be impossible? ) In-Reply-To: <200202172042.g1HKgs691210@apollo.backplane.com> Message-ID: <20020218114754.M4061-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, 17 Feb 2002, Matthew Dillon wrote: > Whoop! I take it back. I'm still getting the errors: > > microuptime() went backwards (458.168990 -> 458.168882) > microuptime() went backwards (578.609995 -> 577.929801) > microuptime() went backwards (748.912755 -> 748.237402) > microuptime() went backwards (775.159625 -> 775.159612) > > I also think this retry loop has to be done everywhere where the > timecounter structure is accessed directly. Yes, since the reads of all the relevant timecounter variables are non-atomic. > Index: kern/kern_tc.c > =================================================================== > RCS file: /home/ncvs/src/sys/kern/kern_tc.c,v > retrieving revision 1.113 > diff -u -r1.113 kern_tc.c > --- kern/kern_tc.c 7 Feb 2002 21:21:55 -0000 1.113 > +++ kern/kern_tc.c 17 Feb 2002 20:41:47 -0000 > @@ -126,8 +128,10 @@ > struct timecounter *tc; > > ngetmicrotime++; > - tc = timecounter; > - *tvp = tc->tc_microtime; > + do { > + tc = timecounter; > + *tvp = tc->tc_microtime; > + } while (tc != timecounter); > } > > void E.g., tc_mictrotime here is a timeval. It doesn't matter getting a stale value (although getting a stale value increases the possible incoherency of the get*() functions from 1/HZ to NTIMECOUNTER/HZ), but getting a stale value that changed underneath the read would be bad. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message