Commit 570c44a0 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf stat: Avoid printing cpus with no counters

perf_evlist's user_requested_cpus can contain CPUs not present in any
evsel's cpus, for example uncore counters. Avoid printing the prefix and
trailing \n until the first valid counter is encountered.
Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: German Gomez <german.gomez@arm.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: John Garry <john.garry@huawei.com>
Cc: KP Singh <kpsingh@kernel.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Martin KaFai Lau <kafai@fb.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Riccardo Mancini <rickyman7@gmail.com>
Cc: Song Liu <songliubraving@fb.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Yonghong Song <yhs@fb.com>
Link: http://lore.kernel.org/lkml/20220503041757.2365696-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 4d27cf1d
...@@ -948,8 +948,6 @@ static void print_no_aggr_metric(struct perf_stat_config *config, ...@@ -948,8 +948,6 @@ static void print_no_aggr_metric(struct perf_stat_config *config,
struct evsel *counter; struct evsel *counter;
bool first = true; bool first = true;
if (prefix)
fputs(prefix, config->output);
evlist__for_each_entry(evlist, counter) { evlist__for_each_entry(evlist, counter) {
u64 ena, run, val; u64 ena, run, val;
double uval; double uval;
...@@ -961,6 +959,8 @@ static void print_no_aggr_metric(struct perf_stat_config *config, ...@@ -961,6 +959,8 @@ static void print_no_aggr_metric(struct perf_stat_config *config,
id = aggr_cpu_id__cpu(cpu, /*data=*/NULL); id = aggr_cpu_id__cpu(cpu, /*data=*/NULL);
if (first) { if (first) {
if (prefix)
fputs(prefix, config->output);
aggr_printout(config, counter, id, 0); aggr_printout(config, counter, id, 0);
first = false; first = false;
} }
...@@ -972,7 +972,8 @@ static void print_no_aggr_metric(struct perf_stat_config *config, ...@@ -972,7 +972,8 @@ static void print_no_aggr_metric(struct perf_stat_config *config,
printout(config, id, 0, counter, uval, prefix, printout(config, id, 0, counter, uval, prefix,
run, ena, 1.0, &rt_stat); run, ena, 1.0, &rt_stat);
} }
fputc('\n', config->output); if (!first)
fputc('\n', config->output);
} }
} }
......
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