• Zachary Amsden's avatar
    KVM: Kill the confusing tsc_ref_khz and ref_freq variables · 0cca7907
    Zachary Amsden authored
    They are globals, not clearly protected by any ordering or locking, and
    vulnerable to various startup races.
    
    Instead, for variable TSC machines, register the cpufreq notifier and get
    the TSC frequency directly from the cpufreq machinery.  Not only is it
    always right, it is also perfectly accurate, as no error prone measurement
    is required.
    
    On such machines, when a new CPU online is brought online, it isn't clear what
    frequency it will start with, and it may not correspond to the reference, thus
    in hardware_enable we clear the cpu_tsc_khz variable to zero and make sure
    it is set before running on a VCPU.
    Signed-off-by: default avatarZachary Amsden <zamsden@redhat.com>
    Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
    0cca7907
x86.c 120 KB