From: Dan Magenheimer Subject: RE: [PATCH 3/5] x86/pvclock: add vsyscall implementation Date: Tue, 6 Oct 2009 07:19:51 -0700 (PDT) Message-ID: <711a958d-5a76-4f00-aa69-8e5889945992@default> References: <4ACB0833.2050203@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=Windows-1252 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <4ACB0833.2050203@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 , Jeremy Fitzhardinge Cc: Xen-devel , kurt.hackel@oracle.com, the arch/x86 maintainers , Linux Kernel Mailing List , Glauber de Oliveira Costa , Keir Fraser , zach.brown@oracle.com, chris.mason@oracle.com List-Id: xen-devel@lists.xenproject.org > From: Jeremy Fitzhardinge [mailto:jeremy.fitzhardinge@citrix.com] > With this in place, I can do a gettimeofday in about 100ns on a 2.4GHz > Q6600. I'm sure this could be tuned a bit more, but it is=20 > already much better than a syscall. To evaluate the goodness of this, we really need a full set of measurements for: a) cost of rdtsc (and rdtscp if different) b) cost of vsyscall+pvclock c) cost of rdtsc emulated d) cost of a hypercall that returns "hypervisor system time" On a E6850 (3Ghz but let's use cycles), I measured; a =3D=3D 72 cycles c =3D=3D 1080 cycles d =3D=3D 780 cycles It may be partly apples and oranges, but it looks like a good guess for b on my machine is b =3D=3D 240 cycles Not bad, but is there any additional context switch cost to support it? > From: Avi Kivity [mailto:avi@redhat.com] > Instead of using vgetcpu() and rdtsc() independently, you can=20 > use rdtscp=20 > to read both atomically. This removes the need for the=20 > preempt notifier. Xen does not currently expose rdtscp and so does not emulate (or context switch) TSC_AUX. Context switching TSC_AUX is certainly possible, but will likely be expensive. If the primary reason for vsyscall+pvclock is to maximize performance for gettimeofday/clock_gettime, this cost would need to be added to the mix. > preempt notifiers are per-thread, not global, and will upset=20 > the cycle=20 > counters. I'd drop them and use rdtscp instead (and give up if the=20 > processor doesn't support it). Even if rdtscp is used, in the Intel processor lineup only the very latest (Nehalem) supports rdtscp, so "give up" doesn't seem like a very good option, at least in the near future.