Re: [Patch] Skip cpu_calibrate for kernel runningunder hypervisors.

From: Alok Kataria
Date: Tue Aug 17 2010 - 12:48:38 EST


Hi HPA,

On Mon, 2010-08-16 at 23:30 -0700, H. Peter Anvin wrote:
> On 08/16/2010 10:51 PM, Alok Kataria wrote:
> >>
> >> I'm somewhat reluctant to take this one, since it assumes all the
> >> hypervisors act the same. This seems rather inherently wrong. In fact,
> >> the whole statement is fishy as heck... instead of being dependent on
> >> AMD and so on,
> >
> > The check about being on AMD is something that was already there.
> >
>
> I know it was... and calibrate_cpu() seems to be an AMD-specific
> function, but that's rather crappy. I'm thinking that perhaps we should
> make it an x86_init function, then the AMD CPU detection can install it
> and the vmware hypervisor detection can uninstall it.

I am planning to add a calibrate_apic function ptr in x86_platform_ops,
for getting the APIC frequency too directly from the hypervisor. If you
want I can add this calibrate_cpu function ptr too or is the patch below
okay for now ?

Thanks,
Alok

>
> >> this should either be a function pointer or a CPU
> >> (mis)feature bit.
> >
> > In any case, I agree that my previous patch did assume all hypervisors
> > to be same, which might be wrong. How about using the
> > X86_FEATURE_TSC_RELIABLE bit for this too ? i.e. Skip cpu_calibrate call
> > if TSC_RELIABLE bit is set. As of now that bit is set for vmware only.
> >
> > Something like the below.
> >
> > Signed-off-by: Alok N Kataria <akataria@xxxxxxxxxx>
> > Cc: H. Peter Anvin <hpa@xxxxxxxxx>
> >
> > 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-16 21:59:32.000000000 -0700
> > @@ -927,7 +927,8 @@ 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) &&
> > + !(cpu_has(&boot_cpu_data, X86_FEATURE_TSC_RELIABLE)))
> > cpu_khz = calibrate_cpu();
> >
> > printk("Detected %lu.%03lu MHz processor.\n",
> >
>
> That seems like a much better approach.
>
> -hpa
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/