diff mbox

[RFC:,tsc,virtualization,11/20] Use highest TSC frequency as reference clock

Message ID 1260850127-9766-12-git-send-email-zamsden@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Zachary Amsden Dec. 15, 2009, 4:08 a.m. UTC
None
diff mbox

Patch

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 520ea6a..3c4266f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3701,7 +3701,15 @@  static void kvm_timer_init(void)
 	 * can change at any time.
 	 */
 	register_cpu_notifier(&kvm_x86_cpu_notifier);
+	ref_tsc_khz = tsc_khz;
 	if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) {
+#ifdef CONFIG_CPU_FREQ
+		struct cpufreq_policy policy;
+
+		cpufreq_get_policy(&policy, get_cpu());
+		ref_tsc_khz = policy.cpuinfo.max_freq;
+		put_cpu();
+#endif
 		cpufreq_register_notifier(&kvmclock_cpufreq_notifier_block,
 					  CPUFREQ_TRANSITION_NOTIFIER);
 		for_each_online_cpu(cpu) {
@@ -3718,7 +3726,6 @@  static void kvm_timer_init(void)
 			per_cpu(cpu_tsc_khz, cpu) = tsc_khz;
 	}
 	tsc_base_cpu = get_cpu();
-	ref_tsc_khz = per_cpu(cpu_tsc_khz, tsc_base_cpu);
 	resync(NULL);
 	put_cpu();
 }