aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorStephane Eranian <eranian@google.com>2011-02-16 08:10:01 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-02-17 07:29:19 -0500
commitf0c55bcf4aa41b4b1dbee826513b1acb01bf65e1 (patch)
tree00ebfe5e00bf70a27f404c161c16b59ad1fcca62 /tools/perf/util
parent4498062e72fd55b2a9a4ac1b44fab8cb44ad5367 (diff)
perf: make perf stat print user provided full event names
This patch changes the way perf stat prints event names at the end of a run. Until now, it was trying to reconstruct the event name from its encoding. The problem is that it would only print generic events without their modifiers (u, k, pp). This patch saves the event name as passed by the user in the evsel struct and uses it to print the final event name. This would also work in case perf is linked with a library (such as libpfm4) which provides full PMU event tables. $ perf stat -e cycles:u,cycles:k date Wed Feb 16 14:58:52 CET 2011 Performance counter stats for 'date': 568600 cycles:u 2779715 cycles:k 0.001908182 seconds time elapsed Cc: Arun Sharma <arun@sharma-home.net> Cc: David S. Miller <davem@davemloft.net> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Robert Richter <robert.richter@amd.com> Cc: Stephane Eranian <eranian@gmail.com> LPU-Reference: <4d5bdc64.98a1df0a.7aa3.06c2@mx.google.com> Signed-off-by: Stephane Eranian <eranian@google.com> [ committer note: Fixed a merge problem with 023695d "Add cgroup support" ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/evsel.c1
-rw-r--r--tools/perf/util/evsel.h7
-rw-r--r--tools/perf/util/parse-events.c10
3 files changed, 18 insertions, 0 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index c974e08d07ab..63cadaf3e208 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -86,6 +86,7 @@ void perf_evsel__delete(struct perf_evsel *evsel)
86{ 86{
87 perf_evsel__exit(evsel); 87 perf_evsel__exit(evsel);
88 close_cgroup(evsel->cgrp); 88 close_cgroup(evsel->cgrp);
89 free(evsel->name);
89 free(evsel); 90 free(evsel);
90} 91}
91 92
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 1d3d5a3dbe60..f6fc8f651a25 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -37,6 +37,12 @@ struct perf_sample_id {
37 struct perf_evsel *evsel; 37 struct perf_evsel *evsel;
38}; 38};
39 39
40/** struct perf_evsel - event selector
41 *
42 * @name - Can be set to retain the original event name passed by the user,
43 * so that when showing results in tools such as 'perf stat', we
44 * show the name used, not some alias.
45 */
40struct perf_evsel { 46struct perf_evsel {
41 struct list_head node; 47 struct list_head node;
42 struct perf_event_attr attr; 48 struct perf_event_attr attr;
@@ -45,6 +51,7 @@ struct perf_evsel {
45 struct xyarray *id; 51 struct xyarray *id;
46 struct perf_counts *counts; 52 struct perf_counts *counts;
47 int idx; 53 int idx;
54 char *name;
48 void *priv; 55 void *priv;
49 struct cgroup_sel *cgrp; 56 struct cgroup_sel *cgrp;
50}; 57};
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index cf082daa43e3..80a3dd5ef573 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -268,6 +268,9 @@ const char *event_name(struct perf_evsel *evsel)
268 u64 config = evsel->attr.config; 268 u64 config = evsel->attr.config;
269 int type = evsel->attr.type; 269 int type = evsel->attr.type;
270 270
271 if (evsel->name)
272 return evsel->name;
273
271 return __event_name(type, config); 274 return __event_name(type, config);
272} 275}
273 276
@@ -782,8 +785,10 @@ int parse_events(const struct option *opt, const char *str, int unset __used)
782 struct perf_evlist *evlist = *(struct perf_evlist **)opt->value; 785 struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;
783 struct perf_event_attr attr; 786 struct perf_event_attr attr;
784 enum event_result ret; 787 enum event_result ret;
788 const char *ostr;
785 789
786 for (;;) { 790 for (;;) {
791 ostr = str;
787 memset(&attr, 0, sizeof(attr)); 792 memset(&attr, 0, sizeof(attr));
788 ret = parse_event_symbols(opt, &str, &attr); 793 ret = parse_event_symbols(opt, &str, &attr);
789 if (ret == EVT_FAILED) 794 if (ret == EVT_FAILED)
@@ -798,6 +803,11 @@ int parse_events(const struct option *opt, const char *str, int unset __used)
798 if (evsel == NULL) 803 if (evsel == NULL)
799 return -1; 804 return -1;
800 perf_evlist__add(evlist, evsel); 805 perf_evlist__add(evlist, evsel);
806
807 evsel->name = calloc(str - ostr + 1, 1);
808 if (!evsel->name)
809 return -1;
810 strncpy(evsel->name, ostr, str - ostr);
801 } 811 }
802 812
803 if (*str == 0) 813 if (*str == 0)