]> git.karo-electronics.de Git - linux-beck.git/commitdiff
x86, paravirt: don't compute pvclock adjustments if we trust the tsc
authorGlauber Costa <glommer@redhat.com>
Tue, 11 May 2010 16:17:45 +0000 (12:17 -0400)
committerAvi Kivity <avi@redhat.com>
Wed, 19 May 2010 08:41:05 +0000 (11:41 +0300)
If the HV told us we can fully trust the TSC, skip any
correction

Signed-off-by: Glauber Costa <glommer@redhat.com>
Acked-by: Zachary Amsden <zamsden@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/include/asm/kvm_para.h
arch/x86/include/asm/pvclock-abi.h
arch/x86/kernel/kvmclock.c
arch/x86/kernel/pvclock.c

index f019f8cb182ebeb25c1b4688cf6237e57f4417eb..05eba5e9a8e8e59372ddc615e630a8a21f155f37 100644 (file)
  */
 #define KVM_FEATURE_CLOCKSOURCE2        3
 
+/* The last 8 bits are used to indicate how to interpret the flags field
+ * in pvclock structure. If no bits are set, all flags are ignored.
+ */
+#define KVM_FEATURE_CLOCKSOURCE_STABLE_BIT     24
+
 #define MSR_KVM_WALL_CLOCK  0x11
 #define MSR_KVM_SYSTEM_TIME 0x12
 
index ec5c41ac4befec204ceef3ca0b825f7546de5b74..35f2d1948adad8bebad28a5dc06b328454dc6ace 100644 (file)
@@ -39,5 +39,6 @@ struct pvclock_wall_clock {
        u32   nsec;
 } __attribute__((__packed__));
 
+#define PVCLOCK_TSC_STABLE_BIT (1 << 0)
 #endif /* __ASSEMBLY__ */
 #endif /* _ASM_X86_PVCLOCK_ABI_H */
index 59c740fcb9b3e7e3e1f8ef77d9ccd4f42ce212a8..eb9b76c716c2277d147f2a3b4ad12456ec57dfb6 100644 (file)
@@ -215,4 +215,7 @@ void __init kvmclock_init(void)
        clocksource_register(&kvm_clock);
        pv_info.paravirt_enabled = 1;
        pv_info.name = "KVM";
+
+       if (kvm_para_has_feature(KVM_FEATURE_CLOCKSOURCE_STABLE_BIT))
+               pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT);
 }
index f5bc40e1697e0bd366e3b2552f2212665be43ed8..239427ca02af05f8671aacaf9820aa298e94bff1 100644 (file)
@@ -135,6 +135,10 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
                barrier();
        } while (version != src->version);
 
+       if ((valid_flags & PVCLOCK_TSC_STABLE_BIT) &&
+               (shadow.flags & PVCLOCK_TSC_STABLE_BIT))
+               return ret;
+
        /*
         * Assumption here is that last_value, a global accumulator, always goes
         * forward. If we are less than that, we should not be much smaller.