summaryrefslogtreecommitdiff
path: root/tools/perf/util/stat-display.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/stat-display.c')
-rw-r--r--tools/perf/util/stat-display.c102
1 files changed, 61 insertions, 41 deletions
diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
index fee7543843a8..583ae4f09c5d 100644
--- a/tools/perf/util/stat-display.c
+++ b/tools/perf/util/stat-display.c
@@ -68,15 +68,15 @@ static void print_cgroup(struct perf_stat_config *config, struct evsel *evsel)
static void aggr_printout(struct perf_stat_config *config,
- struct evsel *evsel, int id, int nr)
+ struct evsel *evsel, struct aggr_cpu_id id, int nr)
{
switch (config->aggr_mode) {
case AGGR_CORE:
fprintf(config->output, "S%d-D%d-C%*d%s%*d%s",
- cpu_map__id_to_socket(id),
- cpu_map__id_to_die(id),
+ id.socket,
+ id.die,
config->csv_output ? 0 : -8,
- cpu_map__id_to_cpu(id),
+ id.core,
config->csv_sep,
config->csv_output ? 0 : 4,
nr,
@@ -84,9 +84,9 @@ static void aggr_printout(struct perf_stat_config *config,
break;
case AGGR_DIE:
fprintf(config->output, "S%d-D%*d%s%*d%s",
- cpu_map__id_to_socket(id << 16),
+ id.socket,
config->csv_output ? 0 : -8,
- cpu_map__id_to_die(id << 16),
+ id.die,
config->csv_sep,
config->csv_output ? 0 : 4,
nr,
@@ -95,7 +95,7 @@ static void aggr_printout(struct perf_stat_config *config,
case AGGR_SOCKET:
fprintf(config->output, "S%*d%s%*d%s",
config->csv_output ? 0 : -5,
- id,
+ id.socket,
config->csv_sep,
config->csv_output ? 0 : 4,
nr,
@@ -104,7 +104,7 @@ static void aggr_printout(struct perf_stat_config *config,
case AGGR_NODE:
fprintf(config->output, "N%*d%s%*d%s",
config->csv_output ? 0 : -5,
- id,
+ id.node,
config->csv_sep,
config->csv_output ? 0 : 4,
nr,
@@ -113,23 +113,23 @@ static void aggr_printout(struct perf_stat_config *config,
case AGGR_NONE:
if (evsel->percore && !config->percore_show_thread) {
fprintf(config->output, "S%d-D%d-C%*d%s",
- cpu_map__id_to_socket(id),
- cpu_map__id_to_die(id),
+ id.socket,
+ id.die,
config->csv_output ? 0 : -3,
- cpu_map__id_to_cpu(id), config->csv_sep);
- } else if (id > -1) {
+ id.core, config->csv_sep);
+ } else if (id.core > -1) {
fprintf(config->output, "CPU%*d%s",
config->csv_output ? 0 : -7,
- evsel__cpus(evsel)->map[id],
+ evsel__cpus(evsel)->map[id.core],
config->csv_sep);
}
break;
case AGGR_THREAD:
fprintf(config->output, "%*s-%*d%s",
config->csv_output ? 0 : 16,
- perf_thread_map__comm(evsel->core.threads, id),
+ perf_thread_map__comm(evsel->core.threads, id.thread),
config->csv_output ? 0 : -8,
- perf_thread_map__pid(evsel->core.threads, id),
+ perf_thread_map__pid(evsel->core.threads, id.thread),
config->csv_sep);
break;
case AGGR_GLOBAL:
@@ -144,7 +144,8 @@ struct outstate {
bool newline;
const char *prefix;
int nfields;
- int id, nr;
+ int nr;
+ struct aggr_cpu_id id;
struct evsel *evsel;
};
@@ -319,13 +320,13 @@ static void print_metric_header(struct perf_stat_config *config,
}
static int first_shadow_cpu(struct perf_stat_config *config,
- struct evsel *evsel, int id)
+ struct evsel *evsel, struct aggr_cpu_id id)
{
struct evlist *evlist = evsel->evlist;
int i;
if (config->aggr_mode == AGGR_NONE)
- return id;
+ return id.core;
if (!config->aggr_get_id)
return 0;
@@ -333,14 +334,17 @@ static int first_shadow_cpu(struct perf_stat_config *config,
for (i = 0; i < evsel__nr_cpus(evsel); i++) {
int cpu2 = evsel__cpus(evsel)->map[i];
- if (config->aggr_get_id(config, evlist->core.cpus, cpu2) == id)
+ if (cpu_map__compare_aggr_cpu_id(
+ config->aggr_get_id(config, evlist->core.cpus, cpu2),
+ id)) {
return cpu2;
+ }
}
return 0;
}
static void abs_printout(struct perf_stat_config *config,
- int id, int nr, struct evsel *evsel, double avg)
+ struct aggr_cpu_id id, int nr, struct evsel *evsel, double avg)
{
FILE *output = config->output;
double sc = evsel->scale;
@@ -393,7 +397,7 @@ static bool is_mixed_hw_group(struct evsel *counter)
return false;
}
-static void printout(struct perf_stat_config *config, int id, int nr,
+static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int nr,
struct evsel *counter, double uval,
char *prefix, u64 run, u64 ena, double noise,
struct runtime_stat *st)
@@ -496,7 +500,8 @@ static void printout(struct perf_stat_config *config, int id, int nr,
static void aggr_update_shadow(struct perf_stat_config *config,
struct evlist *evlist)
{
- int cpu, s2, id, s;
+ int cpu, s;
+ struct aggr_cpu_id s2, id;
u64 val;
struct evsel *counter;
@@ -506,7 +511,7 @@ static void aggr_update_shadow(struct perf_stat_config *config,
val = 0;
for (cpu = 0; cpu < evsel__nr_cpus(counter); cpu++) {
s2 = config->aggr_get_id(config, evlist->core.cpus, cpu);
- if (s2 != id)
+ if (!cpu_map__compare_aggr_cpu_id(s2, id))
continue;
val += perf_counts(counter->counts, cpu, 0)->val;
}
@@ -584,7 +589,7 @@ static bool collect_data(struct perf_stat_config *config, struct evsel *counter,
struct aggr_data {
u64 ena, run, val;
- int id;
+ struct aggr_cpu_id id;
int nr;
int cpu;
};
@@ -593,13 +598,14 @@ static void aggr_cb(struct perf_stat_config *config,
struct evsel *counter, void *data, bool first)
{
struct aggr_data *ad = data;
- int cpu, s2;
+ int cpu;
+ struct aggr_cpu_id s2;
for (cpu = 0; cpu < evsel__nr_cpus(counter); cpu++) {
struct perf_counts_values *counts;
s2 = config->aggr_get_id(config, evsel__cpus(counter), cpu);
- if (s2 != ad->id)
+ if (!cpu_map__compare_aggr_cpu_id(s2, ad->id))
continue;
if (first)
ad->nr++;
@@ -628,7 +634,8 @@ static void print_counter_aggrdata(struct perf_stat_config *config,
struct aggr_data ad;
FILE *output = config->output;
u64 ena, run, val;
- int id, nr;
+ int nr;
+ struct aggr_cpu_id id;
double uval;
ad.id = id = config->aggr_map->map[s];
@@ -649,8 +656,12 @@ static void print_counter_aggrdata(struct perf_stat_config *config,
fprintf(output, "%s", prefix);
uval = val * counter->scale;
- printout(config, cpu != -1 ? cpu : id, nr, counter, uval, prefix,
- run, ena, 1.0, &rt_stat);
+ if (cpu != -1) {
+ id = cpu_map__empty_aggr_cpu_id();
+ id.core = cpu;
+ }
+ printout(config, id, nr, counter, uval,
+ prefix, run, ena, 1.0, &rt_stat);
if (!metric_only)
fputc('\n', output);
}
@@ -728,7 +739,8 @@ static struct perf_aggr_thread_value *sort_aggr_thread(
continue;
buf[i].counter = counter;
- buf[i].id = thread;
+ buf[i].id = cpu_map__empty_aggr_cpu_id();
+ buf[i].id.thread = thread;
buf[i].uval = uval;
buf[i].val = val;
buf[i].run = run;
@@ -751,7 +763,8 @@ static void print_aggr_thread(struct perf_stat_config *config,
FILE *output = config->output;
int nthreads = perf_thread_map__nr(counter->core.threads);
int ncpus = perf_cpu_map__nr(counter->core.cpus);
- int thread, sorted_threads, id;
+ int thread, sorted_threads;
+ struct aggr_cpu_id id;
struct perf_aggr_thread_value *buf;
buf = sort_aggr_thread(counter, nthreads, ncpus, &sorted_threads, _target);
@@ -768,7 +781,7 @@ static void print_aggr_thread(struct perf_stat_config *config,
if (config->stats)
printout(config, id, 0, buf[thread].counter, buf[thread].uval,
prefix, buf[thread].run, buf[thread].ena, 1.0,
- &config->stats[id]);
+ &config->stats[id.thread]);
else
printout(config, id, 0, buf[thread].counter, buf[thread].uval,
prefix, buf[thread].run, buf[thread].ena, 1.0,
@@ -814,8 +827,8 @@ static void print_counter_aggr(struct perf_stat_config *config,
fprintf(output, "%s", prefix);
uval = cd.avg * counter->scale;
- printout(config, -1, 0, counter, uval, prefix, cd.avg_running, cd.avg_enabled,
- cd.avg, &rt_stat);
+ printout(config, cpu_map__empty_aggr_cpu_id(), 0, counter, uval, prefix, cd.avg_running,
+ cd.avg_enabled, cd.avg, &rt_stat);
if (!metric_only)
fprintf(output, "\n");
}
@@ -842,6 +855,7 @@ static void print_counter(struct perf_stat_config *config,
u64 ena, run, val;
double uval;
int cpu;
+ struct aggr_cpu_id id;
for (cpu = 0; cpu < evsel__nr_cpus(counter); cpu++) {
struct aggr_data ad = { .cpu = cpu };
@@ -856,8 +870,10 @@ static void print_counter(struct perf_stat_config *config,
fprintf(output, "%s", prefix);
uval = val * counter->scale;
- printout(config, cpu, 0, counter, uval, prefix, run, ena, 1.0,
- &rt_stat);
+ id = cpu_map__empty_aggr_cpu_id();
+ id.core = cpu;
+ printout(config, id, 0, counter, uval, prefix,
+ run, ena, 1.0, &rt_stat);
fputc('\n', output);
}
@@ -872,6 +888,7 @@ static void print_no_aggr_metric(struct perf_stat_config *config,
struct evsel *counter;
u64 ena, run, val;
double uval;
+ struct aggr_cpu_id id;
nrcpus = evlist->core.cpus->nr;
for (cpu = 0; cpu < nrcpus; cpu++) {
@@ -880,8 +897,10 @@ static void print_no_aggr_metric(struct perf_stat_config *config,
if (prefix)
fputs(prefix, config->output);
evlist__for_each_entry(evlist, counter) {
+ id = cpu_map__empty_aggr_cpu_id();
+ id.core = cpu;
if (first) {
- aggr_printout(config, counter, cpu, 0);
+ aggr_printout(config, counter, id, 0);
first = false;
}
val = perf_counts(counter->counts, cpu, 0)->val;
@@ -889,8 +908,8 @@ static void print_no_aggr_metric(struct perf_stat_config *config,
run = perf_counts(counter->counts, cpu, 0)->run;
uval = val * counter->scale;
- printout(config, cpu, 0, counter, uval, prefix, run, ena, 1.0,
- &rt_stat);
+ printout(config, id, 0, counter, uval, prefix,
+ run, ena, 1.0, &rt_stat);
}
fputc('\n', config->output);
}
@@ -1140,14 +1159,15 @@ static void print_footer(struct perf_stat_config *config)
static void print_percore_thread(struct perf_stat_config *config,
struct evsel *counter, char *prefix)
{
- int s, s2, id;
+ int s;
+ struct aggr_cpu_id s2, id;
bool first = true;
for (int i = 0; i < evsel__nr_cpus(counter); i++) {
s2 = config->aggr_get_id(config, evsel__cpus(counter), i);
for (s = 0; s < config->aggr_map->nr; s++) {
id = config->aggr_map->map[s];
- if (s2 == id)
+ if (cpu_map__compare_aggr_cpu_id(s2, id))
break;
}