Re: [tip:perfcounters/core] perf_counter, x86: remove X86_FEATURE_ARCH_PERFMON flag for AMD cpus

Jaswinder Singh Rajput
2009-05-11T12:16:00Z

On Sun, 2009-05-10 at 08:30 +0200, Ingo Molnar wrote:
> * Jaswinder Singh Rajput <jaswinder@kernel.org> wrote:
>
> > > #define X86_FEATURE_ARCH_PERFMON (3*32+11) /* Intel Architectural PerfMon */
> > > should be replaced by
> > > #define X86_FEATURE_ARCH_PERFMON (3*32+11) /* Performace Monitor */
> > >
> > > All x86 cpus which support performance monitor should set this feature.
> > >
> >
> > Currently X86_FEATURE_ARCH_PERFMON is enabled for >= Intel Core2
> >
> > But Performance monitor is almost supported by all Intel
> > processors. I am adding few MSRs list for reference to see
> > complete list please check arch/x86/kernel/cpu/cpu_debug.c
>
> I think you are confusing two things:
>
> - The 'architectural perfmon' CPU flag, enumerated in CPUID. (this
> is a relatively new CPUID flag that only Intel CPUs at around
> Core2 and later will report.)
>
> - The concept of 'performance monitoring' - which has been present
> in various x86 CPUs starting at the original Pentium (P5) 15 years
> ago or so.
>

Here is the patch for review for ancient performance monitoring
cpufeature, complete cpu_debug and cpu_feature patches are available
at :
http://git.kernel.org/?p=linux/kernel/git/jaswinder/linux-2.6-tip.git;a=summary

Subject: [PATCH] x86: Add cpufeature for ancient performance monitoring

X86_FEATURE_ARCH_PERFMON uses almost different MSRs as compare to
ancient performance monitoring, so introduced X86_FEATURE_PERFMON
to friendly access ancient performance monitor MSRs:

X86_FEATURE_PERFMON : performance monitoring for !X86_FEATURE_ARCH_PERFMON

Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
---
arch/x86/include/asm/cpufeature.h | 1 +
arch/x86/kernel/cpu/amd.c | 2 ++
arch/x86/kernel/cpu/intel.c | 4 +++-
3 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index 12fc758..3d5170b 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -169,6 +169,7 @@
#define X86_FEATURE_MM_CFG (7*32+ 14) /* MM configuration */
#define X86_FEATURE_BUS_CFG (7*32+ 15) /* Bus configuration */
#define X86_FEATURE_PERF_FREQ (7*32+ 16) /* Performance frequency */
+#define X86_FEATURE_PERFMON (7*32+ 17) /* Performance monitoring */

/* Virtualization flags: Linux defined */
#define X86_FEATURE_TPR_SHADOW (8*32+ 0) /* Intel TPR Shadow */
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 4b7f7dc..849d794 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -481,6 +481,8 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
if (c->x86 >= 7) { /* K7+ */
/* MSRC001_0015 Hardware Configuration Register (HWCR) */
set_cpu_cap(c, X86_FEATURE_HW_CFG);
+ /* Performance monitoring support */
+ set_cpu_cap(c, X86_FEATURE_PERFMON);
}
if (c->x86 >= 8) { /* K8+ */
/*
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 33ad800..c2f16b9 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -333,7 +333,9 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
/* Check for version and the number of counters */
if ((eax & 0xff) && (((eax>>8) & 0xff) > 1))
set_cpu_cap(c, X86_FEATURE_ARCH_PERFMON);
- }
+ } else if (c->x86 >= 5)
+ /* ancient performance monitoring support */
+ set_cpu_cap(c, X86_FEATURE_PERFMON);

if (cpu_has_xmm2)
set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
--
1.6.0.6