lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1278080613.1917.258.camel@laptop>
Date:	Fri, 02 Jul 2010 16:23:33 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Vince Weaver <vweaver1@...s.utk.edu>
Cc:	Ingo Molnar <mingo@...e.hu>, LKML <linux-kernel@...r.kernel.org>,
	Paul Mackerras <paulus@...ba.org>,
	Arnaldo Carvalho de Melo <acme@...hat.com>
Subject: Re: [PATCH] perf wrong branches event on AMD

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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