[PATCH v2 6/9] perf stat: Check merged PMU instance's cpumasks when skipping zero counts
Besar Wicaksono
bwicaksono at nvidia.com
Fri Oct 30 10:48:13 PDT 2026
Commit dd15480a3d67 ("perf stat: Hide invalid uncore event output for
aggr mode") hides a 0 count of an uncore event in an aggregation id
that the event is not counted in, using the event's cpumask. When an
uncore event has more than one PMU instance, the evsels of the other
instances are merged into the evsel of the first one, and only the
cpumask of the first instance is checked. A 0 count in an aggregation
id covered only by another instance is then hidden, while a non-zero
count in the same id is printed.
For example, on a dual-socket NVIDIA Tegra410 with one UCF PMU per
socket (nvidia_ucf_pmu_0 on CPU 0, nvidia_ucf_pmu_1 on CPU 88):
Before:
$ perf stat -a --per-socket -e UCF_SLC_ACCESS_ATOMIC,UCF_SLC_ACCESS_RD -- sleep 1
S268435456 1 0 UCF_SLC_ACCESS_ATOMIC
S268435456 1 3,407,373 UCF_SLC_ACCESS_RD
S285212672 1 2,086,640 UCF_SLC_ACCESS_RD
After:
$ perf stat -a --per-socket -e UCF_SLC_ACCESS_ATOMIC,UCF_SLC_ACCESS_RD -- sleep 1
S268435456 1 0 UCF_SLC_ACCESS_ATOMIC
S268435456 1 2,669,279 UCF_SLC_ACCESS_RD
S285212672 1 0 UCF_SLC_ACCESS_ATOMIC
S285212672 1 1,006,579 UCF_SLC_ACCESS_RD
Also check the cpumasks of the evsels merged into the counter. Zero
counts are still hidden in aggregation ids that none of the instances
count in, such as the other cores in --per-core mode. Core PMUs and
--no-aggr output are unchanged.
Fixes: dd15480a3d67 ("perf stat: Hide invalid uncore event output for aggr mode")
Signed-off-by: Besar Wicaksono <bwicaksono at nvidia.com>
---
tools/perf/util/stat-display.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
index b337cc23f413..493ed6c88685 100644
--- a/tools/perf/util/stat-display.c
+++ b/tools/perf/util/stat-display.c
@@ -894,6 +894,7 @@ static bool should_skip_zero_counter(struct perf_stat_config *config,
struct evsel *counter,
const struct aggr_cpu_id *id)
{
+ struct evsel *alias;
struct perf_cpu cpu;
unsigned int idx;
@@ -946,6 +947,25 @@ static bool should_skip_zero_counter(struct perf_stat_config *config,
if (aggr_cpu_id__equal(id, &own_id))
return false;
}
+
+ if (config->aggr_mode == AGGR_NONE || !counter->pmu || counter->pmu->is_core)
+ return true;
+
+ /*
+ * A merged uncore counter also counts on the CPUs of the other PMU
+ * instances merged into it, for example on another socket.
+ */
+ evlist__for_each_entry(counter->evlist, alias) {
+ if (alias->first_wildcard_match != counter)
+ continue;
+
+ perf_cpu_map__for_each_cpu(cpu, idx, alias->core.cpus) {
+ struct aggr_cpu_id own_id = config->aggr_get_id(config, cpu);
+
+ if (aggr_cpu_id__equal(id, &own_id))
+ return false;
+ }
+ }
return true;
}
--
2.43.0
More information about the linux-arm-kernel
mailing list