Re: [PATCH] perf/x86: Disable uncore on virtualized CPU.

From: Andi Kleen
Date: Wed Sep 05 2012 - 14:52:27 EST


On Wed, Sep 05, 2012 at 08:35:24AM +0200, Ingo Molnar wrote:
>
> * Yan, Zheng <zheng.z.yan@xxxxxxxxx> wrote:
>
> > From: "Yan, Zheng" <zheng.z.yan@xxxxxxxxx>
> >
> > Initializing uncore PMU on virtualized CPU may hang the kernel.
> > This is because kvm does not emulate the entire hardware. Thers
> > are lots of uncore related MSRs, making kvm enumerate them all
> > is a non-trival task. So just disable uncore on virtualized CPU.
> >
> > Signed-off-by: Yan, Zheng <zheng.z.yan@xxxxxxxxx>
> > ---
> > arch/x86/kernel/cpu/perf_event_intel_uncore.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
> > index 0a55710..2f005ba 100644
> > --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
> > +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
> > @@ -2898,6 +2898,9 @@ static int __init intel_uncore_init(void)
> > if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
> > return -ENODEV;
> >
> > + if (cpu_has_hypervisor)
> > + return -ENODEV;
> > +
> > ret = uncore_pci_init();
> > if (ret)
> > goto fail;
>
> Cannot the presence of the uncore hardware be detected in a
> cleaner fashion, via the PCI config space and such?

Probably just by reading the registers and see that they are 0 and
when writing read back and check.

And the code should not hang when that happens, then this check wouldn't
be needed.

-Andi
--
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/