Re: [patch] kvmclock fix

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +static unsigned int  ref_freq;
> +static unsigned long loops_per_jiffy_ref;
> +static unsigned long tsc_khz_ref;

Doesn't these need to be percpu too ?

Otherwise we could be calculating the new frequency based on a foreign
reference.

> +
> +static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
> +                                    void *data)
> +{
> +       struct cpufreq_freqs *freq = data;
> +       unsigned long *lpj, dummy;
> +       struct kvm *kvm;
> +       struct kvm_vcpu *vcpu;
> +       int i, guest_mode;
> +
> +       if (cpu_has(&cpu_data(freq->cpu), X86_FEATURE_CONSTANT_TSC))
> +               return 0;
> +
> +       lpj = &dummy;
> +        if (!(freq->flags & CPUFREQ_CONST_LOOPS))
> +#ifdef CONFIG_SMP
> +               lpj = &cpu_data(freq->cpu).loops_per_jiffy;
> +#else
> +               lpj = &boot_cpu_data.loops_per_jiffy;
> +#endif
> +
> +        if (!ref_freq) {
> +               ref_freq = freq->old;
> +               loops_per_jiffy_ref = *lpj;
> +               tsc_khz_ref = tsc_khz;
> +        }
> +
> +       if ((val == CPUFREQ_PRECHANGE  && freq->old < freq->new) ||
> +           (val == CPUFREQ_POSTCHANGE && freq->old > freq->new) ||
> +           (val == CPUFREQ_RESUMECHANGE)) {
> +               *lpj =  cpufreq_scale(loops_per_jiffy_ref, ref_freq, freq->new);
> +               per_cpu(cpu_tsc_khz, freq->cpu) = cpufreq_scale(tsc_khz_ref, ref_freq, freq->new);

I believe a possible approach is to move those that refer to tsc
calculation to tsc.c, and make all uses
of tsc_khz comply to a per_cpu use. A global tsc_khz does not make sense anyway.

Then we'll have a specific kvm notifier that just forces the guest out
of its execution so we can update
the clock state.


-- 
Glauber  Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux