diff options
author | Andi Kleen <ak@linux.intel.com> | 2016-03-01 13:57:52 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-03-03 09:10:40 -0500 |
commit | fb4605ba47e772ff9d62d1d54218a832ec8b3e1d (patch) | |
tree | 1d31d9bf1378cc014ce4a96fa818b1ef119256b9 | |
parent | 1b69317d2dc80bc8e1d005e1a771c4f5bff3dabe (diff) |
perf stat: Check for frontend stalled for metrics
Add an extra check for frontend stalled in the metrics. This avoids an
extra column for the --metric-only case when the CPU does not support
frontend stalled.
v2: Add separate init function
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/1456858672-21594-8-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-stat.c | 1 | ||||
-rw-r--r-- | tools/perf/util/stat-shadow.c | 9 | ||||
-rw-r--r-- | tools/perf/util/stat.h | 1 |
3 files changed, 10 insertions, 1 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 9b5089c5dffe..baa82078c148 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -1966,6 +1966,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) | |||
1966 | argc = parse_options_subcommand(argc, argv, stat_options, stat_subcommands, | 1966 | argc = parse_options_subcommand(argc, argv, stat_options, stat_subcommands, |
1967 | (const char **) stat_usage, | 1967 | (const char **) stat_usage, |
1968 | PARSE_OPT_STOP_AT_NON_OPTION); | 1968 | PARSE_OPT_STOP_AT_NON_OPTION); |
1969 | perf_stat__init_shadow_stats(); | ||
1969 | 1970 | ||
1970 | if (csv_sep) { | 1971 | if (csv_sep) { |
1971 | csv_output = true; | 1972 | csv_output = true; |
diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index 5e2d2e34e1bc..b33ffb2af2cf 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include "evsel.h" | 2 | #include "evsel.h" |
3 | #include "stat.h" | 3 | #include "stat.h" |
4 | #include "color.h" | 4 | #include "color.h" |
5 | #include "pmu.h" | ||
5 | 6 | ||
6 | enum { | 7 | enum { |
7 | CTX_BIT_USER = 1 << 0, | 8 | CTX_BIT_USER = 1 << 0, |
@@ -35,9 +36,15 @@ static struct stats runtime_dtlb_cache_stats[NUM_CTX][MAX_NR_CPUS]; | |||
35 | static struct stats runtime_cycles_in_tx_stats[NUM_CTX][MAX_NR_CPUS]; | 36 | static struct stats runtime_cycles_in_tx_stats[NUM_CTX][MAX_NR_CPUS]; |
36 | static struct stats runtime_transaction_stats[NUM_CTX][MAX_NR_CPUS]; | 37 | static struct stats runtime_transaction_stats[NUM_CTX][MAX_NR_CPUS]; |
37 | static struct stats runtime_elision_stats[NUM_CTX][MAX_NR_CPUS]; | 38 | static struct stats runtime_elision_stats[NUM_CTX][MAX_NR_CPUS]; |
39 | static bool have_frontend_stalled; | ||
38 | 40 | ||
39 | struct stats walltime_nsecs_stats; | 41 | struct stats walltime_nsecs_stats; |
40 | 42 | ||
43 | void perf_stat__init_shadow_stats(void) | ||
44 | { | ||
45 | have_frontend_stalled = pmu_have_event("cpu", "stalled-cycles-frontend"); | ||
46 | } | ||
47 | |||
41 | static int evsel_context(struct perf_evsel *evsel) | 48 | static int evsel_context(struct perf_evsel *evsel) |
42 | { | 49 | { |
43 | int ctx = 0; | 50 | int ctx = 0; |
@@ -323,7 +330,7 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel, | |||
323 | print_metric(ctxp, NULL, "%7.2f ", | 330 | print_metric(ctxp, NULL, "%7.2f ", |
324 | "stalled cycles per insn", | 331 | "stalled cycles per insn", |
325 | ratio); | 332 | ratio); |
326 | } else { | 333 | } else if (have_frontend_stalled) { |
327 | print_metric(ctxp, NULL, NULL, | 334 | print_metric(ctxp, NULL, NULL, |
328 | "stalled cycles per insn", 0); | 335 | "stalled cycles per insn", 0); |
329 | } | 336 | } |
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index f02af68adc04..0150e786ccc7 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h | |||
@@ -72,6 +72,7 @@ typedef void (*print_metric_t)(void *ctx, const char *color, const char *unit, | |||
72 | const char *fmt, double val); | 72 | const char *fmt, double val); |
73 | typedef void (*new_line_t )(void *ctx); | 73 | typedef void (*new_line_t )(void *ctx); |
74 | 74 | ||
75 | void perf_stat__init_shadow_stats(void); | ||
75 | void perf_stat__reset_shadow_stats(void); | 76 | void perf_stat__reset_shadow_stats(void); |
76 | void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count, | 77 | void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count, |
77 | int cpu); | 78 | int cpu); |