Commit e0128b30 authored by Jin Yao's avatar Jin Yao Committed by Arnaldo Carvalho de Melo

perf stat: Print per-thread shadow stats

The function perf_stat__print_shadow_stats() is called to print the
shadow stats on a set of static variables.

But the static variables are the limitations to support
per-thread shadow stats.

This patch lets the perf_stat__print_shadow_stats() support
to print the shadow stats from a input parameter 'st'.

It will not directly get value from static variable. Instead,
it now uses runtime_stat_avg() and runtime_stat_n() to get and
compute the values.
Signed-off-by: default avatarJin Yao <yao.jin@linux.intel.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1512482591-4646-6-git-send-email-yao.jin@linux.intel.com
[ Rename 'stat' variables to 'st' to build on centos:{5,6} and others where it shadows a global declaration ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 1fcd0394
......@@ -1557,7 +1557,8 @@ static void perf_sample__fprint_metric(struct perf_script *script,
evsel_script(ev2)->val,
sample->cpu,
&ctx,
NULL);
NULL,
&rt_stat);
}
evsel_script(evsel->leader)->gnum = 0;
}
......
......@@ -1097,7 +1097,8 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
}
static void printout(int id, int nr, struct perf_evsel *counter, double uval,
char *prefix, u64 run, u64 ena, double noise)
char *prefix, u64 run, u64 ena, double noise,
struct runtime_stat *st)
{
struct perf_stat_output_ctx out;
struct outstate os = {
......@@ -1190,7 +1191,7 @@ static void printout(int id, int nr, struct perf_evsel *counter, double uval,
perf_stat__print_shadow_stats(counter, uval,
first_shadow_cpu(counter, id),
&out, &metric_events);
&out, &metric_events, st);
if (!csv_output && !metric_only) {
print_noise(counter, noise);
print_running(run, ena);
......@@ -1335,7 +1336,8 @@ static void print_aggr(char *prefix)
fprintf(output, "%s", prefix);
uval = val * counter->scale;
printout(id, nr, counter, uval, prefix, run, ena, 1.0);
printout(id, nr, counter, uval, prefix, run, ena, 1.0,
&rt_stat);
if (!metric_only)
fputc('\n', output);
}
......@@ -1365,7 +1367,8 @@ static void print_aggr_thread(struct perf_evsel *counter, char *prefix)
fprintf(output, "%s", prefix);
uval = val * counter->scale;
printout(thread, 0, counter, uval, prefix, run, ena, 1.0);
printout(thread, 0, counter, uval, prefix, run, ena, 1.0,
&rt_stat);
fputc('\n', output);
}
}
......@@ -1402,7 +1405,8 @@ static void print_counter_aggr(struct perf_evsel *counter, char *prefix)
fprintf(output, "%s", prefix);
uval = cd.avg * counter->scale;
printout(-1, 0, counter, uval, prefix, cd.avg_running, cd.avg_enabled, cd.avg);
printout(-1, 0, counter, uval, prefix, cd.avg_running, cd.avg_enabled,
cd.avg, &rt_stat);
if (!metric_only)
fprintf(output, "\n");
}
......@@ -1441,7 +1445,8 @@ static void print_counter(struct perf_evsel *counter, char *prefix)
fprintf(output, "%s", prefix);
uval = val * counter->scale;
printout(cpu, 0, counter, uval, prefix, run, ena, 1.0);
printout(cpu, 0, counter, uval, prefix, run, ena, 1.0,
&rt_stat);
fputc('\n', output);
}
......@@ -1473,7 +1478,8 @@ static void print_no_aggr_metric(char *prefix)
run = perf_counts(counter->counts, cpu, 0)->run;
uval = val * counter->scale;
printout(cpu, 0, counter, uval, prefix, run, ena, 1.0);
printout(cpu, 0, counter, uval, prefix, run, ena, 1.0,
&rt_stat);
}
fputc('\n', stat_config.output);
}
......@@ -1529,7 +1535,8 @@ static void print_metric_headers(const char *prefix, bool no_indent)
perf_stat__print_shadow_stats(counter, 0,
0,
&out,
&metric_events);
&metric_events,
&rt_stat);
}
fputc('\n', stat_config.output);
}
......
This diff is collapsed.
......@@ -140,7 +140,8 @@ struct perf_stat_output_ctx {
void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
double avg, int cpu,
struct perf_stat_output_ctx *out,
struct rblist *metric_events);
struct rblist *metric_events,
struct runtime_stat *st);
void perf_stat__collect_metric_expr(struct perf_evlist *);
int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment