[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1255548516-15260-8-git-send-email-jeremy.fitzhardinge@citrix.com>
Date: Wed, 14 Oct 2009 12:28:31 -0700
From: Jeremy Fitzhardinge <jeremy.fitzhardinge@...rix.com>
To: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Cc: Xen-devel <xen-devel@...ts.xensource.com>, kurt.hackel@...cle.com,
Glauber de Oliveira Costa <gcosta@...hat.com>,
Avi Kivity <avi@...hat.com>,
the arch/x86 maintainers <x86@...nel.org>,
Chris Mason <chris.mason@...cle.com>,
Jeremy Fitzhardinge <jeremy.fitzhardinge@...rix.com>,
Ingo Molnar <mingo@...e.hu>, Gerd Hoffmann <kraxel@...hat.com>
Subject: [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@...rix.com>
Cc: Avi Kivity <avi@...hat.com>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: Glauber Costa <gcosta@...hat.com>
Cc: Gerd Hoffmann <kraxel@...hat.com>
---
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists