]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
x86: paravirt: factor out cpu_khz to common code
authorGlauber Costa <gcosta@redhat.com>
Mon, 28 Jul 2008 14:47:52 +0000 (11:47 -0300)
committerAvi Kivity <avi@qumranet.com>
Wed, 15 Oct 2008 08:15:17 +0000 (10:15 +0200)
KVM intends to use paravirt code to calibrate khz. Xen
current code will do just fine. So as a first step, factor out
code to pvclock.c.

Signed-off-by: Glauber Costa <gcosta@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
arch/x86/kernel/pvclock.c
arch/x86/xen/time.c
include/asm-x86/pvclock.h

index 05fbe9a0325a513c81fed8359a3bc259bce54edc..1c54b5fb7aedb43b129651c3cbab8157fbe595f2 100644 (file)
@@ -97,6 +97,18 @@ static unsigned pvclock_get_time_values(struct pvclock_shadow_time *dst,
        return dst->version;
 }
 
+unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
+{
+       u64 tsc_khz = 1000000ULL << 32;
+
+       do_div(tsc_khz, src->tsc_to_system_mul);
+       if (src->tsc_shift < 0)
+               tsc_khz <<= -src->tsc_shift;
+       else
+               tsc_khz >>= src->tsc_shift;
+       return tsc_khz;
+}
+
 cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
 {
        struct pvclock_shadow_time shadow;
index 004ba86326ae022eb1b9d60a926a9adc6f207582..c9f7cda48ed78ecbe1b421c540bbe2b777681400 100644 (file)
@@ -198,17 +198,10 @@ unsigned long long xen_sched_clock(void)
 /* Get the TSC speed from Xen */
 unsigned long xen_tsc_khz(void)
 {
-       u64 xen_khz = 1000000ULL << 32;
-       const struct pvclock_vcpu_time_info *info =
+       struct pvclock_vcpu_time_info *info =
                &HYPERVISOR_shared_info->vcpu_info[0].time;
 
-       do_div(xen_khz, info->tsc_to_system_mul);
-       if (info->tsc_shift < 0)
-               xen_khz <<= -info->tsc_shift;
-       else
-               xen_khz >>= info->tsc_shift;
-
-       return xen_khz;
+       return pvclock_tsc_khz(info);
 }
 
 cycle_t xen_clocksource_read(void)
index 1a38f68348007a64dfabf488dd623bef2a463f42..ad29e277fd6d6dd9d114e33b6113c42d03bf5d2c 100644 (file)
@@ -6,6 +6,7 @@
 
 /* some helper functions for xen and kvm pv clock sources */
 cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src);
+unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src);
 void pvclock_read_wallclock(struct pvclock_wall_clock *wall,
                            struct pvclock_vcpu_time_info *vcpu,
                            struct timespec *ts);