linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: linux-kernel@vger.kernel.org
Cc: x86@kernel.org, a.p.zijlstra@chello.nl, eranian@google.com,
	acme@redhat.com, Andi Kleen <ak@linux.intel.com>
Subject: [PATCH 23/31] perf, tools: Add support for generic transaction events to perf userspace
Date: Thu, 27 Sep 2012 21:31:28 -0700	[thread overview]
Message-ID: <1348806696-31170-24-git-send-email-andi@firstfloor.org> (raw)
In-Reply-To: <1348806696-31170-1-git-send-email-andi@firstfloor.org>

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

Add the generic transaction events with aliases to the parser, lexer
and the reverse map code.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/util/evsel.c        |   40 ++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/parse-events.c |   24 ++++++++++++++++++++++++
 tools/perf/util/parse-events.l |   19 ++++++++++++++++++-
 tools/perf/util/parse-events.y |    4 ++--
 4 files changed, 84 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index ff084b0..8790069 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -288,6 +288,42 @@ static int perf_evsel__hw_cache_name(struct perf_evsel *evsel, char *bf, size_t
 	return ret + perf_evsel__add_modifiers(evsel, bf + ret, size - ret);
 }
 
+static const char *transaction_name[] = {
+ [PERF_COUNT_HW_TRANSACTION_START]  = "transaction-start",
+ [PERF_COUNT_HW_TRANSACTION_COMMIT] = "transaction-commit",
+ [PERF_COUNT_HW_TRANSACTION_ABORT]  = "transaction-abort",
+ [PERF_COUNT_HW_ELISION_START]      = "elision-start",
+ [PERF_COUNT_HW_ELISION_COMMIT]     = "elision-commit",
+ [PERF_COUNT_HW_ELISION_ABORT]      = "elision-abort",
+};
+
+static const char *transaction_reason[] = {
+ [PERF_COUNT_HW_ABORT_ALL]          = "all",
+ [PERF_COUNT_HW_ABORT_CONFLICT]     = "conflict",
+ [PERF_COUNT_HW_ABORT_CAPACITY]     = "capacity",
+};
+
+static int perf_evsel__transaction_name(struct perf_evsel *evsel, char *bf,
+					size_t size)
+{
+	u64 config = evsel->attr.config;
+	u8 name = config & 0xff, reason = (config >> 8) & 0xff;
+
+	if (name < PERF_COUNT_HW_TRANSACTION_MAX &&
+	    reason < PERF_COUNT_HW_ABORT_MAX) {
+		const char *sep = "", *rtxt = "";
+		if (name == PERF_COUNT_HW_TRANSACTION_ABORT ||
+		    name == PERF_COUNT_HW_ELISION_ABORT) {
+			sep = "-";
+			rtxt = transaction_reason[reason];
+		}
+		return scnprintf(bf, size, "%s%s%s", transaction_name[name],
+						     sep, rtxt);
+	}
+
+	return scnprintf(bf, size, "invalid-transaction");
+}
+
 static int perf_evsel__raw_name(struct perf_evsel *evsel, char *bf, size_t size)
 {
 	int ret = scnprintf(bf, size, "raw 0x%" PRIx64, evsel->attr.config);
@@ -326,6 +362,10 @@ const char *perf_evsel__name(struct perf_evsel *evsel)
 		perf_evsel__bp_name(evsel, bf, sizeof(bf));
 		break;
 
+	case PERF_TYPE_HW_TRANSACTION:
+		perf_evsel__transaction_name(evsel, bf, sizeof(bf));
+		break;
+
 	default:
 		scnprintf(bf, sizeof(bf), "%s", "unknown attr type");
 		break;
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 5668ca6..e24a490 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -110,6 +110,20 @@ static struct event_symbol event_symbols_sw[PERF_COUNT_SW_MAX] = {
 	},
 };
 
