[PATCH] perf, amd: Fix rdpmc index calculation for AMD family 15h

From: Robert Richter
Date: Fri Jun 15 2012 - 13:43:23 EST


On 06.06.12 09:17:02, tip-bot for Vince Weaver wrote:
> Commit-ID: c48b60538c3ba05a7a2713c4791b25405525431b
> Gitweb: http://git.kernel.org/tip/c48b60538c3ba05a7a2713c4791b25405525431b
> Author: Vince Weaver <vweaver1@xxxxxxxxxxxx>
> AuthorDate: Thu, 1 Mar 2012 17:28:14 -0500
> Committer: Ingo Molnar <mingo@xxxxxxxxxx>
> CommitDate: Wed, 6 Jun 2012 17:23:35 +0200
>
> perf/x86: Use rdpmc() rather than rdmsr() when possible in the kernel
>
> The rdpmc instruction is faster than the equivelant rdmsr call,
> so use it when possible in the kernel.
>
> The perfctr kernel patches did this, after extensive testing showed
> rdpmc to always be faster (One can look in etc/costs in the perfctr-2.6
> package to see a historical list of the overhead).
>
> I have done some tests on a 3.2 kernel, the kernel module I used
> was included in the first posting of this patch:
>
> rdmsr rdpmc
> Core2 T9900: 203.9 cycles 30.9 cycles
> AMD fam0fh: 56.2 cycles 9.8 cycles
> Atom 6/28/2: 129.7 cycles 50.6 cycles
>
> The speedup of using rdpmc is large.
>
> [ It's probably possible (and desirable) to do this without
> requiring a new field in the hw_perf_event structure, but
> the fixed events make this tricky. ]
>
> Signed-off-by: Vince Weaver <vweaver1@xxxxxxxxxxxx>
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
> Link: http://lkml.kernel.org/r/alpine.DEB.2.00.1203011724030.26934@xxxxxxxxxxxxxxxxxx
> Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
> ---
> arch/x86/kernel/cpu/perf_event.c | 4 +++-
> include/linux/perf_event.h | 1 +
> 2 files changed, 4 insertions(+), 1 deletions(-)

This crashs on AMD family 15h. Fix below.

-Robert