Subject: Re: [PATCH] oprofile: don't set counter width from cpuid on core2

On 19.02.09 17:34:03, Tim Blechmann wrote:
> resetting the counter width of the performance counters on intel's
> core2, breaks the delivery of NMIs, when running in x86_64 mode.
>
> this should fix bug #12395:
> http://bugzilla.kernel.org/show_bug.cgi?id=12395

Applied to oprofile/fixes. Thanks Tim.

Ingo, please pull from

git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git fixes

for v2.6.29-rc7.

Thanks,

-Robert

--
Advanced Micro Devices, Inc.
Operating System Research Center
email: [email protected]


2009-03-03 11:06:10

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH] oprofile: don't set counter width from cpuid on core2


* Robert Richter <[email protected]> wrote:

> On 19.02.09 17:34:03, Tim Blechmann wrote:
> > resetting the counter width of the performance counters on intel's
> > core2, breaks the delivery of NMIs, when running in x86_64 mode.
> >
> > this should fix bug #12395:
> > http://bugzilla.kernel.org/show_bug.cgi?id=12395
>
> Applied to oprofile/fixes. Thanks Tim.
>
> Ingo, please pull from
>
> git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git fixes
>
> for v2.6.29-rc7.

Pulled, thanks a lot Robert!

Note: i amended the commit to add a tag for the .28 backport
[this fix is .28.x relevant] and to fix a few small details
(removed the goto, etc.).

Ingo

2009-03-03 11:10:41

by Tim Blechmann

[permalink] [raw]
Subject: [tip:x86/urgent] x86: oprofile: don't set counter width from cpuid on Core2

Commit-ID: 780eef9492b16a1543a3b2ae9f9526a735fc9856
Gitweb: http://git.kernel.org/tip/780eef9492b16a1543a3b2ae9f9526a735fc9856
Author: "Tim Blechmann" <[email protected]>
AuthorDate: Thu, 19 Feb 2009 17:34:03 +0100
Commit: Ingo Molnar <[email protected]>
CommitDate: Tue, 3 Mar 2009 12:04:22 +0100

x86: oprofile: don't set counter width from cpuid on Core2

Impact: fix stuck NMIs and non-working oprofile on certain CPUs

Resetting the counter width of the performance counters on Intel's
Core2 CPUs, breaks the delivery of NMIs, when running in x86_64 mode.

This should fix bug #12395:

http://bugzilla.kernel.org/show_bug.cgi?id=12395

Signed-off-by: Tim Blechmann <[email protected]>
Signed-off-by: Robert Richter <[email protected]>
LKML-Reference: <[email protected]>
Cc: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>


---
arch/x86/oprofile/op_model_ppro.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
index e9f80c7..10131fb 100644
--- a/arch/x86/oprofile/op_model_ppro.c
+++ b/arch/x86/oprofile/op_model_ppro.c
@@ -78,8 +78,18 @@ static void ppro_setup_ctrs(struct op_msrs const * const msrs)
if (cpu_has_arch_perfmon) {
union cpuid10_eax eax;
eax.full = cpuid_eax(0xa);
- if (counter_width < eax.split.bit_width)
- counter_width = eax.split.bit_width;
+
+ /*
+ * For Core2 (family 6, model 15), don't reset the
+ * counter width:
+ */
+ if (!(eax.split.version_id == 0 &&
+ current_cpu_data.x86 == 6 &&
+ current_cpu_data.x86_model == 15)) {
+
+ if (counter_width < eax.split.bit_width)
+ counter_width = eax.split.bit_width;
+ }
}

/* clear all counters */