From: Peter Zijlstra <peterz@infradead.org>
To: Vince Weaver <vweaver1@eecs.utk.edu>
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
Paul Mackerras <paulus@samba.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [PATCH] perf wrong branches event on AMD
Date: Fri, 02 Jul 2010 16:23:33 +0200 [thread overview]
Message-ID: <1278080613.1917.258.camel@laptop> (raw)
In-Reply-To: <alpine.DEB.2.00.1007020950420.29784@cl320.eecs.utk.edu>
On Fri, 2010-07-02 at 09:56 -0400, Vince Weaver wrote:
> You think I have root on this machine?
Well yeah,.. I'd not want a dev job and not have full access to the
hardware. But then, maybe I'm picky.
> In any case, yes, there's the "-r" option. Fun. I get to modify all my
> scripts to have some complicated case... "if AMD machine and if kernel is
> new enough"... how new? It gets confusing once things get backported to
> stable. As far as I know there's no way to get a kernel to spit out what
> raw events it's using for the predefined events.
You can stick the knowledge in perf if you really want to.. something
like the below, add something that parses cpuid or /proc/cpuinfo and you
should be good.
---
tools/perf/util/parse-events.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/tools/perf/util/parse-events.c
b/tools/perf/util/parse-events.c
index 4af5bd5..800f864 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -771,6 +771,22 @@ parse_event_symbols(const char **str, struct
perf_event_attr *attr)
modifier:
parse_event_modifier(str, attr);
+ if (attr->type == PERF_TYPE_HARDWARE) {
+ switch (attr->config) {
+ case PERF_COUNT_HW_BRANCH_INSTRUCTIONS:
+ attr->type = PERF_TYPE_RAW;
+ attr->config = 0x00c2;
+ break;
+ case PERF_COUNT_HW_BRANCH_MISSES:
+ attr->type = PERF_TYPE_RAW;
+ attr->config = 0x00c3;
+ break;
+
+ default:
+ break;
+ }
+ }
+
return ret;
}
> If the solution really is to use raw events in a case like this, I
> question why the predefined events are in the kernel at all. Pretty much
> anyone using the braches event on an AMD machine is going to be getting
> wrong results for all kernels between 2.6.31 and 2.6.35 and not even know
> it unless they read the kernel list.
And how would it be different if it the data table lived in userspace?
They'd still get the wrong thing unless they updated.
next prev parent reply other threads:[~2010-07-02 14:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-01 19:30 [PATCH] perf wrong branches event on AMD Vince Weaver
2010-07-01 19:54 ` Arnaldo Carvalho de Melo
2010-07-02 11:38 ` Peter Zijlstra
2010-07-02 13:56 ` Vince Weaver
2010-07-02 14:23 ` Peter Zijlstra [this message]
2010-07-02 19:52 ` Vince Weaver
2010-07-03 13:54 ` Ingo Molnar
2010-07-04 0:30 ` David Dillow
2010-07-04 9:11 ` Ingo Molnar
2010-07-03 13:58 ` [tip:perf/urgent] perf, x86: Fix incorrect branches event on AMD CPUs tip-bot for Vince Weaver
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1278080613.1917.258.camel@laptop \
--to=peterz@infradead.org \
--cc=acme@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=vweaver1@eecs.utk.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox