aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2015-06-03 10:25:52 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-06-08 09:30:30 -0400
commit4c358d5cf36192f22b8d331779cb92e3ede9cddf (patch)
tree0f9d1e258f73c7680bf1c326bae51ba92c67e8a6 /tools/perf
parente2f56da1d6670070f6f55d43007cb7b03ee04c2f (diff)
perf stat: Replace transaction event possition check with id check
Using perf_stat::id to check for transaction events, instead of current position based way. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Andi Kleen <ak@linux.intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1433341559-31848-3-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-stat.c55
-rw-r--r--tools/perf/util/stat.c6
-rw-r--r--tools/perf/util/stat.h4
3 files changed, 16 insertions, 49 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index a6ae1007f1f9..514493d703da 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -96,17 +96,6 @@ static const char * const transaction_limited_attrs[] = {
96 "}" 96 "}"
97}; 97};
98 98
99/* must match transaction_attrs and the beginning limited_attrs */
100enum {
101 T_TASK_CLOCK,
102 T_INSTRUCTIONS,
103 T_CYCLES,
104 T_CYCLES_IN_TX,
105 T_TRANSACTION_START,
106 T_ELISION_START,
107 T_CYCLES_IN_TX_CP,
108};
109
110static struct perf_evlist *evsel_list; 99static struct perf_evlist *evsel_list;
111 100
112static struct target target = { 101static struct target target = {
@@ -352,29 +341,6 @@ static inline int nsec_counter(struct perf_evsel *evsel)
352 return 0; 341 return 0;
353} 342}
354 343
355static struct perf_evsel *nth_evsel(int n)
356{
357 static struct perf_evsel **array;
358 static int array_len;
359 struct perf_evsel *ev;
360 int j;
361
362 /* Assumes this only called when evsel_list does not change anymore. */
363 if (!array) {
364 evlist__for_each(evsel_list, ev)
365 array_len++;
366 array = malloc(array_len * sizeof(void *));
367 if (!array)
368 exit(ENOMEM);
369 j = 0;
370 evlist__for_each(evsel_list, ev)
371 array[j++] = ev;
372 }
373 if (n < array_len)
374 return array[n];
375 return NULL;
376}
377
378/* 344/*
379 * Update various tracking values we maintain to print 345 * Update various tracking values we maintain to print
380 * more semantic information such as miss/hit ratios, 346 * more semantic information such as miss/hit ratios,
@@ -389,14 +355,11 @@ static void update_shadow_stats(struct perf_evsel *counter, u64 *count,
389 update_stats(&runtime_nsecs_stats[cpu], count[0]); 355 update_stats(&runtime_nsecs_stats[cpu], count[0]);
390 else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES)) 356 else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES))
391 update_stats(&runtime_cycles_stats[ctx][cpu], count[0]); 357 update_stats(&runtime_cycles_stats[ctx][cpu], count[0]);
392 else if (transaction_run && 358 else if (transaction_run && perf_stat_evsel__is(counter, CYCLES_IN_TX))
393 perf_evsel__cmp(counter, nth_evsel(T_CYCLES_IN_TX)))
394 update_stats(&runtime_transaction_stats[ctx][cpu], count[0]); 359 update_stats(&runtime_transaction_stats[ctx][cpu], count[0]);
395 else if (transaction_run && 360 else if (transaction_run && perf_stat_evsel__is(counter, TRANSACTION_START))
396 perf_evsel__cmp(counter, nth_evsel(T_TRANSACTION_START)))
397 update_stats(&runtime_transaction_stats[ctx][cpu], count[0]); 361 update_stats(&runtime_transaction_stats[ctx][cpu], count[0]);
398 else if (transaction_run && 362 else if (transaction_run && perf_stat_evsel__is(counter, ELISION_START))
399 perf_evsel__cmp(counter, nth_evsel(T_ELISION_START)))
400 update_stats(&runtime_elision_stats[ctx][cpu], count[0]); 363 update_stats(&runtime_elision_stats[ctx][cpu], count[0]);
401 else if (perf_evsel__match(counter, HARDWARE, HW_STALLED_CYCLES_FRONTEND)) 364 else if (perf_evsel__match(counter, HARDWARE, HW_STALLED_CYCLES_FRONTEND))
402 update_stats(&runtime_stalled_cycles_front_stats[ctx][cpu], count[0]); 365 update_stats(&runtime_stalled_cycles_front_stats[ctx][cpu], count[0]);
@@ -1207,15 +1170,13 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
1207 } else { 1170 } else {
1208 fprintf(output, " "); 1171 fprintf(output, " ");
1209 } 1172 }
1210 } else if (transaction_run && 1173 } else if (transaction_run && perf_stat_evsel__is(evsel, CYCLES_IN_TX)) {
1211 perf_evsel__cmp(evsel, nth_evsel(T_CYCLES_IN_TX))) {
1212 total = avg_stats(&runtime_cycles_stats[ctx][cpu]); 1174 total = avg_stats(&runtime_cycles_stats[ctx][cpu]);
1213 if (total) 1175 if (total)
1214 fprintf(output, 1176 fprintf(output,
1215 " # %5.2f%% transactional cycles ", 1177 " # %5.2f%% transactional cycles ",
1216 100.0 * (avg / total)); 1178 100.0 * (avg / total));
1217 } else if (transaction_run && 1179 } else if (transaction_run && perf_stat_evsel__is(evsel, CYCLES_IN_TX_CP)) {
1218 perf_evsel__cmp(evsel, nth_evsel(T_CYCLES_IN_TX_CP))) {
1219 total = avg_stats(&runtime_cycles_stats[ctx][cpu]); 1180 total = avg_stats(&runtime_cycles_stats[ctx][cpu]);
1220 total2 = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]); 1181 total2 = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]);
1221 if (total2 < avg) 1182 if (total2 < avg)
@@ -1224,8 +1185,7 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
1224 fprintf(output, 1185 fprintf(output,
1225 " # %5.2f%% aborted cycles ", 1186 " # %5.2f%% aborted cycles ",
1226 100.0 * ((total2-avg) / total)); 1187 100.0 * ((total2-avg) / total));
1227 } else if (transaction_run && 1188 } else if (transaction_run && perf_stat_evsel__is(evsel, TRANSACTION_START) &&
1228 perf_evsel__cmp(evsel, nth_evsel(T_TRANSACTION_START)) &&
1229 avg > 0 && 1189 avg > 0 &&
1230 runtime_cycles_in_tx_stats[ctx][cpu].n != 0) { 1190 runtime_cycles_in_tx_stats[ctx][cpu].n != 0) {
1231 total = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]); 1191 total = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]);
@@ -1234,8 +1194,7 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
1234 ratio = total / avg; 1194 ratio = total / avg;
1235 1195
1236 fprintf(output, " # %8.0f cycles / transaction ", ratio); 1196 fprintf(output, " # %8.0f cycles / transaction ", ratio);
1237 } else if (transaction_run && 1197 } else if (transaction_run && perf_stat_evsel__is(evsel, ELISION_START) &&
1238 perf_evsel__cmp(evsel, nth_evsel(T_ELISION_START)) &&
1239 avg > 0 && 1198 avg > 0 &&
1240 runtime_cycles_in_tx_stats[ctx][cpu].n != 0) { 1199 runtime_cycles_in_tx_stats[ctx][cpu].n != 0) {
1241 total = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]); 1200 total = avg_stats(&runtime_cycles_in_tx_stats[ctx][cpu]);
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 8e9f6bb7581b..60b92822f655 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -72,7 +72,11 @@ bool __perf_evsel_stat__is(struct perf_evsel *evsel,
72 72
73#define ID(id, name) [PERF_STAT_EVSEL_ID__##id] = #name 73#define ID(id, name) [PERF_STAT_EVSEL_ID__##id] = #name
74static const char *id_str[PERF_STAT_EVSEL_ID__MAX] = { 74static const char *id_str[PERF_STAT_EVSEL_ID__MAX] = {
75 ID(NONE, x), 75 ID(NONE, x),
76 ID(CYCLES_IN_TX, cpu/cycles-t/),
77 ID(TRANSACTION_START, cpu/tx-start/),
78 ID(ELISION_START, cpu/el-start/),
79 ID(CYCLES_IN_TX_CP, cpu/cycles-ct/),
76}; 80};
77#undef ID 81#undef ID
78 82
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index f4136cfd3cc9..3df529bd0774 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -11,6 +11,10 @@ struct stats
11 11
12enum perf_stat_evsel_id { 12enum perf_stat_evsel_id {
13 PERF_STAT_EVSEL_ID__NONE = 0, 13 PERF_STAT_EVSEL_ID__NONE = 0,
14 PERF_STAT_EVSEL_ID__CYCLES_IN_TX,
15 PERF_STAT_EVSEL_ID__TRANSACTION_START,
16 PERF_STAT_EVSEL_ID__ELISION_START,
17 PERF_STAT_EVSEL_ID__CYCLES_IN_TX_CP,
14 PERF_STAT_EVSEL_ID__MAX, 18 PERF_STAT_EVSEL_ID__MAX,
15}; 19};
16 20