[Patch] Skip cpu_calibrate for kernel running under hypervisors.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Alok Kataria
Date: Monday, August 16, 2010 - 12:25 pm

Hi, 

This is a trivial change to fix the cpu_khz value returned when running
on a virtualized environment. We have seen instances when the cpu_khz
value is off by couple of MHz's when running on VMware's platform on AMD
hardware.

--
Since the TSC frequency read from hypervisor is accurate for the guest, and
since the hypervisor will always clock the vcpu at the TSC frequency, there is
no need to calibrate it again. To avoid any calibration errors through
calibrate_cpu this patch skips calling calibrate_cpu for kernel running
under hypervisors.

Signed-off-by: Alok N Kataria <akataria@vmware.com>
Cc: K. Y. Srinivasan <ksrinivasan@novell.com>
Cc: Greg KH <greg@kroah.com>
Cc: H. Peter Anvin <hpa@zytor.com>

Index: linux-x86-tree.git/arch/x86/kernel/tsc.c
===================================================================
--- linux-x86-tree.git.orig/arch/x86/kernel/tsc.c	2010-08-03 12:21:20.000000000 -0700
+++ linux-x86-tree.git/arch/x86/kernel/tsc.c	2010-08-13 15:07:08.000000000 -0700
@@ -927,7 +927,7 @@ void __init tsc_init(void)
 	}
 
 	if (cpu_has(&boot_cpu_data, X86_FEATURE_CONSTANT_TSC) &&
-			(boot_cpu_data.x86_vendor == X86_VENDOR_AMD))
+	    (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) && !x86_hyper)
 		cpu_khz = calibrate_cpu();
 
 	printk("Detected %lu.%03lu MHz processor.\n",


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[Patch] Skip cpu_calibrate for kernel running under hyperv ..., Alok Kataria, (Mon Aug 16, 12:25 pm)
[PATCH] x86, tsc: Limit CPU frequency calibration on AMD, Borislav Petkov, (Wed Aug 18, 9:16 am)
Re: [PATCH] x86, tsc: Limit CPU frequency calibration on AMD, Borislav Petkov, (Wed Aug 18, 10:34 am)
Re: [PATCH] x86, tsc: Limit CPU frequency calibration on AMD, H. Peter Anvin, (Wed Aug 18, 10:44 am)
Re: [PATCH] x86, tsc: Limit CPU frequency calibration on AMD, Borislav Petkov, (Wed Aug 18, 11:45 am)
Re: [PATCH] x86, tsc: Limit CPU frequency calibration on AMD, Borislav Petkov, (Thu Aug 19, 1:29 pm)
[PATCH -v2] x86, tsc: Limit CPU frequency calibration on AMD, Borislav Petkov, (Tue Aug 24, 8:53 am)
Re: [PATCH -v2] x86, tsc: Limit CPU frequency calibration ..., Borislav Petkov, (Wed Aug 25, 12:06 am)
Re: [PATCH -v2] x86, tsc: Limit CPU frequency calibration ..., Andreas Herrmann, (Wed Aug 25, 6:04 am)
Re: [PATCH -v2] x86, tsc: Limit CPU frequency calibration ..., Andreas Herrmann, (Wed Aug 25, 6:39 am)
[tip:x86/cpu] x86, tsc: Remove CPU frequency calibration o ..., tip-bot for Borislav ..., (Wed Aug 25, 2:36 pm)