From: John Levon Subject: Re: System time monotonicity Date: Tue, 3 Apr 2007 15:03:11 +0100 Message-ID: <20070403140311.GA16768@totally.trollied.org.uk> References: <20070326182323.GA30728@totally.trollied.org.uk> <20070326200447.GA3730@totally.trollied.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20070326200447.GA3730@totally.trollied.org.uk> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On Mon, Mar 26, 2007 at 09:04:47PM +0100, John Levon wrote: > > >> From what I can work out, time is supposed to be monotonic but I admit I > > > can't really understand the time code yet at least. I couldn't find any > > > documentation on what to expect from system time. Any suggestions? > > > > > > This seems to happen across all the hardware we've tried but this > > > particular case is a Sun V20Z with two CPUs: > > > > > > x86 (AuthenticAMD family 15 model 5 step 10 clock 2392 MHz) > > > AMD Opteron(tm) Processor 250 > > > > Small backwards time deltas are possible from the current time code. You'll > > have to filter them out yourself if you can't deal with them. We could add > > extra code in Xen to stop this happening for any individual VCPU > > Some instrumentation indicated that we had cross-VCPU jitter of > significant deltas, ~18us at worst. Though the instrumentation wasn't > completely reliable so that might not be accurate. I've done some more testing, the problem appears to be significantly worse than you're claiming. I store the previously read value in the thread structure and breakpoint whenever it fails: [2]> fffffffece9e6040::print kthread_t t_dhrtime t_dhrtime_tsc t_dhrtime_cpu t_dhrtime_vers t_dhrtime = 0x3de7923989c t_dhrtime_tsc = 0x9414981ce0e t_dhrtime_cpu = 0x2 t_dhrtime_vers = 0x2616 And the new values: t_dhrtime = 0x3de7923088b t_dhrtime_tsc = 0x9414982169b t_dhrtime_cpu = 0x2 t_dhrtime_vers = 0x2618 [2]> 0x3de7923989c - 0x000003de7923088b=D 36881 That's 36us. It doesn't even seem that we migrated across physical CPUs given the version field. So something seems significantly awry to me? (I must admit I still don't quite understand why monotonic_clock() is called monotonic_clock() ...) regards john