[lkml]   [2010]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subject[Patch] Skip cpu_calibrate for kernel running under hypervisors.

    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

    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 <>
    Cc: K. Y. Srinivasan <>
    Cc: Greg KH <>
    Cc: H. Peter Anvin <>

    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",

     \ /
      Last update: 2010-08-16 21:29    [W:0.038 / U:16.624 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site