[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 07/12] pvclock: there's no need to copy time_info into shadow



We can use the vcpu_time_info as-is, without needing to copy it.  We just
need to grab a copy of the version number before starting, then we can
compute the time using the time_info directly.  If things changed under
our feet, then we just go back and do the whole thing again.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
Cc: Avi Kivity <avi@xxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Glauber Costa <gcosta@xxxxxxxxxx>
Cc: Gerd Hoffmann <kraxel@xxxxxxxxxx>
---
 arch/x86/kernel/pvclock.c |   47 +++++---------------------------------------
 1 files changed, 6 insertions(+), 41 deletions(-)

diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
index 963f349..e43cd78 100644
--- a/arch/x86/kernel/pvclock.c
+++ b/arch/x86/kernel/pvclock.c
@@ -20,20 +20,6 @@
 #include <asm/pvclock.h>
 
 /*
- * These are perodically updated
- *    xen: magic shared_info page
- *    kvm: gpa registered via msr
- * and then copied here.
- */
-struct pvclock_shadow_time {
-       u64 tsc_timestamp;     /* TSC at last update of time vals.  */
-       u64 system_timestamp;  /* Time, in nanosecs, since boot.    */
-       u32 tsc_to_nsec_mul;
-       int tsc_shift;
-       u32 version;
-};
-
-/*
  * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction,
  * yielding a 64-bit result.
  */
@@ -71,30 +57,10 @@ static inline u64 scale_delta(u64 delta, u32 mul_frac, int 
shift)
        return product;
 }
 
-static u64 pvclock_get_nsec_offset(struct pvclock_shadow_time *shadow)
-{
-       u64 delta = native_read_tsc() - shadow->tsc_timestamp;
-       return scale_delta(delta, shadow->tsc_to_nsec_mul, shadow->tsc_shift);
-}
-
-/*
- * Reads a consistent set of time-base values from hypervisor,
- * into a shadow data area.
- */
-static unsigned pvclock_get_time_values(struct pvclock_shadow_time *dst,
-                                       struct pvclock_vcpu_time_info *src)
+static u64 pvclock_get_nsec_offset(const struct pvclock_vcpu_time_info *src)
 {
-       do {
-               dst->version = src->version;
-               rmb();          /* fetch version before data */
-               dst->tsc_timestamp     = src->tsc_timestamp;
-               dst->system_timestamp  = src->system_time;
-               dst->tsc_to_nsec_mul   = src->tsc_to_system_mul;
-               dst->tsc_shift         = src->tsc_shift;
-               rmb();          /* test version after fetching data */
-       } while ((src->version & 1) || (dst->version != src->version));
-
-       return dst->version;
+       u64 delta = native_read_tsc() - src->tsc_timestamp;
+       return scale_delta(delta, src->tsc_to_system_mul, src->tsc_shift);
 }
 
 unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
@@ -111,15 +77,14 @@ unsigned long pvclock_tsc_khz(struct 
pvclock_vcpu_time_info *src)
 
 cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
 {
-       struct pvclock_shadow_time shadow;
        unsigned version;
        cycle_t ret, offset;
 
        do {
-               version = pvclock_get_time_values(&shadow, src);
+               version = src->version;
                rdtsc_barrier();
-               offset = pvclock_get_nsec_offset(&shadow);
-               ret = shadow.system_timestamp + offset;
+               offset = pvclock_get_nsec_offset(src);
+               ret = src->system_time + offset;
                rdtsc_barrier();
        } while (version != src->version);
 
-- 
1.6.2.5


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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.