Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1346891

[PATCH 1/7] perf, tools, stat: Check existence of frontend/backed stalled cycles

From Andi Kleen <andi@firstfloor.org>
Newsgroups linux.kernel
Subject [PATCH 1/7] perf, tools, stat: Check existence of frontend/backed stalled cycles
Date 2016-03-01 20:00 +0100
Message-ID <r7XGz-4zK-33@gated-at.bofh.it> (permalink)
References <r7XGy-4zK-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

Signed-off-by: Andi Kleen <ak@linux.intel.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 8c0bc0f..24f222d 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 — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

perf, tools: Refactor and support interval and CSV metrics Andi Kleen <andi@firstfloor.org> - 2016-03-01 20:00 +0100
  [PATCH 3/7] perf, tools, stat: Support metrics in --per-core/socket mode Andi Kleen <andi@firstfloor.org> - 2016-03-01 20:00 +0100
  [PATCH 5/7] perf, tools, stat: Implement --metric-only mode Andi Kleen <andi@firstfloor.org> - 2016-03-01 20:00 +0100
    Re: [PATCH 5/7] perf, tools, stat: Implement --metric-only mode Jiri Olsa <jolsa@redhat.com> - 2016-03-02 13:00 +0100
      Re: [PATCH 5/7] perf, tools, stat: Implement --metric-only mode Andi Kleen <andi@firstfloor.org> - 2016-03-02 16:40 +0100
  [PATCH 1/7] perf, tools, stat: Check existence of frontend/backed stalled cycles Andi Kleen <andi@firstfloor.org> - 2016-03-01 20:00 +0100
  [PATCH 4/7] perf, tools, stat: Document CSV format in manpage Andi Kleen <andi@firstfloor.org> - 2016-03-01 20:00 +0100
    Re: [PATCH 4/7] perf, tools, stat: Document CSV format in manpage Jiri Olsa <jolsa@redhat.com> - 2016-03-02 12:30 +0100
  [PATCH 2/7] perf, tools, stat: Implement CSV metrics output Andi Kleen <andi@firstfloor.org> - 2016-03-01 20:10 +0100
  Re: perf, tools: Refactor and support interval and CSV metrics Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-03-01 20:10 +0100

csiph-web