From: Jiri Olsa <jolsa@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
David Ahern <dsahern@gmail.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Andi Kleen <andi@firstfloor.org>
Subject: [PATCH 19/43] perf stat: Pass stat_config argument to global print functions
Date: Thu, 30 Aug 2018 08:32:28 +0200 [thread overview]
Message-ID: <20180830063252.23729-20-jolsa@kernel.org> (raw)
In-Reply-To: <20180830063252.23729-1-jolsa@kernel.org>
Adding stat_config argument global print functions, so those
functions could be used out of the stat command code.
Link: http://lkml.kernel.org/n/tip-p1yrm9p91j87rx77eqzf5cfk@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-script.c | 8 +-
tools/perf/builtin-stat.c | 74 +++++++++--------
tools/perf/util/stat-shadow.c | 147 ++++++++++++++++++----------------
tools/perf/util/stat.h | 8 +-
4 files changed, 131 insertions(+), 106 deletions(-)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index ba481d73f910..6176bae177c2 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1544,7 +1544,8 @@ struct metric_ctx {
FILE *fp;
};
-static void script_print_metric(void *ctx, const char *color,
+static void script_print_metric(struct perf_stat_config *config __maybe_unused,
+ void *ctx, const char *color,
const char *fmt,
const char *unit, double val)
{
@@ -1562,7 +1563,8 @@ static void script_print_metric(void *ctx, const char *color,
fprintf(mctx->fp, " %s\n", unit);
}
-static void script_new_line(void *ctx)
+static void script_new_line(struct perf_stat_config *config __maybe_unused,
+ void *ctx)
{
struct metric_ctx *mctx = ctx;
@@ -1608,7 +1610,7 @@ static void perf_sample__fprint_metric(struct perf_script *script,
evsel_script(evsel)->val = val;
if (evsel_script(evsel->leader)->gnum == evsel->leader->nr_members) {
for_each_group_member (ev2, evsel->leader) {
- perf_stat__print_shadow_stats(ev2,
+ perf_stat__print_shadow_stats(&stat_config, ev2,
evsel_script(ev2)->val,
sample->cpu,
&ctx,
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index f56da22abccc..7a3361308e61 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -697,11 +697,12 @@ static void print_noise(struct perf_stat_config *config,
print_noise_pct(config, stddev_stats(&ps->res_stats[0]), avg);
}
-static void aggr_printout(struct perf_evsel *evsel, int id, int nr)
+static void aggr_printout(struct perf_stat_config *config,
+ struct perf_evsel *evsel, int id, int nr)
{
- switch (stat_config.aggr_mode) {
+ switch (config->aggr_mode) {
case AGGR_CORE:
- fprintf(stat_config.output, "S%d-C%*d%s%*d%s",
+ fprintf(config->output, "S%d-C%*d%s%*d%s",
cpu_map__id_to_socket(id),
csv_output ? 0 : -8,
cpu_map__id_to_cpu(id),
@@ -711,7 +712,7 @@ static void aggr_printout(struct perf_evsel *evsel, int id, int nr)
csv_sep);
break;
case AGGR_SOCKET:
- fprintf(stat_config.output, "S%*d%s%*d%s",
+ fprintf(config->output, "S%*d%s%*d%s",
csv_output ? 0 : -5,
id,
csv_sep,
@@ -720,12 +721,12 @@ static void aggr_printout(struct perf_evsel *evsel, int id, int nr)
csv_sep);
break;
case AGGR_NONE:
- fprintf(stat_config.output, "CPU%*d%s",
+ fprintf(config->output, "CPU%*d%s",
csv_output ? 0 : -4,
perf_evsel__cpus(evsel)->map[id], csv_sep);
break;
case AGGR_THREAD:
- fprintf(stat_config.output, "%*s-%*d%s",
+ fprintf(config->output, "%*s-%*d%s",
csv_output ? 0 : 16,
thread_map__comm(evsel->threads, id),
csv_output ? 0 : -8,
@@ -750,24 +751,27 @@ struct outstate {
#define METRIC_LEN 35
-static void new_line_std(void *ctx)
+static void new_line_std(struct perf_stat_config *config __maybe_unused,
+ void *ctx)
{
struct outstate *os = ctx;
os->newline = true;
}
-static void do_new_line_std(struct outstate *os)
+static void do_new_line_std(struct perf_stat_config *config,
+ struct outstate *os)
{
fputc('\n', os->fh);
fputs(os->prefix, os->fh);
- aggr_printout(os->evsel, os->id, os->nr);
- if (stat_config.aggr_mode == AGGR_NONE)
+ aggr_printout(config, os->evsel, os->id, os->nr);
+ if (config->aggr_mode == AGGR_NONE)
fprintf(os->fh, " ");
fprintf(os->fh, " ");
}
-static void print_metric_std(void *ctx, const char *color, const char *fmt,
+static void print_metric_std(struct perf_stat_config *config,
+ void *ctx, const char *color, const char *fmt,
const char *unit, double val)
{
struct outstate *os = ctx;
@@ -783,7 +787,7 @@ static void print_metric_std(void *ctx, const char *color, const char *fmt,
}
if (newline)
- do_new_line_std(os);
+ do_new_line_std(config, os);
n = fprintf(out, " # ");
if (color)
@@ -793,7 +797,7 @@ static void print_metric_std(void *ctx, const char *color, const char *fmt,
fprintf(out, " %-*s", METRIC_LEN - n - 1, unit);
}
-static void new_line_csv(void *ctx)
+static void new_line_csv(struct perf_stat_config *config, void *ctx)
{
struct outstate *os = ctx;
int i;
@@ -801,12 +805,13 @@ static void new_line_csv(void *ctx)
fputc('\n', os->fh);
if (os->prefix)
fprintf(os->fh, "%s%s", os->prefix, csv_sep);
- aggr_printout(os->evsel, os->id, os->nr);
+ aggr_printout(config, os->evsel, os->id, os->nr);
for (i = 0; i < os->nfields; i++)
fputs(csv_sep, os->fh);
}
-static void print_metric_csv(void *ctx,
+static void print_metric_csv(struct perf_stat_config *config __maybe_unused,
+ void *ctx,
const char *color __maybe_unused,
const char *fmt, const char *unit, double val)
{
@@ -853,7 +858,8 @@ static const char *fixunit(char *buf, struct perf_evsel *evsel,
return unit;
}
-static void print_metric_only(void *ctx, const char *color, const char *fmt,
+static void print_metric_only(struct perf_stat_config *config __maybe_unused,
+ void *ctx, const char *color, const char *fmt,
const char *unit, double val)
{
struct outstate *os = ctx;
@@ -874,7 +880,8 @@ static void print_metric_only(void *ctx, const char *color, const char *fmt,
fprintf(out, "%*s ", mlen, str);
}
-static void print_metric_only_csv(void *ctx, const char *color __maybe_unused,
+static void print_metric_only_csv(struct perf_stat_config *config __maybe_unused,
+ void *ctx, const char *color __maybe_unused,
const char *fmt,
const char *unit, double val)
{
@@ -894,11 +901,13 @@ static void print_metric_only_csv(void *ctx, const char *color __maybe_unused,
fprintf(out, "%s%s", vals, csv_sep);
}
-static void new_line_metric(void *ctx __maybe_unused)
+static void new_line_metric(struct perf_stat_config *config __maybe_unused,
+ void *ctx __maybe_unused)
{
}
-static void print_metric_header(void *ctx, const char *color __maybe_unused,
+static void print_metric_header(struct perf_stat_config *config __maybe_unused,
+ void *ctx, const char *color __maybe_unused,
const char *fmt __maybe_unused,
const char *unit, double val __maybe_unused)
{
@@ -936,9 +945,10 @@ static int first_shadow_cpu(struct perf_evsel *evsel, int id)
return 0;
}
-static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
+static void abs_printout(struct perf_stat_config *config,
+ int id, int nr, struct perf_evsel *evsel, double avg)
{
- FILE *output = stat_config.output;
+ FILE *output = config->output;
double sc = evsel->scale;
const char *fmt;
@@ -951,7 +961,7 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
fmt = floor(sc) != sc ? "%18.2f%s" : "%18.0f%s";
}
- aggr_printout(evsel, id, nr);
+ aggr_printout(config, evsel, id, nr);
fprintf(output, fmt, avg, csv_sep);
@@ -1004,7 +1014,7 @@ static void printout(struct perf_stat_config *config, int id, int nr,
.evsel = counter,
};
print_metric_t pm = print_metric_std;
- void (*nl)(void *);
+ new_line_t nl;
if (metric_only) {
nl = new_line_metric;
@@ -1033,10 +1043,10 @@ static void printout(struct perf_stat_config *config, int id, int nr,
}
if (run == 0 || ena == 0 || counter->counts->scaled == -1) {
if (metric_only) {
- pm(&os, NULL, "", "", 0);
+ pm(config, &os, NULL, "", "", 0);
return;
}
- aggr_printout(counter, id, nr);
+ aggr_printout(config, counter, id, nr);
fprintf(config->output, "%*s%s",
csv_output ? 0 : 18,
@@ -1062,16 +1072,16 @@ static void printout(struct perf_stat_config *config, int id, int nr,
csv_sep, counter->cgrp->name);
if (!csv_output)
- pm(&os, NULL, NULL, "", 0);
+ pm(config, &os, NULL, NULL, "", 0);
print_noise(config, counter, noise);
print_running(config, run, ena);
if (csv_output)
- pm(&os, NULL, NULL, "", 0);
+ pm(config, &os, NULL, NULL, "", 0);
return;
}
if (!metric_only)
- abs_printout(id, nr, counter, uval);
+ abs_printout(config, id, nr, counter, uval);
out.print_metric = pm;
out.new_line = nl;
@@ -1083,7 +1093,7 @@ static void printout(struct perf_stat_config *config, int id, int nr,
print_running(config, run, ena);
}
- perf_stat__print_shadow_stats(counter, uval,
+ perf_stat__print_shadow_stats(config, counter, uval,
first_shadow_cpu(counter, id),
&out, &metric_events, st);
if (!csv_output && !metric_only) {
@@ -1255,7 +1265,7 @@ static void print_aggr(struct perf_stat_config *config,
val = ad.val;
if (first && metric_only) {
first = false;
- aggr_printout(counter, id, nr);
+ aggr_printout(config, counter, id, nr);
}
if (prefix && !metric_only)
fprintf(output, "%s", prefix);
@@ -1459,7 +1469,7 @@ static void print_no_aggr_metric(struct perf_stat_config *config,
if (is_duration_time(counter))
continue;
if (first) {
- aggr_printout(counter, cpu, 0);
+ aggr_printout(config, counter, cpu, 0);
first = false;
}
val = perf_counts(counter->counts, cpu, 0)->val;
@@ -1521,7 +1531,7 @@ static void print_metric_headers(struct perf_stat_config *config,
out.new_line = new_line_metric;
out.force_header = true;
os.evsel = counter;
- perf_stat__print_shadow_stats(counter, 0,
+ perf_stat__print_shadow_stats(config, counter, 0,
0,
&out,
&metric_events,
diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index 99990f5f2512..8ad32763cfff 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -410,7 +410,8 @@ static double runtime_stat_n(struct runtime_stat *st,
return v->stats.n;
}
-static void print_stalled_cycles_frontend(int cpu,
+static void print_stalled_cycles_frontend(struct perf_stat_config *config,
+ int cpu,
struct perf_evsel *evsel, double avg,
struct perf_stat_output_ctx *out,
struct runtime_stat *st)
@@ -427,13 +428,14 @@ static void print_stalled_cycles_frontend(int cpu,
color = get_ratio_color(GRC_STALLED_CYCLES_FE, ratio);
if (ratio)
- out->print_metric(out->ctx, color, "%7.2f%%", "frontend cycles idle",
+ out->print_metric(config, out->ctx, color, "%7.2f%%", "frontend cycles idle",
ratio);
else
- out->print_metric(out->ctx, NULL, NULL, "frontend cycles idle", 0);
+ out->print_metric(config, out->ctx, NULL, NULL, "frontend cycles idle", 0);
}
-static void print_stalled_cycles_backend(int cpu,
+static void print_stalled_cycles_backend(struct perf_stat_config *config,
+ int cpu,
struct perf_evsel *evsel, double avg,
struct perf_stat_output_ctx *out,
struct runtime_stat *st)
@@ -449,10 +451,11 @@ static void print_stalled_cycles_backend(int cpu,
color = get_ratio_color(GRC_STALLED_CYCLES_BE, ratio);
- out->print_metric(out->ctx, color, "%7.2f%%", "backend cycles idle", ratio);
+ out->print_metric(config, out->ctx, color, "%7.2f%%", "backend cycles idle", ratio);
}
-static void print_branch_misses(int cpu,
+static void print_branch_misses(struct perf_stat_config *config,
+ int cpu,
struct perf_evsel *evsel,
double avg,
struct perf_stat_output_ctx *out,
@@ -469,10 +472,11 @@ static void print_branch_misses(int cpu,
color = get_ratio_color(GRC_CACHE_MISSES, ratio);
- out->print_metric(out->ctx, color, "%7.2f%%", "of all branches", ratio);
+ out->print_metric(config, out->ctx, color, "%7.2f%%", "of all branches", ratio);
}
-static void print_l1_dcache_misses(int cpu,
+static void print_l1_dcache_misses(struct perf_stat_config *config,
+ int cpu,
struct perf_evsel *evsel,
double avg,
struct perf_stat_output_ctx *out,
@@ -490,10 +494,11 @@ static void print_l1_dcache_misses(int cpu,
color = get_ratio_color(GRC_CACHE_MISSES, ratio);
- out->print_metric(out->ctx, color, "%7.2f%%", "of all L1-dcache hits", ratio);
+ out->print_metric(config, out->ctx, color, "%7.2f%%", "of all L1-dcache hits", ratio);
}
-static void print_l1_icache_misses(int cpu,
+static void print_l1_icache_misses(struct perf_stat_config *config,
+ int cpu,
struct perf_evsel *evsel,
double avg,
struct perf_stat_output_ctx *out,
@@ -510,10 +515,11 @@ static void print_l1_icache_misses(int cpu,
ratio = avg / total * 100.0;
color = get_ratio_color(GRC_CACHE_MISSES, ratio);
- out->print_metric(out->ctx, color, "%7.2f%%", "of all L1-icache hits", ratio);
+ out->print_metric(config, out->ctx, color, "%7.2f%%", "of all L1-icache hits", ratio);
}
-static void print_dtlb_cache_misses(int cpu,
+static void print_dtlb_cache_misses(struct perf_stat_config *config,
+ int cpu,
struct perf_evsel *evsel,
double avg,
struct perf_stat_output_ctx *out,
@@ -529,10 +535,11 @@ static void print_dtlb_cache_misses(int cpu,
ratio = avg / total * 100.0;
color = get_ratio_color(GRC_CACHE_MISSES, ratio);
- out->print_metric(out->ctx, color, "%7.2f%%", "of all dTLB cache hits", ratio);
+ out->print_metric(config, out->ctx, color, "%7.2f%%", "of all dTLB cache hits", ratio);
}
-static void print_itlb_cache_misses(int cpu,
+static void print_itlb_cache_misses(struct perf_stat_config *config,
+ int cpu,
struct perf_evsel *evsel,
double avg,
struct perf_stat_output_ctx *out,
@@ -548,10 +555,11 @@ static void print_itlb_cache_misses(int cpu,
ratio = avg / total * 100.0;
color = get_ratio_color(GRC_CACHE_MISSES, ratio);
- out->print_metric(out->ctx, color, "%7.2f%%", "of all iTLB cache hits", ratio);
+ out->print_metric(config, out->ctx, color, "%7.2f%%", "of all iTLB cache hits", ratio);
}
-static void print_ll_cache_misses(int cpu,
+static void print_ll_cache_misses(struct perf_stat_config *config,
+ int cpu,
struct perf_evsel *evsel,
double avg,
struct perf_stat_output_ctx *out,
@@ -567,7 +575,7 @@ static void print_ll_cache_misses(int cpu,
ratio = avg / total * 100.0;
color = get_ratio_color(GRC_CACHE_MISSES, ratio);
- out->print_metric(out->ctx, color, "%7.2f%%", "of all LL-cache hits", ratio);
+ out->print_metric(config, out->ctx, color, "%7.2f%%", "of all LL-cache hits", ratio);
}
/*
@@ -674,7 +682,8 @@ static double td_be_bound(int ctx, int cpu, struct runtime_stat *st)
return sanitize_val(1.0 - sum);
}
-static void print_smi_cost(int cpu, struct perf_evsel *evsel,
+static void print_smi_cost(struct perf_stat_config *config,
+ int cpu, struct perf_evsel *evsel,
struct perf_stat_output_ctx *out,
struct runtime_stat *st)
{
@@ -694,11 +703,12 @@ static void print_smi_cost(int cpu, struct perf_evsel *evsel,
if (cost > 10)
color = PERF_COLOR_RED;
- out->print_metric(out->ctx, color, "%8.1f%%", "SMI cycles%", cost);
- out->print_metric(out->ctx, NULL, "%4.0f", "SMI#", smi_num);
+ out->print_metric(config, out->ctx, color, "%8.1f%%", "SMI cycles%", cost);
+ out->print_metric(config, out->ctx, NULL, "%4.0f", "SMI#", smi_num);
}
-static void generic_metric(const char *metric_expr,
+static void generic_metric(struct perf_stat_config *config,
+ const char *metric_expr,
struct perf_evsel **metric_events,
char *name,
const char *metric_name,
@@ -737,20 +747,21 @@ static void generic_metric(const char *metric_expr,
const char *p = metric_expr;
if (expr__parse(&ratio, &pctx, &p) == 0)
- print_metric(ctxp, NULL, "%8.1f",
+ print_metric(config, ctxp, NULL, "%8.1f",
metric_name ?
metric_name :
out->force_header ? name : "",
ratio);
else
- print_metric(ctxp, NULL, NULL,
+ print_metric(config, ctxp, NULL, NULL,
out->force_header ?
(metric_name ? metric_name : name) : "", 0);
} else
- print_metric(ctxp, NULL, NULL, "", 0);
+ print_metric(config, ctxp, NULL, NULL, "", 0);
}
-void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
+void perf_stat__print_shadow_stats(struct perf_stat_config *config,
+ struct perf_evsel *evsel,
double avg, int cpu,
struct perf_stat_output_ctx *out,
struct rblist *metric_events,
@@ -769,10 +780,10 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
if (total) {
ratio = avg / total;
- print_metric(ctxp, NULL, "%7.2f ",
+ print_metric(config, ctxp, NULL, "%7.2f ",
"insn per cycle", ratio);
} else {
- print_metric(ctxp, NULL, NULL, "insn per cycle", 0);
+ print_metric(config, ctxp, NULL, NULL, "insn per cycle", 0);
}
total = runtime_stat_avg(st, STAT_STALLED_CYCLES_FRONT,
@@ -783,20 +794,20 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
ctx, cpu));
if (total && avg) {
- out->new_line(ctxp);
+ out->new_line(config, ctxp);
ratio = total / avg;
- print_metric(ctxp, NULL, "%7.2f ",
+ print_metric(config, ctxp, NULL, "%7.2f ",
"stalled cycles per insn",
ratio);
} else if (have_frontend_stalled) {
- print_metric(ctxp, NULL, NULL,
+ print_metric(config, ctxp, NULL, NULL,
"stalled cycles per insn", 0);
}
} else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES)) {
if (runtime_stat_n(st, STAT_BRANCHES, ctx, cpu) != 0)
- print_branch_misses(cpu, evsel, avg, out, st);
+ print_branch_misses(config, cpu, evsel, avg, out, st);
else
- print_metric(ctxp, NULL, NULL, "of all branches", 0);
+ print_metric(config, ctxp, NULL, NULL, "of all branches", 0);
} else if (
evsel->attr.type == PERF_TYPE_HW_CACHE &&
evsel->attr.config == ( PERF_COUNT_HW_CACHE_L1D |
@@ -804,9 +815,9 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) {
if (runtime_stat_n(st, STAT_L1_DCACHE, ctx, cpu) != 0)
- print_l1_dcache_misses(cpu, evsel, avg, out, st);
+ print_l1_dcache_misses(config, cpu, evsel, avg, out, st);
else
- print_metric(ctxp, NULL, NULL, "of all L1-dcache hits", 0);
+ print_metric(config, ctxp, NULL, NULL, "of all L1-dcache hits", 0);
} else if (
evsel->attr.type == PERF_TYPE_HW_CACHE &&
evsel->attr.config == ( PERF_COUNT_HW_CACHE_L1I |
@@ -814,9 +825,9 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) {
if (runtime_stat_n(st, STAT_L1_ICACHE, ctx, cpu) != 0)
- print_l1_icache_misses(cpu, evsel, avg, out, st);
+ print_l1_icache_misses(config, cpu, evsel, avg, out, st);
else
- print_metric(ctxp, NULL, NULL, "of all L1-icache hits", 0);
+ print_metric(config, ctxp, NULL, NULL, "of all L1-icache hits", 0);
} else if (
evsel->attr.type == PERF_TYPE_HW_CACHE &&
evsel->attr.config == ( PERF_COUNT_HW_CACHE_DTLB |
@@ -824,9 +835,9 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) {
if (runtime_stat_n(st, STAT_DTLB_CACHE, ctx, cpu) != 0)
- print_dtlb_cache_misses(cpu, evsel, avg, out, st);
+ print_dtlb_cache_misses(config, cpu, evsel, avg, out, st);
else
- print_metric(ctxp, NULL, NULL, "of all dTLB cache hits", 0);
+ print_metric(config, ctxp, NULL, NULL, "of all dTLB cache hits", 0);
} else if (
evsel->attr.type == PERF_TYPE_HW_CACHE &&
evsel->attr.config == ( PERF_COUNT_HW_CACHE_ITLB |
@@ -834,9 +845,9 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) {
if (runtime_stat_n(st, STAT_ITLB_CACHE, ctx, cpu) != 0)
- print_itlb_cache_misses(cpu, evsel, avg, out, st);
+ print_itlb_cache_misses(config, cpu, evsel, avg, out, st);
else
- print_metric(ctxp, NULL, NULL, "of all iTLB cache hits", 0);
+ print_metric(config, ctxp, NULL, NULL, "of all iTLB cache hits", 0);
} else if (
evsel->attr.type == PERF_TYPE_HW_CACHE &&
evsel->attr.config == ( PERF_COUNT_HW_CACHE_LL |
@@ -844,9 +855,9 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) {
if (runtime_stat_n(st, STAT_LL_CACHE, ctx, cpu) != 0)
- print_ll_cache_misses(cpu, evsel, avg, out, st);
+ print_ll_cache_misses(config, cpu, evsel, avg, out, st);
else
- print_metric(ctxp, NULL, NULL, "of all LL-cache hits", 0);
+ print_metric(config, ctxp, NULL, NULL, "of all LL-cache hits", 0);
} else if (perf_evsel__match(evsel, HARDWARE, HW_CACHE_MISSES)) {
total = runtime_stat_avg(st, STAT_CACHEREFS, ctx, cpu);
@@ -854,32 +865,32 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
ratio = avg * 100 / total;
if (runtime_stat_n(st, STAT_CACHEREFS, ctx, cpu) != 0)
- print_metric(ctxp, NULL, "%8.3f %%",
+ print_metric(config, ctxp, NULL, "%8.3f %%",
"of all cache refs", ratio);
else
- print_metric(ctxp, NULL, NULL, "of all cache refs", 0);
+ print_metric(config, ctxp, NULL, NULL, "of all cache refs", 0);
} else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_FRONTEND)) {
- print_stalled_cycles_frontend(cpu, evsel, avg, out, st);
+ print_stalled_cycles_frontend(config, cpu, evsel, avg, out, st);
} else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_BACKEND)) {
- print_stalled_cycles_backend(cpu, evsel, avg, out, st);
+ print_stalled_cycles_backend(config, cpu, evsel, avg, out, st);
} else if (perf_evsel__match(evsel, HARDWARE, HW_CPU_CYCLES)) {
total = runtime_stat_avg(st, STAT_NSECS, 0, cpu);
if (total) {
ratio = avg / total;
- print_metric(ctxp, NULL, "%8.3f", "GHz", ratio);
+ print_metric(config, ctxp, NULL, "%8.3f", "GHz", ratio);
} else {
- print_metric(ctxp, NULL, NULL, "Ghz", 0);
+ print_metric(config, ctxp, NULL, NULL, "Ghz", 0);
}
} else if (perf_stat_evsel__is(evsel, CYCLES_IN_TX)) {
total = runtime_stat_avg(st, STAT_CYCLES, ctx, cpu);
if (total)
- print_metric(ctxp, NULL,
+ print_metric(config, ctxp, NULL,
"%7.2f%%", "transactional cycles",
100.0 * (avg / total));
else
- print_metric(ctxp, NULL, NULL, "transactional cycles",
+ print_metric(config, ctxp, NULL, NULL, "transactional cycles",
0);
} else if (perf_stat_evsel__is(evsel, CYCLES_IN_TX_CP)) {
total = runtime_stat_avg(st, STAT_CYCLES, ctx, cpu);
@@ -888,10 +899,10 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
if (total2 < avg)
total2 = avg;
if (total)
- print_metric(ctxp, NULL, "%7.2f%%", "aborted cycles",
+ print_metric(config, ctxp, NULL, "%7.2f%%", "aborted cycles",
100.0 * ((total2-avg) / total));
else
- print_metric(ctxp, NULL, NULL, "aborted cycles", 0);
+ print_metric(config, ctxp, NULL, NULL, "aborted cycles", 0);
} else if (perf_stat_evsel__is(evsel, TRANSACTION_START)) {
total = runtime_stat_avg(st, STAT_CYCLES_IN_TX,
ctx, cpu);
@@ -900,10 +911,10 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
ratio = total / avg;
if (runtime_stat_n(st, STAT_CYCLES_IN_TX, ctx, cpu) != 0)
- print_metric(ctxp, NULL, "%8.0f",
+ print_metric(config, ctxp, NULL, "%8.0f",
"cycles / transaction", ratio);
else
- print_metric(ctxp, NULL, NULL, "cycles / transaction",
+ print_metric(config, ctxp, NULL, NULL, "cycles / transaction",
0);
} else if (perf_stat_evsel__is(evsel, ELISION_START)) {
total = runtime_stat_avg(st, STAT_CYCLES_IN_TX,
@@ -912,33 +923,33 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
if (avg)
ratio = total / avg;
- print_metric(ctxp, NULL, "%8.0f", "cycles / elision", ratio);
+ print_metric(config, ctxp, NULL, "%8.0f", "cycles / elision", ratio);
} else if (perf_evsel__is_clock(evsel)) {
if ((ratio = avg_stats(&walltime_nsecs_stats)) != 0)
- print_metric(ctxp, NULL, "%8.3f", "CPUs utilized",
+ print_metric(config, ctxp, NULL, "%8.3f", "CPUs utilized",
avg / (ratio * evsel->scale));
else
- print_metric(ctxp, NULL, NULL, "CPUs utilized", 0);
+ print_metric(config, ctxp, NULL, NULL, "CPUs utilized", 0);
} else if (perf_stat_evsel__is(evsel, TOPDOWN_FETCH_BUBBLES)) {
double fe_bound = td_fe_bound(ctx, cpu, st);
if (fe_bound > 0.2)
color = PERF_COLOR_RED;
- print_metric(ctxp, color, "%8.1f%%", "frontend bound",
+ print_metric(config, ctxp, color, "%8.1f%%", "frontend bound",
fe_bound * 100.);
} else if (perf_stat_evsel__is(evsel, TOPDOWN_SLOTS_RETIRED)) {
double retiring = td_retiring(ctx, cpu, st);
if (retiring > 0.7)
color = PERF_COLOR_GREEN;
- print_metric(ctxp, color, "%8.1f%%", "retiring",
+ print_metric(config, ctxp, color, "%8.1f%%", "retiring",
retiring * 100.);
} else if (perf_stat_evsel__is(evsel, TOPDOWN_RECOVERY_BUBBLES)) {
double bad_spec = td_bad_spec(ctx, cpu, st);
if (bad_spec > 0.1)
color = PERF_COLOR_RED;
- print_metric(ctxp, color, "%8.1f%%", "bad speculation",
+ print_metric(config, ctxp, color, "%8.1f%%", "bad speculation",
bad_spec * 100.);
} else if (perf_stat_evsel__is(evsel, TOPDOWN_SLOTS_ISSUED)) {
double be_bound = td_be_bound(ctx, cpu, st);
@@ -955,12 +966,12 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
if (be_bound > 0.2)
color = PERF_COLOR_RED;
if (td_total_slots(ctx, cpu, st) > 0)
- print_metric(ctxp, color, "%8.1f%%", name,
+ print_metric(config, ctxp, color, "%8.1f%%", name,
be_bound * 100.);
else
- print_metric(ctxp, NULL, NULL, name, 0);
+ print_metric(config, ctxp, NULL, NULL, name, 0);
} else if (evsel->metric_expr) {
- generic_metric(evsel->metric_expr, evsel->metric_events, evsel->name,
+ generic_metric(config, evsel->metric_expr, evsel->metric_events, evsel->name,
evsel->metric_name, avg, cpu, out, st);
} else if (runtime_stat_n(st, STAT_NSECS, 0, cpu) != 0) {
char unit = 'M';
@@ -975,9 +986,9 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
unit = 'K';
}
snprintf(unit_buf, sizeof(unit_buf), "%c/sec", unit);
- print_metric(ctxp, NULL, "%8.3f", unit_buf, ratio);
+ print_metric(config, ctxp, NULL, "%8.3f", unit_buf, ratio);
} else if (perf_stat_evsel__is(evsel, SMI_NUM)) {
- print_smi_cost(cpu, evsel, out, st);
+ print_smi_cost(config, cpu, evsel, out, st);
} else {
num = 0;
}
@@ -987,12 +998,12 @@ void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
list_for_each_entry (mexp, &me->head, nd) {
if (num++ > 0)
- out->new_line(ctxp);
- generic_metric(mexp->metric_expr, mexp->metric_events,
+ out->new_line(config, ctxp);
+ generic_metric(config, mexp->metric_expr, mexp->metric_events,
evsel->name, mexp->metric_name,
avg, cpu, out, st);
}
}
if (num == 0)
- print_metric(ctxp, NULL, NULL, NULL, 0);
+ print_metric(config, ctxp, NULL, NULL, NULL, 0);
}
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index da6a706daecc..dffcf2110706 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -135,9 +135,10 @@ bool __perf_evsel_stat__is(struct perf_evsel *evsel,
extern struct runtime_stat rt_stat;
extern struct stats walltime_nsecs_stats;
-typedef void (*print_metric_t)(void *ctx, const char *color, const char *unit,
+typedef void (*print_metric_t)(struct perf_stat_config *config,
+ void *ctx, const char *color, const char *unit,
const char *fmt, double val);
-typedef void (*new_line_t )(void *ctx);
+typedef void (*new_line_t)(struct perf_stat_config *config, void *ctx);
void runtime_stat__init(struct runtime_stat *st);
void runtime_stat__exit(struct runtime_stat *st);
@@ -153,7 +154,8 @@ struct perf_stat_output_ctx {
bool force_header;
};
-void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
+void perf_stat__print_shadow_stats(struct perf_stat_config *config,
+ struct perf_evsel *evsel,
double avg, int cpu,
struct perf_stat_output_ctx *out,
struct rblist *metric_events,
--
2.17.1
next prev parent reply other threads:[~2018-08-30 6:33 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-30 6:32 [PATCH 00/43] perf stat: Make some of the stat code generic Jiri Olsa
2018-08-30 6:32 ` [PATCH 01/43] perf stat: Use evsel->threads in create_perf_stat_counter Jiri Olsa
2018-09-06 13:21 ` [tip:perf/core] perf stat: Use evsel->threads in create_perf_stat_counter() tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 02/43] perf stat: Move initial_delay into struct perf_stat_config Jiri Olsa
2018-09-06 13:21 ` [tip:perf/core] perf stat: Move 'initial_delay' to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 03/43] perf stat: Move no_inherit into struct perf_stat_config Jiri Olsa
2018-09-06 13:22 ` [tip:perf/core] perf stat: Move 'no_inherit' to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 04/43] perf stat: Use local config arg for scale in create_perf_stat_counter Jiri Olsa
2018-09-06 13:22 ` [tip:perf/core] perf stat: Use local config arg for scale in create_perf_stat_counter() tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 05/43] perf stat: Add identifier flag into struct stat_opts Jiri Olsa
2018-09-06 13:23 ` [tip:perf/core] perf stat: Add 'identifier' flag to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 06/43] perf tools: Switch session argument to evlist in perf_event__synthesize_attrs Jiri Olsa
2018-09-06 13:23 ` [tip:perf/core] perf tools: Switch 'session' argument to 'evlist' in perf_event__synthesize_attrs() tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 07/43] perf tools: Add perf_evsel__store_ids function Jiri Olsa
2018-09-06 13:24 ` [tip:perf/core] perf evsel: Introduce perf_evsel__store_ids() tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 08/43] perf stat: Move create_perf_stat_counter into stat.c Jiri Olsa
2018-09-06 13:24 ` [tip:perf/core] perf stat: Move create_perf_stat_counter() to stat.c tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 09/43] perf stat: Rename is_pipe argument to attrs perf_stat_synthesize_config Jiri Olsa
2018-09-06 13:25 ` [tip:perf/core] perf stat: Rename 'is_pipe' argument to 'attrs' in perf_stat_synthesize_config() tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 10/43] perf stat: Add struct perf_stat_config argument to perf_stat_synthesize_config Jiri Olsa
2018-09-06 13:26 ` [tip:perf/core] perf stat: Add 'struct perf_stat_config' argument to perf_stat_synthesize_config() tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 11/43] perf stat: Add struct perf_tool argument to perf_stat_synthesize_config Jiri Olsa
2018-09-06 13:26 ` [tip:perf/core] perf stat: Add 'struct perf_tool' argument to perf_stat_synthesize_config() tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 12/43] perf stat: Add struct perf_evlist argument to perf_stat_synthesize_config Jiri Olsa
2018-09-06 13:27 ` [tip:perf/core] perf stat: Add 'struct perf_evlist' argument to perf_stat_synthesize_config() tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 13/43] perf stat: Add perf_event__handler_t argument to perf_stat_synthesize_config Jiri Olsa
2018-09-06 13:27 ` [tip:perf/core] perf stat: Add 'perf_event__handler_t' argument to perf_stat_synthesize_config() tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 14/43] perf stat: Move perf_stat_synthesize_config into stat.c Jiri Olsa
2018-09-06 13:28 ` [tip:perf/core] perf stat: Move perf_stat_synthesize_config() to stat.c tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 15/43] perf stat: Add perf_evlist__print_counters function Jiri Olsa
2018-09-06 13:28 ` [tip:perf/core] perf stat: Introduce perf_evlist__print_counters() tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 16/43] perf stat: Move STAT_RECORD out of perf_evlist__print_counters Jiri Olsa
2018-09-06 13:29 ` [tip:perf/core] perf stat: Move STAT_RECORD out of perf_evlist__print_counters() tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 17/43] perf stat: Add stat_config argument to perf_evlist__print_counters Jiri Olsa
2018-09-06 13:29 ` [tip:perf/core] perf stat: Add 'struct perf_stat_config' argument to perf_evlist__print_counters() tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 18/43] perf stat: Pass stat_config argument to local print functions Jiri Olsa
2018-09-06 13:30 ` [tip:perf/core] perf stat: Pass 'struct perf_stat_config' " tip-bot for Jiri Olsa
2018-08-30 6:32 ` Jiri Olsa [this message]
2018-09-06 13:30 ` [tip:perf/core] perf stat: Pass a 'struct perf_stat_config' argument to global " tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 20/43] perf stat: Move csv_* into struct perf_stat_config Jiri Olsa
2018-09-06 13:31 ` [tip:perf/core] perf stat: Move csv_* to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 21/43] perf stat: Move interval_clear into struct perf_stat_config Jiri Olsa
2018-09-06 13:31 ` [tip:perf/core] perf stat: Move 'interval_clear' to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 22/43] perf stat: Move metric_only into struct perf_stat_config Jiri Olsa
2018-09-06 13:32 ` [tip:perf/core] perf stat: Move 'metric_only' to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 23/43] perf stat: Move unit_width into struct perf_stat_config Jiri Olsa
2018-09-06 13:33 ` [tip:perf/core] perf stat: Move 'unit_width' to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 24/43] perf stat: Add target argument to perf_evlist__print_counters Jiri Olsa
2018-09-06 13:33 ` [tip:perf/core] perf stat: Add 'target' argument to perf_evlist__print_counters() tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 25/43] perf stat: Pass evlist argument to print functions Jiri Olsa
2018-09-06 13:34 ` [tip:perf/core] perf stat: Pass 'evlist' " tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 26/43] perf stat: Use evsel->evlist instead of evsel_list in collect_all_aliases Jiri Olsa
2018-09-06 13:34 ` [tip:perf/core] perf stat: Use 'evsel->evlist' instead of 'evsel_list' in collect_all_aliases() tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 27/43] perf stat: Move run_count into struct perf_stat_config Jiri Olsa
2018-09-06 13:35 ` [tip:perf/core] perf stat: Move 'run_count' to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 28/43] perf stat: Move metric_only_len into struct perf_stat_config Jiri Olsa
2018-09-06 13:35 ` [tip:perf/core] perf stat: Move 'metric_only_len' to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 29/43] perf stat: Pass stat_config to first_shadow_cpu Jiri Olsa
2018-09-06 13:36 ` [tip:perf/core] perf stat: Pass 'struct perf_stat_config' to first_shadow_cpu() tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 30/43] perf stat: Pass evlist to aggr_update_shadow Jiri Olsa
2018-09-06 13:37 ` [tip:perf/core] perf stat: Pass 'evlist' to aggr_update_shadow() tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 31/43] perf stat: Add walltime_nsecs_stats pointer into struct perf_stat_config Jiri Olsa
2018-09-06 13:37 ` [tip:perf/core] perf stat: Add 'walltime_nsecs_stats' pointer to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 32/43] perf stat: Move null_run into struct perf_stat_config Jiri Olsa
2018-09-06 13:38 ` [tip:perf/core] perf stat: Move 'null_run' to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 33/43] perf stat: Move print_free_counters_hint into struct perf_stat_config Jiri Olsa
2018-09-06 13:38 ` [tip:perf/core] perf stat: Move 'print_free_counters_hint' to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 34/43] perf stat: Move print_mixed_hw_group_error into struct perf_stat_config Jiri Olsa
2018-09-06 13:39 ` [tip:perf/core] perf stat: Move 'print_mixed_hw_group_error' to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 35/43] perf stat: Move ru_* data into struct perf_stat_config Jiri Olsa
2018-09-06 13:39 ` [tip:perf/core] perf stat: Move ru_* data to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 36/43] perf stat: Move *_aggr_* data into struct perf_stat_config Jiri Olsa
2018-09-06 13:40 ` [tip:perf/core] perf stat: Move *_aggr_* data to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 37/43] perf stat: Do not use glovab evsel_list in print functions Jiri Olsa
2018-09-06 13:40 ` [tip:perf/core] perf stat: Do not use the global 'evsel_list' " tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 38/43] perf stat: Move big_num data into struct perf_stat_config Jiri Olsa
2018-09-06 13:41 ` [tip:perf/core] perf stat: Move 'big_num' data to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 39/43] perf stat: Move no_merge data into struct perf_stat_config Jiri Olsa
2018-09-06 13:42 ` [tip:perf/core] perf stat: Move 'no_merge' data to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 40/43] perf stat: Propagate struct target arg to sort_aggr_thread Jiri Olsa
2018-09-06 13:42 ` [tip:perf/core] perf stat: Propagate 'struct target' arg to sort_aggr_thread() tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 41/43] perf stat: Move walltime_* data into struct perf_stat_config Jiri Olsa
2018-09-06 13:43 ` [tip:perf/core] perf stat: Move 'walltime_*' data to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 42/43] perf stat: Move metric_events into struct perf_stat_config Jiri Olsa
2018-09-06 13:43 ` [tip:perf/core] perf stat: Move 'metric_events' to 'struct perf_stat_config' tip-bot for Jiri Olsa
2018-08-30 6:32 ` [PATCH 43/43] perf stat: Move display functions into stat-display.c Jiri Olsa
2018-09-06 13:44 ` [tip:perf/core] perf stat: Move the display functions to stat-display.c tip-bot for Jiri Olsa
2018-08-30 17:54 ` [PATCH 00/43] perf stat: Make some of the stat code generic Arnaldo Carvalho de Melo
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=20180830063252.23729-20-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=andi@firstfloor.org \
--cc=dsahern@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).