From: Dan Magenheimer Subject: RE: Re: [PATCH 3/5] x86/pvclock: add vsyscall implementation Date: Wed, 4 Nov 2009 16:45:04 -0800 (PST) Message-ID: <36e12dba-7580-4a9c-9fac-9e8d810e5a7c@default> References: <1257379338.10811.152.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <1257379338.10811.152.camel@localhost.localdomain> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: john stultz Cc: Jeremy Fitzhardinge , Jeremy Fitzhardinge , kurt.hackel@oracle.com, Glauber Costa , maintainers , Linux Kernel Mailing List , Glauber de Oliveira Costa , Xen-devel , Avi Kivity , the, Ingo Molnar , zach.brown@oracle.com, chris.mason@oracle.com, Keir Fraser List-Id: xen-devel@lists.xenproject.org > > Yes, possibly of interest. But does it work with CONFIG_NO_HZ? > > (I'm expecting that over time NO_HZ will become widespread > > for VM OS's, though interested in if you agree.) >=20 > It should work, with CONFIG_NO_HZ, as soon as we come out of=20 > a long idle > (likely due to a timer tick), the timekeeping code will accumulate all > the skipped ticks. >=20 > If we ever get to non-idle NOHZ, we'll need some extra work here > (probably lazy accumulation done conditionally in the read path), but > that's also true for filesystem timestamps.=20 OK, sounds good. > > Also very interested in your thoughts about a variation > > that returns something similar to a TSC_AUX to notify > > caller that the underlying reference clock has/may have > > changed. >=20 > I haven't been following that closely. Personally, experience makes me > skeptical of workarounds for unsynced TSCs. But I'm sure=20 > there's sharper > folks out there that might make it work. The kernel just requires that > it *really really* works, and not "mostly" works. :) This is less a workaround for unsynced TSCs than it is for VM migration (and maybe also time where a VM is out-of-context or moved to a different pcpu) though it could probably be made to work on unsynced TSC boxes also. Basically an application needing hi-res profiling info would do: nsec1 =3D clock_gettime2(MONOTONIC,&aux1); (time passes) nsec2 =3D clock_gettime2(MONOTONIC,&aux2); if (aux1 !=3D aux2) discard_measurement(); else use_measurement(nsec2-nsec1); and system software (hypervisor or kernel or both) is responsible for ensuring aux value monotonically increases whenever a different crystal is used. Without something like this as a vsyscall, apps will just use rdtscp (which must be emulated to work properly across a migration).