From owner-freebsd-current Sun Feb 17 10:46:18 2002 Delivered-To: freebsd-current@freebsd.org Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by hub.freebsd.org (Postfix) with ESMTP id C6EBC37B404 for ; Sun, 17 Feb 2002 10:46:14 -0800 (PST) Received: (from dillon@localhost) by apollo.backplane.com (8.11.6/8.9.1) id g1HIkCQ71367; Sun, 17 Feb 2002 10:46:12 -0800 (PST) (envelope-from dillon) Date: Sun, 17 Feb 2002 10:46:12 -0800 (PST) From: Matthew Dillon Message-Id: <200202171846.g1HIkCQ71367@apollo.backplane.com> To: Bruce Evans Cc: Subject: Re: 'microuptime() went backwards ...' using ACPI timer. Shouldn't that be impossible? References: <20020217184436.M934-100000@gamplex.bde.org> 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 :I just wrote the following fix for some of the overflow problems. I don't understand how this code is supposed to handle overflows. You seem only to be checking to see if the master timecounter has changed to a different type. -Matt Matthew Dillon :%%% :Index: kern_tc.c :=================================================================== :RCS file: /home/ncvs/src/sys/kern/kern_tc.c,v :retrieving revision 1.113 :diff -c -2 -r1.113 kern_tc.c :*** kern_tc.c 7 Feb 2002 21:21:55 -0000 1.113 :--- kern_tc.c 17 Feb 2002 06:25:14 -0000 :*************** :*** 108,114 **** : struct timecounter *tc; : :! tc = timecounter; :! *bt = tc->tc_offset; :! bintime_addx(bt, tc->tc_scale * tco_delta(tc)); : } : :--- 95,129 ---- : struct timecounter *tc; : :! /* :! * The loop is to handle changes of timecounter underneath us. :! * Such changes may even become normal for preemptive kernels. :! * It is quite reasonable for idle priority processes to not :! * run for many seconds, and if they are not running after :! * being preempted here, the timecounter may cycle many times :! * underneath them. An NTIMECOUNTER of > 2 is neither necessary :! * or sufficient for fixing this problem, unless NTIMECOUNTER is :! * preposterously large. NTIMECOUNTER == 2 suffices for most :! * cases, and something more is required to fix the general case. :! * :! * I hope this also fixes problems with overflow of the :! * multiplication. We depend on tc not becoming stale by more :! * than 1 second. We will now normally see such staleness :! * because it will cause the timecounter to change many times :! * underneath us. There will only be problems if hardclock() :! * doesn't run for many seconds, but hardclock() is a very :! * high priority interrupt, so such problems "can't happen". :! * :! * XXX should use a generation count. :! * :! * XXX problems with hardclock() can happen, e.g., at boot time :! * if you have fixed hardclock() to not be a broken fast interrupt :! * handler, or if you sit at the ddb prompt for several seconds. :! * Should do something to make them harmless. :! */ :! do { :! tc = timecounter; :! *bt = tc->tc_offset; :! bintime_addx(bt, tc->tc_scale * tco_delta(tc)); :! } while (tc != timecounter); : } : :%%% : :Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message