[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-43d0b97817a41b274aaec0476e912dae3ae1f93d@git.kernel.org>
Date: Sat, 20 Feb 2016 03:38:41 -0800
From: tip-bot for Wang Nan <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: wangnan0@...wei.com, kirr@...edi.com, brendan.d.gregg@...il.com,
adrian.hunter@...el.com, jolsa@...nel.org, tglx@...utronix.de,
namhyung@...nel.org, dev@...yps.com, hpa@...or.com,
jeremie.galarneau@...icios.com, masami.hiramatsu.pt@...achi.com,
peterz@...radead.org, linux-kernel@...r.kernel.org, ast@...nel.org,
hekuang@...wei.com, acme@...hat.com, mingo@...nel.org,
lizefan@...wei.com
Subject: [tip:perf/core] perf tools:
Enable config and setting names for legacy cache events
Commit-ID: 43d0b97817a41b274aaec0476e912dae3ae1f93d
Gitweb: http://git.kernel.org/tip/43d0b97817a41b274aaec0476e912dae3ae1f93d
Author: Wang Nan <wangnan0@...wei.com>
AuthorDate: Fri, 19 Feb 2016 11:44:01 +0000
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Fri, 19 Feb 2016 19:12:51 -0300
perf tools: Enable config and setting names for legacy cache events
This patch allows setting config terms for legacy cache events.
For example:
# perf stat -e L1-icache-misses/name=valA/ -e branches/name=valB/ ls
...
Performance counter stats for 'ls':
11299 valA
451605 valB
0.000779091 seconds time elapsed
# perf record -e cache-misses/name=inh/ -e cache-misses/name=noinh,no-inherit/ bash
# ls
# exit
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.023 MB perf.data (131 samples) ]
# perf report --stdio | grep -B 1 'Event count'
# Samples: 105 of event 'inh'
# Event count (approx.): 109118
--
# Samples: 26 of event 'noinh'
# Event count (approx.): 48302
A test case is introduced to test this feature.
Signed-off-by: Wang Nan <wangnan0@...wei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Adrian Hunter <adrian.hunter@...el.com>
Cc: Alexei Starovoitov <ast@...nel.org>
Cc: Brendan Gregg <brendan.d.gregg@...il.com>
Cc: Cody P Schafer <dev@...yps.com>
Cc: He Kuang <hekuang@...wei.com>
Cc: Jeremie Galarneau <jeremie.galarneau@...icios.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Kirill Smelkov <kirr@...edi.com>
Cc: Li Zefan <lizefan@...wei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Zefan Li <lizefan@...wei.com>
Cc: pi3orama@....com
Link: http://lkml.kernel.org/r/1455882283-79592-14-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/tests/parse-events.c | 12 ++++++++++++
tools/perf/util/parse-events.c | 30 +++++++++++++++++++++++++++---
tools/perf/util/parse-events.h | 4 +++-
tools/perf/util/parse-events.y | 18 ++++++++++++------
4 files changed, 54 insertions(+), 10 deletions(-)
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 15e2d05..7865f68 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -1295,6 +1295,13 @@ static int test__checkevent_config_num(struct perf_evlist *evlist)
return 0;
}
+static int test__checkevent_config_cache(struct perf_evlist *evlist)
+{
+ struct perf_evsel *evsel = perf_evlist__first(evlist);
+
+ TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "cachepmu") == 0);
+ return 0;
+}
static int count_tracepoints(void)
{
@@ -1619,6 +1626,11 @@ static struct evlist_test test__events[] = {
.check = test__checkevent_config_num,
.id = 50,
},
+ {
+ .name = "L1-dcache-misses/name=cachepmu/",
+ .check = test__checkevent_config_cache,
+ .id = 51,
+ },
};
static struct evlist_test test__events_pmu[] = {
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 75576e1..2996aa4 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -350,11 +350,25 @@ static int parse_aliases(char *str, const char *names[][PERF_EVSEL__MAX_ALIASES]
return -1;
}
+typedef int config_term_func_t(struct perf_event_attr *attr,
+ struct parse_events_term *term,
+ struct parse_events_error *err);
+static int config_term_common(struct perf_event_attr *attr,
+ struct parse_events_term *term,
+ struct parse_events_error *err);
+static int config_attr(struct perf_event_attr *attr,
+ struct list_head *head,
+ struct parse_events_error *err,
+ config_term_func_t config_term);
+
int parse_events_add_cache(struct list_head *list, int *idx,
- char *type, char *op_result1, char *op_result2)
+ char *type, char *op_result1, char *op_result2,
+ struct parse_events_error *error,
+ struct list_head *head_config)
{
struct perf_event_attr attr;
- char name[MAX_NAME_LEN];
+ LIST_HEAD(config_terms);
+ char name[MAX_NAME_LEN], *config_name;
int cache_type = -1, cache_op = -1, cache_result = -1;
char *op_result[2] = { op_result1, op_result2 };
int i, n;
@@ -368,6 +382,7 @@ int parse_events_add_cache(struct list_head *list, int *idx,
if (cache_type == -1)
return -EINVAL;
+ config_name = get_config_name(head_config);
n = snprintf(name, MAX_NAME_LEN, "%s", type);
for (i = 0; (i < 2) && (op_result[i]); i++) {
@@ -408,7 +423,16 @@ int parse_events_add_cache(struct list_head *list, int *idx,
memset(&attr, 0, sizeof(attr));
attr.config = cache_type | (cache_op << 8) | (cache_result << 16);
attr.type = PERF_TYPE_HW_CACHE;
- return add_event(list, idx, &attr, name, NULL);
+
+ if (head_config) {
+ if (config_attr(&attr, head_config, error,
+ config_term_common))
+ return -EINVAL;
+
+ if (get_config_terms(head_config, &config_terms))
+ return -ENOMEM;
+ }
+ return add_event(list, idx, &attr, config_name ? : name, &config_terms);
}
static void tracepoint_error(struct parse_events_error *e, int err,
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 76151f9..d5eb2af 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -140,7 +140,9 @@ int parse_events_add_numeric(struct parse_events_evlist *data,
u32 type, u64 config,
struct list_head *head_config);
int parse_events_add_cache(struct list_head *list, int *idx,
- char *type, char *op_result1, char *op_result2);
+ char *type, char *op_result1, char *op_result2,
+ struct parse_events_error *error,
+ struct list_head *head_config);
int parse_events_add_breakpoint(struct list_head *list, int *idx,
void *ptr, char *type, u64 len);
int parse_events_add_pmu(struct parse_events_evlist *data,
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 82029f9..6a2d006 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -293,33 +293,39 @@ value_sym sep_slash_dc
}
event_legacy_cache:
-PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
+PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_event_config
{
struct parse_events_evlist *data = _data;
+ struct parse_events_error *error = data->error;
struct list_head *list;
ALLOC_LIST(list);
- ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, $5));
+ ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, $5, error, $6));
+ parse_events_terms__delete($6);
$$ = list;
}
|
-PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
+PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config
{
struct parse_events_evlist *data = _data;
+ struct parse_events_error *error = data->error;
struct list_head *list;
ALLOC_LIST(list);
- ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, NULL));
+ ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, NULL, error, $4));
+ parse_events_terms__delete($4);
$$ = list;
}
|
-PE_NAME_CACHE_TYPE
+PE_NAME_CACHE_TYPE opt_event_config
{
struct parse_events_evlist *data = _data;
+ struct parse_events_error *error = data->error;
struct list_head *list;
ALLOC_LIST(list);
- ABORT_ON(parse_events_add_cache(list, &data->idx, $1, NULL, NULL));
+ ABORT_ON(parse_events_add_cache(list, &data->idx, $1, NULL, NULL, error, $2));
+ parse_events_terms__delete($2);
$$ = list;
}
Powered by blists - more mailing lists