+static struct event_symbol event_symbols_txn[] = {
+	{ .symbol = "transaction-start",          .alias = "tx-start"    },
+	{ .symbol = "transaction-commit",         .alias = "tx-commit"   },
+	{ .symbol = "transaction-abort-all",      .alias = "tx-abort"    },
+	{ .symbol = "transaction-abort-capacity", .alias = "tx-capacity" },
+	{ .symbol = "transaction-abort-conflict", .alias = "tx-conflict" },
+	{ .symbol = "elision-start",              .alias = "le-start"    },
+	{ .symbol = "elision-commit",             .alias = "le-commit"   },
+	{ .symbol = "elision-abort-all",          .alias = "le-abort"    },
+	{ .symbol = "elision-abort-capacity",     .alias = "le-capacity" },
+	{ .symbol = "elision-abort-conflict",     .alias = "le-conflict" },
+
+};
+
 #define __PERF_EVENT_FIELD(config, name) \
 	((config & PERF_EVENT_##name##_MASK) >> PERF_EVENT_##name##_SHIFT)
 
@@ -232,6 +246,9 @@ const char *event_type(int type)
 	case PERF_TYPE_HW_CACHE:
 		return "hardware-cache";
 
+	case PERF_TYPE_HW_TRANSACTION:
+		return "hardware-transaction";
+
 	default:
 		break;
 	}
@@ -800,6 +817,7 @@ static const char * const event_type_descriptors[] = {
 	"Hardware cache event",
 	"Raw hardware event descriptor",
 	"Hardware breakpoint",
+	"Hardware transaction event",
 };
 
 /*
@@ -909,6 +927,9 @@ void print_events_type(u8 type)
 {
 	if (type == PERF_TYPE_SOFTWARE)
 		__print_events_type(type, event_symbols_sw, PERF_COUNT_SW_MAX);
+	else if (type == PERF_TYPE_HW_TRANSACTION)
+		__print_events_type(type, event_symbols_txn,
+				    ARRAY_SIZE(event_symbols_txn));
 	else
 		__print_events_type(type, event_symbols_hw, PERF_COUNT_HW_MAX);
 }
@@ -984,6 +1005,9 @@ void print_events(const char *event_glob)
 
 	print_hwcache_events(event_glob);
 
+	print_symbol_events(event_glob, PERF_TYPE_HW_TRANSACTION,
+			    event_symbols_txn, ARRAY_SIZE(event_symbols_txn));
+
 	if (event_glob != NULL)
 		return;
 
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index 96ab100..2c9dd04 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -56,7 +56,8 @@ static int sym(yyscan_t scanner, int type, int config)
 	YYSTYPE *yylval = parse_events_get_lval(scanner);
 
 	yylval->num = (type << 16) + config;
-	return type == PERF_TYPE_HARDWARE ? PE_VALUE_SYM_HW : PE_VALUE_SYM_SW;
+	return type == PERF_TYPE_HARDWARE || type == PERF_TYPE_HW_TRANSACTION ?
+	       PE_VALUE_SYM_HW : PE_VALUE_SYM_SW;
 }
 
 static int term(yyscan_t scanner, int type)
@@ -67,6 +68,11 @@ static int term(yyscan_t scanner, int type)
 	return PE_TERM;
 }
 
+#define txn(t)		sym(yyscanner, PERF_TYPE_HW_TRANSACTION, \
+                            PERF_COUNT_HW_##t)
+#define txn_abort(t, a) sym(yyscanner, PERF_TYPE_HW_TRANSACTION, \
+			    PERF_COUNT_HW_##t | ((PERF_COUNT_HW_ABORT_##a)<<8))
+
 %}
 
 %x mem
@@ -127,6 +133,17 @@ speculative-read|speculative-load	|
 refs|Reference|ops|access		|
 misses|miss				{ return str(yyscanner, PE_NAME_CACHE_OP_RESULT); }
 
+transaction-start|tx-start		{ return txn(TRANSACTION_START);  }
+transaction-commit|tx-commit		{ return txn(TRANSACTION_COMMIT); }
+transaction-abort-all|tx-aborts?	{ return txn_abort(TRANSACTION_ABORT, ALL); }
+transaction-abort-conflict|tx-conflict  { return txn_abort(TRANSACTION_ABORT, CONFLICT); }
+transaction-abort-capacity|tx-capacity  { return txn_abort(TRANSACTION_ABORT, CAPACITY); }
+elision-start|le-start			{ return txn(ELISION_START);  }
+elision-commit|le-commit		{ return txn(ELISION_COMMIT); }
+elision-abort-all|le-aborts?		{ return txn_abort(ELISION_ABORT, ALL); }
+elision-abort-conflict|le-conflict	{ return txn_abort(ELISION_ABORT, CONFLICT); }
+elision-abort-capacity|le-capacity	{ return txn_abort(ELISION_ABORT, CAPACITY); }
+
 	/*
 	 * These are event config hardcoded term names to be specified
 	 * within xxx/.../ syntax. So far we dont clash with other names,
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 2bc5fbf..6485eb3 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -122,7 +122,7 @@ value_sym '/' event_config '/'
 	struct parse_events_data__events *data = _data;
 	struct list_head *list = NULL;
 	int type = $1 >> 16;
-	int config = $1 & 255;
+	int config = $1 & 0xffff;
 
 	ABORT_ON(parse_events_add_numeric(&list, &data->idx,
 					  type, config, $3));
@@ -135,7 +135,7 @@ value_sym sep_slash_dc
 	struct parse_events_data__events *data = _data;
 	struct list_head *list = NULL;
 	int type = $1 >> 16;
-	int config = $1 & 255;
+	int config = $1 & 0xffff;
 
 	ABORT_ON(parse_events_add_numeric(&list, &data->idx,
 					  type, config, NULL));
-- 
1.7.7.6


  parent reply	other threads:[~2012-09-28  4:37 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-28  4:31 perf PMU support for Haswell Andi Kleen
2012-09-28  4:31 ` [PATCH 01/31] perf, x86: Add PEBSv2 record support Andi Kleen
2012-09-28  8:43   ` Peter Zijlstra
2012-09-28  8:54     ` Stephane Eranian
2012-09-28  9:28       ` Peter Zijlstra
2012-09-28 11:33         ` Stephane Eranian
2012-09-28 14:42     ` Andi Kleen
2012-09-28  4:31 ` [PATCH 02/31] perf, x86: Basic Haswell PMU support Andi Kleen
2012-09-28  9:05   ` Peter Zijlstra
2012-09-28 14:58     ` Andi Kleen
     [not found]       ` <CABPqkBQ90Crh+EpRQq0Y+xUvrj5vzrX_=SpJQyR4p8uFR_Hr=Q@mail.gmail.com>
2012-09-28 15:21         ` Peter Zijlstra
2012-09-28 15:23         ` Andi Kleen
2012-09-28  4:31 ` [PATCH 03/31] perf, x86: Basic Haswell PEBS support Andi Kleen
2012-09-28  8:50   ` Peter Zijlstra
2012-09-28  4:31 ` [PATCH 04/31] perf, core: Add generic intx/intx_checkpointed counter modifiers Andi Kleen
2012-09-28  9:02   ` Peter Zijlstra
2012-09-28 11:35     ` Stephane Eranian
2012-09-28 14:53     ` Andi Kleen
2012-09-28 15:19       ` Peter Zijlstra
2012-09-28 15:29         ` Andi Kleen
2012-09-28 15:36           ` Peter Zijlstra
2012-09-28 15:23       ` Peter Zijlstra
2012-09-28 15:37         ` Andi Kleen
2012-09-28  4:31 ` [PATCH 05/31] perf, tools: Add :c,:t event modifiers in perf tools Andi Kleen
2012-09-28  4:31 ` [PATCH 06/31] perf, tools: Add intx/intx_checkpoint to perf script and header printing Andi Kleen
2012-09-28  4:31 ` [PATCH 07/31] perf, x86: Implement the :t and :c qualifiers for Haswell Andi Kleen
2012-09-28  4:31 ` [PATCH 08/31] perf, x86: Report PEBS event in a raw format Andi Kleen
2012-09-28  8:54   ` Peter Zijlstra
2012-09-28  8:57     ` Stephane Eranian
2012-09-28  4:31 ` [PATCH 09/31] perf, kvm: Support :t and :c perf modifiers in KVM arch perfmon emulation Andi Kleen
2012-09-28  4:31 ` [PATCH 10/31] perf, x86: Support PERF_SAMPLE_ADDR on Haswell Andi Kleen
2012-09-28  4:31 ` [PATCH 11/31] perf, x86: Support Haswell v4 LBR format Andi Kleen
2012-09-28  4:31 ` [PATCH 12/31] perf, x86: Disable LBR recording for unknown LBR_FMT Andi Kleen
2012-09-28  4:31 ` [PATCH 13/31] perf, x86: Support LBR filtering by INTX/NOTX/ABORT Andi Kleen
2012-09-28  4:31 ` [PATCH 14/31] perf, tools: Add abort,notx,intx branch filter options to perf report -j Andi Kleen
2012-09-28  4:31 ` [PATCH 15/31] perf, tools: Support sorting by intx, abort branch flags Andi Kleen
2012-09-28  4:31 ` [PATCH 16/31] perf, x86: Support full width counting on Haswell Andi Kleen
2012-09-28  4:31 ` [PATCH 17/31] perf, x86: Avoid checkpointed counters causing excessive TSX aborts Andi Kleen
2012-09-28  4:31 ` [PATCH 18/31] perf, core: Add a concept of a weightened sample Andi Kleen
2012-09-28  9:06   ` Stephane Eranian
2012-09-28 14:57     ` Andi Kleen
2012-09-28 17:09       ` Stephane Eranian
2012-09-28  4:31 ` [PATCH 19/31] perf, x86: Support weight samples for PEBS Andi Kleen
2012-09-28  4:31 ` [PATCH 20/31] perf, tools: Add support for weight Andi Kleen
2012-09-28  4:31 ` [PATCH 21/31] perf, tools: Handle XBEGIN like a jump Andi Kleen
2012-09-28  4:31 ` [PATCH 22/31] perf, core: Define generic hardware transaction events Andi Kleen
2012-09-28  9:33   ` Peter Zijlstra
2012-09-28  4:31 ` Andi Kleen [this message]
2012-09-28  4:31 ` [PATCH 24/31] perf, x86: Add the Haswell implementation of the generic " Andi Kleen
2012-09-28  4:31 ` [PATCH 25/31] perf, tools: Add perf stat --transaction Andi Kleen
2012-09-28  4:31 ` [PATCH 26/31] perf, x86: Support for printing PMU state on spurious PMIs Andi Kleen
2012-09-28  9:36   ` Peter Zijlstra
2012-09-28 11:39     ` Stephane Eranian
2012-09-28  4:31 ` [PATCH 27/31] perf, core: Add generic transaction flags Andi Kleen
2012-09-28  4:31 ` [PATCH 28/31] perf, x86: Add Haswell specific transaction flag reporting Andi Kleen
2012-09-28  4:31 ` [PATCH 29/31] perf, tools: Add support for record transaction flags Andi Kleen
2012-09-28  4:31 ` [PATCH 30/31] perf, tools: Point --sort documentation to --help Andi Kleen
2012-09-28  4:31 ` [PATCH 31/31] perf, tools: Add browser support for transaction flags Andi Kleen

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=1348806696-31170-24-git-send-email-andi@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).