aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-test.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-09-06 13:55:44 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-09-06 13:55:44 -0400
commit49f20d723e25a221fbcf1cbf4e51bb2942326e4f (patch)
tree9d358df8fc11f8bcf9abff7013b731c14e6d86f3 /tools/perf/builtin-test.c
parent78f067b38bed1adce6a2fa7868cf8ea37d61f537 (diff)
perf test: Add roundtrip test for hardware cache events
That nicely catches the problem reported by Joel Uckelman in http://permalink.gmane.org/gmane.linux.kernel.perf.user/1016 : [root@sandy ~]# perf test 1: vmlinux symtab matches kallsyms: Ok 2: detect open syscall event: Ok 3: detect open syscall event on all cpus: Ok 4: read samples using the mmap interface: Ok 5: parse events tests: Ok 6: x86 rdpmc test: Ok 7: Validate PERF_RECORD_* events & perf_sample fields: Ok 8: Test perf pmu format parsing: Ok 9: Test dso data interface: Ok 10: roundtrip evsel->name check: FAILED! [root@sandy ~]# perf test -v 10 10: roundtrip evsel->name check: --- start --- L1-dcache-misses != L1-dcache-load-misses L1-dcache-misses != L1-dcache-store-misses L1-dcache-misses != L1-dcache-prefetch-misses L1-icache-misses != L1-icache-load-misses L1-icache-misses != L1-icache-prefetch-misses LLC-misses != LLC-load-misses LLC-misses != LLC-store-misses LLC-misses != LLC-prefetch-misses dTLB-misses != dTLB-load-misses dTLB-misses != dTLB-store-misses dTLB-misses != dTLB-prefetch-misses iTLB-misses != iTLB-load-misses branch-misses != branch-load-misses node-misses != node-load-misses node-misses != node-store-misses node-misses != node-prefetch-misses ---- end ---- roundtrip evsel->name check: FAILED! [root@sandy ~]# Now lemme apply Jiri's fix and try it again... Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Joel Uckelman <joel@lightboxtechnologies.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-bbewtxw0rfipp5qy1j3jtg5d@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-test.c')
-rw-r--r--tools/perf/builtin-test.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index ba94fbe1fa4..cf33e5081c3 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -1092,6 +1092,63 @@ static int test__perf_pmu(void)
1092 return perf_pmu__test(); 1092 return perf_pmu__test();
1093} 1093}
1094 1094
1095static int perf_evsel__roundtrip_cache_name_test(void)
1096{
1097 char name[128];
1098 int type, op, err = 0, ret = 0, i, idx;
1099 struct perf_evsel *evsel;
1100 struct perf_evlist *evlist = perf_evlist__new(NULL, NULL);
1101
1102 if (evlist == NULL)
1103 return -ENOMEM;
1104
1105 for (type = 0; type < PERF_COUNT_HW_CACHE_MAX; type++) {
1106 for (op = 0; op < PERF_COUNT_HW_CACHE_OP_MAX; op++) {
1107 /* skip invalid cache type */
1108 if (!perf_evsel__is_cache_op_valid(type, op))
1109 continue;
1110
1111 for (i = 0; i < PERF_COUNT_HW_CACHE_RESULT_MAX; i++) {
1112 __perf_evsel__hw_cache_type_op_res_name(type, op, i,
1113 name, sizeof(name));
1114 err = parse_events(evlist, name, 0);
1115 if (err)
1116 ret = err;
1117 }
1118 }
1119 }
1120
1121 idx = 0;
1122 evsel = perf_evlist__first(evlist);
1123
1124 for (type = 0; type < PERF_COUNT_HW_CACHE_MAX; type++) {
1125 for (op = 0; op < PERF_COUNT_HW_CACHE_OP_MAX; op++) {
1126 /* skip invalid cache type */
1127 if (!perf_evsel__is_cache_op_valid(type, op))
1128 continue;
1129
1130 for (i = 0; i < PERF_COUNT_HW_CACHE_RESULT_MAX; i++) {
1131 __perf_evsel__hw_cache_type_op_res_name(type, op, i,
1132 name, sizeof(name));
1133 if (evsel->idx != idx)
1134 continue;
1135
1136 ++idx;
1137
1138 if (strcmp(perf_evsel__name(evsel), name)) {
1139 pr_debug("%s != %s\n", perf_evsel__name(evsel), name);
1140 ret = -1;
1141 }
1142
1143 evsel = perf_evsel__next(evsel);
1144 }
1145 }
1146 }
1147
1148 perf_evlist__delete(evlist);
1149 return ret;
1150}
1151
1095static int __perf_evsel__name_array_test(const char *names[], int nr_names) 1152static int __perf_evsel__name_array_test(const char *names[], int nr_names)
1096{ 1153{
1097 int i, err; 1154 int i, err;
@@ -1138,6 +1195,10 @@ static int perf_evsel__roundtrip_name_test(void)
1138 if (err) 1195 if (err)
1139 ret = err; 1196 ret = err;
1140 1197
1198 err = perf_evsel__roundtrip_cache_name_test();
1199 if (err)
1200 ret = err;
1201
1141 return ret; 1202 return ret;
1142} 1203}
1143 1204