From: Dan Magenheimer Subject: RE: Re: [PATCH 3/5] x86/pvclock: add vsyscall implementation Date: Thu, 5 Nov 2009 06:52:38 -0800 (PST) Message-ID: References: <4AF274E5.5080205@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <4AF274E5.5080205@redhat.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Avi Kivity Cc: Jeremy Fitzhardinge , Jeremy Fitzhardinge , kurt.hackel@oracle.com, Glauber Costa , the arch/x86 maintainers , Linux Kernel Mailing List , Glauber de Oliveira Costa , Xen-devel , Keir Fraser , zach.brown@oracle.com, Ingo Molnar , chris.mason@oracle.com List-Id: xen-devel@lists.xenproject.org > From: Avi Kivity [mailto:avi@redhat.com] >=20 > Within a process, yes. Across processes, not without writable shared=20 > memory. >=20 > That's why I'm trying to understand what the actual=20 > requirements are. =20 > Real monotonic, accurate, high resolution, low cost time sources are=20 > hard to come by. Hmmm... this has significant implications for the rdtsc emulation discussion on xen-devel. Since that's not a Linux question, I'll start another thread on xen-devel with a shorter cc list. > > Actually, I think for many/most profiling applications, > > just knowing a discontinuity occurred between two > > timestamps is very useful as that one specific measurement > > can be discarded. If a discontinuity is invisible, > > one clearly knows that a negative interval is bad, > > but if an interval is very small or very large, > > one never knows if it is due to a discontinuity or > > due to some other reason. > > > > This would argue for a syscall/vsyscall that can > > "return" two values: the "time" and a second > > "continuity generation" counter. >=20 > I doubt it. You should expect discontinuities in user space due to=20 > being swapped out, scheduled out, migrated to a different=20 > cpu, or your=20 > laptop lid being closed. There are no guarantees to a userspace=20 > application. Even the kernel can expect discontinuities due=20 > to SMIs. =20 > So an explicit notification about one type of discontinuity=20 > adds nothing. Good point. I'm interested in enterprise apps that have more control over the machine (and rarely suffer from laptop lid closures :-) and would intend for all discontinuities visible to a hypervisor or kernel to increment "AUX", but bare-metal- kernel-invisible discontinuities such as SMI do throw a wrench in the works. Well, all this discussion has convince me that my original proposals do make sense for enterprise apps to be virtualization-aware and use rdtsc/p directly for timestamping needs rather than OS APIs (with the hypervisor deciding whether or not to emulate rdtsc/p based on the underlying physical machine and whether or not migration is enabled or has occurred).