Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1346112
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 05/11] perf stat: Check existence of frontend/backed stalled cycles |
| Date | 2016-02-29 20:30 +0100 |
| Message-ID | <r7BG2-7d5-17@gated-at.bofh.it> (permalink) |
| References | <r7BG1-7d5-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Andi Kleen <ak@linux.intel.com>
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
a.patch
Performance counter stats for 'ls':
0.822067 task-clock (msec) # 0.873 CPUs utilized (82.26%)
0 context-switches # 0.000 K/sec (82.26%)
0 cpu-migrations # 0.000 K/sec (82.26%)
125 page-faults # 0.152 M/sec (82.26%)
2,516,127 cycles # 3.061 GHz (82.84%)
<not supported> stalled-cycles-frontend
<not supported> stalled-cycles-backend
2,430,467 instructions # 0.97 insn per cycle (82.84%)
486,235 branches # 591.479 M/sec (82.84%)
18,389 branch-misses # 3.78% of all branches (82.84%)
0.000941536 seconds time elapsed
$
After:
$ perf stat ls
a.patch
Performance counter stats for 'ls':
0.824919 task-clock (msec) # 0.893 CPUs utilized (85.47%)
0 context-switches # 0.000 K/sec (85.47%)
0 cpu-migrations # 0.000 K/sec (85.47%)
124 page-faults # 0.150 M/sec (85.47%)
2521790 cycles # 3.057 GHz (86.15%)
2364913 instructions # 0.94 insn per cycle (86.15%)
471970 branches # 572.141 M/sec (86.15%)
16935 branch-misses # 3.59% of all branches (86.15%)
0.000923397 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>
---
tools/perf/builtin-stat.c | 22 ++++++++++++++++++++--
1 file 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)
*/
static int add_default_attributes(void)
{
- struct perf_event_attr default_attrs[] = {
+ struct perf_event_attr default_attrs0[] = {
{ .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_TASK_CLOCK },
{ .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CONTEXT_SWITCHES },
@@ -1449,8 +1449,14 @@ static int add_default_attributes(void)
{ .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_PAGE_FAULTS },
{ .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_CPU_CYCLES },
+};
+ struct perf_event_attr frontend_attrs[] = {
{ .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_STALLED_CYCLES_FRONTEND },
+};
+ struct perf_event_attr backend_attrs[] = {
{ .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_STALLED_CYCLES_BACKEND },
+};
+ struct perf_event_attr default_attrs1[] = {
{ .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_INSTRUCTIONS },
{ .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS },
{ .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_BRANCH_MISSES },
@@ -1567,7 +1573,19 @@ static int add_default_attributes(void)
}
if (!evsel_list->nr_entries) {
- if (perf_evlist__add_default_attrs(evsel_list, default_attrs) < 0)
+ if (perf_evlist__add_default_attrs(evsel_list, default_attrs0) < 0)
+ return -1;
+ if (pmu_have_event("cpu", "stalled-cycles-frontend")) {
+ if (perf_evlist__add_default_attrs(evsel_list,
+ frontend_attrs) < 0)
+ return -1;
+ }
+ if (pmu_have_event("cpu", "stalled-cycles-backend")) {
+ if (perf_evlist__add_default_attrs(evsel_list,
+ backend_attrs) < 0)
+ return -1;
+ }
+ if (perf_evlist__add_default_attrs(evsel_list, default_attrs1) < 0)
return -1;
}
--
2.5.0
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH 05/11] perf stat: Check existence of frontend/backed stalled cycles Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-02-29 20:30 +0100
Re: [PATCH 05/11] perf stat: Check existence of frontend/backed stalled cycles Ingo Molnar <mingo@kernel.org> - 2016-03-03 09:30 +0100
Re: [PATCH 05/11] perf stat: Check existence of frontend/backed stalled cycles Arnaldo Carvalho de Melo <acme@redhat.com> - 2016-03-03 13:50 +0100
Re: [PATCH 05/11] perf stat: Check existence of frontend/backed stalled cycles Arnaldo Carvalho de Melo <acme@redhat.com> - 2016-03-03 14:00 +0100
csiph-web