2012-08-21 09:09:04

by Yan, Zheng

[permalink] [raw]
Subject: [PATCH] perf/x86: Disable uncore on virtualized CPU.

From: "Yan, Zheng" <[email protected]>

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 <[email protected]>
---
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;
--
1.7.11.2


2012-08-21 12:55:25

by Pekka Enberg

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

On Tue, Aug 21, 2012 at 12:08 PM, Yan, Zheng <[email protected]> wrote:
> From: "Yan, Zheng" <[email protected]>
>
> 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 <[email protected]>
> ---
> 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;

Tested-by: Pekka Enberg <[email protected]>

2012-08-21 14:31:24

by Andi Kleen

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

On Tue, Aug 21, 2012 at 05:08:37PM +0800, Yan, Zheng wrote:
> From: "Yan, Zheng" <[email protected]>
>
> 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.

I'm not sure cpu_has_hypervisor is reliable enough for this.
Better find out why it hangs and fix that.

Early rdmsrls should be rdmsrl_safe()
Early writes in the driver should check if anything was written,
and if not then disable itself.

-Andi

2012-08-21 14:42:11

by Pekka Enberg

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

On Tue, Aug 21, 2012 at 05:08:37PM +0800, Yan, Zheng wrote:
>> From: "Yan, Zheng" <[email protected]>
>>
>> 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.

On Tue, Aug 21, 2012 at 5:31 PM, Andi Kleen <[email protected]> wrote:
> I'm not sure cpu_has_hypervisor is reliable enough for this.
> Better find out why it hangs and fix that.
>
> Early rdmsrls should be rdmsrl_safe()
> Early writes in the driver should check if anything was written,
> and if not then disable itself.

It's unfortunate that the changelog does not include any reference to
the actual thread this was discussed in:

http://www.mail-archive.com/[email protected]/msg77524.html

2012-08-31 07:12:27

by Pekka Enberg

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

On Tue, Aug 21, 2012 at 12:08 PM, Yan, Zheng <[email protected]> wrote:
>> From: "Yan, Zheng" <[email protected]>
>>
>> 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 <[email protected]>
>> ---
>> 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;

On Tue, Aug 21, 2012 at 3:55 PM, Pekka Enberg <[email protected]> wrote:
> Tested-by: Pekka Enberg <[email protected]>

Ping? I have not seen a tip bot email for this. Is the patch queued?

2012-10-20 08:24:20

by Yan, Zheng

[permalink] [raw]
Subject: [tip:perf/urgent] perf/x86: Disable uncore on virtualized CPUs

Commit-ID: a05123bdd1b9ba961ed262864924a5b3ee81afe8
Gitweb: http://git.kernel.org/tip/a05123bdd1b9ba961ed262864924a5b3ee81afe8
Author: Yan, Zheng <[email protected]>
AuthorDate: Tue, 21 Aug 2012 17:08:37 +0800
Committer: Ingo Molnar <[email protected]>
CommitDate: Sat, 20 Oct 2012 10:07:02 +0200

perf/x86: Disable uncore on virtualized CPUs

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 <[email protected]>
Tested-by: Pekka Enberg <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
arch/x86/kernel/cpu/perf_event_intel_uncore.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index 99d96a4..5df8d32 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -2926,6 +2926,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;