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]
Date:	Thu, 27 Sep 2012 21:31:10 -0700
From:	Andi Kleen <andi@...stfloor.org>
To:	linux-kernel@...r.kernel.org
Cc:	x86@...nel.org, a.p.zijlstra@...llo.nl, eranian@...gle.com,
	acme@...hat.com, Andi Kleen <ak@...ux.intel.com>
Subject: [PATCH 05/31] perf, tools: Add :c,:t event modifiers in perf tools

From: Andi Kleen <ak@...ux.intel.com>

Haswell supports new per event qualifiers for TSX transactions and
checkpointed transaction qualifiers that can be used to compute the
events discarded due to aborts.

Implement it in the usertool as :t and :c

Signed-off-by: Andi Kleen <ak@...ux.intel.com>
---
 tools/perf/Documentation/perf-list.txt |    6 ++++++
 tools/perf/util/evsel.c                |   14 ++++++++++++--
 tools/perf/util/parse-events.c         |    7 +++++++
 tools/perf/util/parse-events.l         |    2 +-
 4 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/tools/perf/Documentation/perf-list.txt b/tools/perf/Documentation/perf-list.txt
index ddc2252..52ea166 100644
--- a/tools/perf/Documentation/perf-list.txt
+++ b/tools/perf/Documentation/perf-list.txt
@@ -34,6 +34,12 @@ Intel PEBS and can be specified multiple times:
 
 The PEBS implementation now supports up to 2.
 
+On Intel Haswell CPUs t and c can be specified to request that the event
+is only counted inside transactions ('t') or that the counter is rolled
+back to the beginning of the transaction on a abort ('c'). This can
+be used to account for transaction residency and cycles lost to transaction
+aborts.
+
 RAW HARDWARE EVENT DESCRIPTOR
 -----------------------------
 Even when an event is not available in a symbolic form within perf right now,
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 2eaae14..cda3805 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -93,11 +93,12 @@ static int perf_evsel__add_modifiers(struct perf_evsel *evsel, char *bf, size_t
 	struct perf_event_attr *attr = &evsel->attr;
 	bool exclude_guest_default = false;
 
-#define MOD_PRINT(context, mod)	do {					\
-		if (!attr->exclude_##context) {				\
+#define __MOD_PRINT(test, mod)	do {				\
+		if (test) {					\
 			if (!colon) colon = ++r;			\
 			r += scnprintf(bf + r, size - r, "%c", mod);	\
 		} } while(0)
+#define MOD_PRINT(context, mod) __MOD_PRINT(!attr->exclude_##context, mod)
 
 	if (attr->exclude_kernel || attr->exclude_user || attr->exclude_hv) {
 		MOD_PRINT(kernel, 'k');
@@ -113,11 +114,20 @@ static int perf_evsel__add_modifiers(struct perf_evsel *evsel, char *bf, size_t
 		exclude_guest_default = true;
 	}
 
+	if (attr->intx || attr->intx_checkpointed) {
+		__MOD_PRINT(attr->intx_checkpointed, 'c');
+		__MOD_PRINT(attr->intx, 't');
+		/* Set the bizarro flag: */
+		exclude_guest_default = true;
+	}
+
 	if (attr->exclude_host || attr->exclude_guest == exclude_guest_default) {
 		MOD_PRINT(host, 'H');
 		MOD_PRINT(guest, 'G');
 	}
+
 #undef MOD_PRINT
+#undef __MOD_PRINT
 	if (colon)
 		bf[colon - 1] = ':';
 	return r;
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 74a5af4..5668ca6 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -628,6 +628,7 @@ int parse_events_modifier(struct list_head *list, char *str)
 	struct perf_evsel *evsel;
 	int exclude = 0, exclude_GH = 0;
 	int eu = 0, ek = 0, eh = 0, eH = 0, eG = 0, precise = 0;
+	int intx = 0, intx_cp = 0;
 
 	if (str == NULL)
 		return 0;
@@ -655,6 +656,10 @@ int parse_events_modifier(struct list_head *list, char *str)
 			eH = 0;
 		} else if (*str == 'p') {
 			precise++;
+		} else if (*str == 't') {
+			intx = 1;
+		} else if (*str == 'c') {
+			intx_cp = 1;
 		} else
 			break;
 
@@ -681,6 +686,8 @@ int parse_events_modifier(struct list_head *list, char *str)
 		evsel->attr.precise_ip     = precise;
 		evsel->attr.exclude_host   = eH;
 		evsel->attr.exclude_guest  = eG;
+		evsel->attr.intx_checkpointed = intx_cp;
+		evsel->attr.intx	     = intx;
 	}
 
 	return 0;
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index 384ca74..96ab100 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -75,7 +75,7 @@ num_dec		[0-9]+
 num_hex		0x[a-fA-F0-9]+
 num_raw_hex	[a-fA-F0-9]+
 name		[a-zA-Z_*?][a-zA-Z0-9_*?]*
-modifier_event	[ukhpGH]{1,8}
+modifier_event	[ukhpGHct]+
 modifier_bp	[rwx]{1,3}
 
 %%
-- 
1.7.7.6

--
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