WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH RFC] Extending pvclock down to usermode for vsyscall

To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH RFC] Extending pvclock down to usermode for vsyscall
From: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
Date: Mon, 5 Oct 2009 17:50:06 -0700
Cc: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>, kurt.hackel@xxxxxxxxxx, the arch/x86 maintainers <x86@xxxxxxxxxx>, Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>, Glauber de Oliveira Costa <gcosta@xxxxxxxxxx>, Avi Kivity <avi@xxxxxxxxxx>, Zach Brown <zach.brown@xxxxxxxxxx>, Chris Mason <chris.mason@xxxxxxxxxx>, Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Delivery-date: Mon, 05 Oct 2009 17:51:00 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
This series implements the vread method for the clocksource, which allows
it to be used directly from usermode via vsyscall.

Most of the work is in the generic pvclock code, with a bit of
hypervisor-specific code to set things up.  Specifically, it sets up a
page which is an array of pvclock_vcpu_time_info structures indexed by
vcpu number.  The usermode code gets the current (v)cpu via vgetcpu,
gets the appropriate time info and computes system time from the tsc.
After doing all that it rechecks the version number to make things
happened consistently.  The kernel also installs a preempt notifier to
bump the version number so that usermode can tell it has had its cpu
context switched under it.

I've included the Xen implementation, but it should be simple to implement
for KVM (especially since it already has the feature I had to add to
Xen to implement this: the ability to place the pvclock_vcpu_time_info
structure at an arbitrary address).

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 already much
better than a syscall.

(There's also a couple of other little generic pvclock fixes I'll send
separately.)

Thanks,
        J

 arch/x86/Kconfig                |    4 +
 arch/x86/include/asm/fixmap.h   |   21 +++++
 arch/x86/include/asm/pvclock.h  |    6 +
 arch/x86/include/asm/vsyscall.h |    3 
 arch/x86/kernel/Makefile        |    2 
 arch/x86/kernel/pvclock.c       |  156 ++++++++++++++++++++++++++++++++++++----
 arch/x86/xen/Kconfig            |    6 +
 arch/x86/xen/mmu.c              |    3 
 arch/x86/xen/smp.c              |    2 
 arch/x86/xen/time.c             |   52 +++++++++++++
 arch/x86/xen/xen-ops.h          |    8 ++
 include/xen/interface/vcpu.h    |   41 ++++++++++
 12 files changed, 291 insertions(+), 13 deletions(-)


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel