All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: acme@kernel.org
Cc: jolsa@kernel.org, linux-kernel@vger.kernel.org,
	Andi Kleen <ak@linux.intel.com>
Subject: [PATCH 1/7] perf, tools, stat: Check existence of frontend/backed stalled cycles
Date: Tue,  1 Mar 2016 10:57:46 -0800	[thread overview]
Message-ID: <1456858672-21594-2-git-send-email-andi@firstfloor.org> (raw)
In-Reply-To: <1456858672-21594-1-git-send-email-andi@firstfloor.org>

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

  reply	other threads:[~2016-03-01 18:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-01 18:57 perf, tools: Refactor and support interval and CSV metrics Andi Kleen
2016-03-01 18:57 ` Andi Kleen [this message]
2016-03-01 18:57 ` [PATCH 2/7] perf, tools, stat: Implement CSV metrics output Andi Kleen
2016-03-01 18:57 ` [PATCH 3/7] perf, tools, stat: Support metrics in --per-core/socket mode Andi Kleen
2016-03-01 18:57 ` [PATCH 4/7] perf, tools, stat: Document CSV format in manpage Andi Kleen
2016-03-02 11:23   ` Jiri Olsa
2016-03-01 18:57 ` [PATCH 5/7] perf, tools, stat: Implement --metric-only mode Andi Kleen
2016-03-02 11:57   ` Jiri Olsa
2016-03-02 15:35     ` Andi Kleen
2016-03-01 18:57 ` [PATCH 6/7] perf, tools, stat: Add --metric-only support for -A Andi Kleen
2016-03-01 18:57 ` [PATCH 7/7] perf, tools, stat: Check for frontend stalled for metrics Andi Kleen
2016-03-02 12:04   ` Jiri Olsa
2016-03-05  8:21   ` [tip:perf/core] perf " tip-bot for Andi Kleen
2016-03-01 19:05 ` perf, tools: Refactor and support interval and CSV metrics Arnaldo Carvalho de Melo
  -- strict thread matches above, loose matches on Subject: below --
2016-03-03 23:57 Andi Kleen
2016-03-03 23:57 ` [PATCH 1/7] perf, tools, stat: Check existence of frontend/backed stalled cycles Andi Kleen
2016-03-03  0:24 perf, tools: Refactor and support interval and CSV metrics Andi Kleen
2016-03-03  0:24 ` [PATCH 1/7] perf, tools, stat: Check existence of frontend/backed stalled cycles Andi Kleen
2016-02-29 22:36 perf, tools: Refactor and support interval and CSV metrics Andi Kleen
2016-02-29 22:36 ` [PATCH 1/7] perf, tools, stat: Check existence of frontend/backed stalled cycles Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1456858672-21594-2-git-send-email-andi@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.