aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2016-02-26 19:27:56 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-03-03 09:06:43 -0500
commit9dec4473abe7967c204fe700baf5344ade34e9c8 (patch)
treeaaa71efdd6e2aaec1e6ceebe4d2bd92c64e81381
parentf9a5978ac4ede901fa73d7c28ae1c5d89bc2a46a (diff)
perf stat: Check existence of frontend/backed stalled cycles
Only put the frontend/backend stalled cycles into the default perf stat events when the CPU actually supports them. This avoids empty columns with --metric-only on newer Intel CPUs. Committer note: Before: $ perf stat ls Performance counter stats for 'ls': 1.080893 task-clock (msec) # 0.619 CPUs utilized 0 context-switches # 0.000 K/sec 0 cpu-migrations # 0.000 K/sec 97 page-faults # 0.090 M/sec 3,327,741 cycles # 3.079 GHz <not supported> stalled-cycles-frontend <not supported> stalled-cycles-backend 1,609,544 instructions # 0.48 insn per cycle 319,117 branches # 295.235 M/sec 12,246 branch-misses # 3.84% of all branches 0.001746508 seconds time elapsed $ After: $ perf stat ls Performance counter stats for 'ls': 0.693948 task-clock (msec) # 0.662 CPUs utilized 0 context-switches # 0.000 K/sec 0 cpu-migrations # 0.000 K/sec 95 page-faults # 0.137 M/sec 1,792,509 cycles # 2.583 GHz 1,599,047 instructions # 0.89 insn per cycle 316,328 branches # 455.838 M/sec 12,453 branch-misses # 3.94% of all branches 0.001048987 seconds time elapsed $ Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1456532881-26621-2-git-send-email-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-stat.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 8c0bc0fe5179..24f222dd2a8a 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1441,7 +1441,7 @@ static int perf_stat_init_aggr_mode_file(struct perf_stat *st)
1441 */ 1441 */
1442static int add_default_attributes(void) 1442static int add_default_attributes(void)
1443{ 1443{
1444 struct perf_event_attr default_attrs[] = { 1444 struct perf_event_attr default_attrs0[] = {
1445 1445
1446 { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_TASK_CLOCK }, 1446 { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_TASK_CLOCK },
1447 { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CONTEXT_SWITCHES }, 1447 { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CONTEXT_SWITCHES },
@@ -1449,8 +1449,14 @@ static int add_default_attributes(void)
1449 { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_PAGE_FAULTS }, 1449 { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_PAGE_FAULTS },
1450 1450
1451 { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_CPU_CYCLES }, 1451 { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_CPU_CYCLES },
1452};
1453 struct perf_event_attr frontend_attrs[] = {
1452 { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_STALLED_CYCLES_FRONTEND }, 1454 { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_STALLED_CYCLES_FRONTEND },
1455};
1456 struct perf_event_attr backend_attrs[] = {
1453 { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_STALLED_CYCLES_BACKEND }, 1457 { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_STALLED_CYCLES_BACKEND },
1458};
1459 struct perf_event_attr default_attrs1[] = {
1454 { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_INSTRUCTIONS }, 1460 { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_INSTRUCTIONS },
1455 { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS }, 1461 { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS },
1456 { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_BRANCH_MISSES }, 1462 { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_BRANCH_MISSES },
@@ -1567,7 +1573,19 @@ static int add_default_attributes(void)
1567 } 1573 }
1568 1574
1569 if (!evsel_list->nr_entries) { 1575 if (!evsel_list->nr_entries) {
1570 if (perf_evlist__add_default_attrs(evsel_list, default_attrs) < 0) 1576 if (perf_evlist__add_default_attrs(evsel_list, default_attrs0) < 0)
1577 return -1;
1578 if (pmu_have_event("cpu", "stalled-cycles-frontend")) {
1579 if (perf_evlist__add_default_attrs(evsel_list,
1580 frontend_attrs) < 0)
1581 return -1;
1582 }
1583 if (pmu_have_event("cpu", "stalled-cycles-backend")) {
1584 if (perf_evlist__add_default_attrs(evsel_list,
1585 backend_attrs) < 0)
1586 return -1;
1587 }
1588 if (perf_evlist__add_default_attrs(evsel_list, default_attrs1) < 0)
1571 return -1; 1589 return -1;
1572 } 1590 }
1573 1591