From: Jiri Olsa <jolsa@redhat.com>
To: acme@redhat.com, a.p.zijlstra@chello.nl, mingo@elte.hu,
paulus@samba.org, cjashfor@linux.vnet.ibm.com,
fweisbec@gmail.com, eranian@google.com
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>
Subject: [PATCH 07/10] perf, tool: Add support to specify hw event as pmu event term
Date: Wed, 4 Jul 2012 00:00:45 +0200 [thread overview]
Message-ID: <1341352848-11833-8-git-send-email-jolsa@redhat.com> (raw)
In-Reply-To: <1341352848-11833-1-git-send-email-jolsa@redhat.com>
Adding a way to specify hw event as pmu event term like:
'cpu/event=cycles/u'
'cpu/event=instructions,.../u'
The 'event=cycles' term needs to be replaced/translated by the hw
events term translation, which is exposed by sysfs 'events' group
attribute.
The 'events' attribute is handled by the pmu alias code, so the
only thing we need to ensure is to map the event name to the proper
sysfs attribute name.
It's possible to use sysfs attribute name as 'event' term value,
or any possible alias for hw event, e.g.:
cycles OR cpu-cycles
branch_misses OR branch-misses
bus_cycles OR bus-cycles
cache_misses OR cache-misses
cache_references OR cache-references
ref_cycles OR ref-cycles
stalled_cycles_backend OR stalled-cycles-backend
stalled_cycles_frontend OR stalled-cycles-frontend
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
---
tools/perf/util/parse-events.c | 29 +++++++++++++++++++++++++++++
tools/perf/util/parse-events.h | 2 ++
tools/perf/util/parse-events.y | 9 +++++++++
3 files changed, 40 insertions(+)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 6d12b39..a0fb567 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -21,6 +21,11 @@
struct event_symbol {
const char *symbol;
const char *alias;
+ /*
+ * The attribute name inside the 'events' sysfs
+ * group. Only for HW events.
+ */
+ const char *sysfs;
};
#ifdef PARSER_DEBUG
@@ -32,42 +37,52 @@ static struct event_symbol event_symbols_hw[PERF_COUNT_HW_MAX] = {
[PERF_COUNT_HW_CPU_CYCLES] = {
.symbol = "cpu-cycles",
.alias = "cycles",
+ .sysfs = "cycles",
},
[PERF_COUNT_HW_INSTRUCTIONS] = {
.symbol = "instructions",
.alias = "",
+ .sysfs = "instructions",
},
[PERF_COUNT_HW_CACHE_REFERENCES] = {
.symbol = "cache-references",
.alias = "",
+ .sysfs = "cache_references",
},
[PERF_COUNT_HW_CACHE_MISSES] = {
.symbol = "cache-misses",
.alias = "",
+ .sysfs = "cache_misses",
},
[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = {
.symbol = "branch-instructions",
.alias = "branches",
+ .sysfs = "branch_instructions",
},
[PERF_COUNT_HW_BRANCH_MISSES] = {
.symbol = "branch-misses",
.alias = "",
+ .sysfs = "branch_misses",
},
[PERF_COUNT_HW_BUS_CYCLES] = {
.symbol = "bus-cycles",
.alias = "",
+ .sysfs = "bus_cycles",
},
[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = {
.symbol = "stalled-cycles-frontend",
.alias = "idle-cycles-frontend",
+ .sysfs = "stalled_cycles_frontend",
},
[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = {
.symbol = "stalled-cycles-backend",
.alias = "idle-cycles-backend",
+ .sysfs = "stalled_cycles_backend",
},
[PERF_COUNT_HW_REF_CPU_CYCLES] = {
.symbol = "ref-cycles",
.alias = "",
+ .sysfs = "ref_cycles",
},
};
@@ -1037,6 +1052,20 @@ int parse_events__term_str(struct parse_events__term **term,
config, str, 0);
}
+int parse_events__term_sym_hw(struct parse_events__term **term,
+ char *config, unsigned idx)
+{
+ struct event_symbol *sym;
+
+ BUG_ON(idx >= PERF_COUNT_HW_MAX);
+ sym = &event_symbols_hw[idx];
+ BUG_ON(!sym->sysfs);
+
+ return new_term(term, PARSE_EVENTS__TERM_TYPE_STR,
+ PARSE_EVENTS__TERM_TYPE_USER, config,
+ (char *) sym->sysfs, 0);
+}
+
int parse_events__term_clone(struct parse_events__term **new,
struct parse_events__term *term)
{
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index ee9c218..eaf2fd7 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -76,6 +76,8 @@ int parse_events__term_num(struct parse_events__term **_term,
int type_term, char *config, long num);
int parse_events__term_str(struct parse_events__term **_term,
int type_term, char *config, char *str);
+int parse_events__term_sym_hw(struct parse_events__term **term,
+ char *config, unsigned idx);
int parse_events__term_clone(struct parse_events__term **new,
struct parse_events__term *term);
void parse_events__free_terms(struct list_head *terms);
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 2bc5fbf..9c74d8a 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -269,6 +269,15 @@ PE_NAME '=' PE_VALUE
$$ = term;
}
|
+PE_NAME '=' PE_VALUE_SYM_HW
+{
+ struct parse_events__term *term;
+ int config = $3 & 255;
+
+ ABORT_ON(parse_events__term_sym_hw(&term, $1, config));
+ $$ = term;
+}
+|
PE_NAME
{
struct parse_events__term *term;
--
1.7.10.4
next prev parent reply other threads:[~2012-07-03 22:01 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-03 22:00 [RFCv2 0/10] perf, tool: Allow to use hw events in PMU syntax Jiri Olsa
2012-07-03 22:00 ` [PATCH 01/10] perf, tool: Add empty rule for new line in event syntax parsing Jiri Olsa
2012-07-06 11:23 ` [tip:perf/core] perf tools: " tip-bot for Jiri Olsa
2012-07-03 22:00 ` [PATCH 02/10] perf, tool: Fix pmu object initialization Jiri Olsa
2012-07-04 10:30 ` Peter Zijlstra
2012-07-04 11:40 ` Jiri Olsa
2012-07-04 11:50 ` Peter Zijlstra
2012-07-05 14:28 ` Arnaldo Carvalho de Melo
2012-07-03 22:00 ` [PATCH 03/10] perf, tool: Properly free format data Jiri Olsa
2012-07-03 22:00 ` [PATCH 04/10] perf, x86: Making hardware events translations available in sysfs Jiri Olsa
2012-07-04 10:22 ` Peter Zijlstra
2012-07-04 10:38 ` Peter Zijlstra
2012-07-04 12:01 ` Jiri Olsa
2012-07-04 12:14 ` Peter Zijlstra
2012-07-04 16:35 ` Arnaldo Carvalho de Melo
2012-07-04 10:22 ` Peter Zijlstra
2012-07-04 10:24 ` Peter Zijlstra
2012-07-04 10:28 ` Peter Zijlstra
2012-07-04 12:00 ` Jiri Olsa
2012-07-03 22:00 ` [PATCH 05/10] perf, tool: Split out PE_VALUE_SYM parsing token to SW and HW tokens Jiri Olsa
2012-07-06 11:24 ` [tip:perf/core] perf tools: " tip-bot for Jiri Olsa
2012-07-03 22:00 ` [PATCH 06/10] perf, tool: Split event symbols arrays to hw and sw parts Jiri Olsa
2012-07-06 11:25 ` [tip:perf/core] perf tools: " tip-bot for Jiri Olsa
2012-07-03 22:00 ` Jiri Olsa [this message]
2012-07-04 10:39 ` [PATCH 07/10] perf, tool: Add support to specify hw event as pmu event term Peter Zijlstra
2012-07-04 12:00 ` Jiri Olsa
2012-07-04 12:13 ` Peter Zijlstra
2012-07-06 1:08 ` Stephane Eranian
2012-07-09 13:03 ` Peter Zijlstra
2012-07-03 22:00 ` [PATCH 08/10] perf, tool: Add sysfs read file interface Jiri Olsa
2012-07-04 10:40 ` Peter Zijlstra
2012-07-03 22:00 ` [PATCH 09/10] perf, test: Use ARRAY_SIZE in parse events tests Jiri Olsa
2012-07-06 11:22 ` [tip:perf/core] perf " tip-bot for Jiri Olsa
2012-07-03 22:00 ` [PATCH 10/10] perf, test: Add automated tests for pmu sysfs translated events Jiri Olsa
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=1341352848-11833-8-git-send-email-jolsa@redhat.com \
--to=jolsa@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=cjashfor@linux.vnet.ibm.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.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).