perf stat: Don't print uncounted hwmon events
Ian Rogers
reviewerPATCH 1/1 perf stat: Don't print uncounted hwmon events
Aggregation is different for core events compared to uncore. For uncore we don't want the counts for events not in the aggregation id. Switch the !counter->pmu->is_uncore test to a counter->pmu->is_core as the hwmon PMU doesn't set the uncore boolean. There are 2 booleans as some PMUs forget to set either cpumask or cpus that are used to determine whether a PMU is uncore or core. Also check config->aggr_get_id is present as the non-core 'software' PMU doesn't have it set.
Before:
```
$ perf stat --per-core -e temp_cpu -a true
Performance counter stats for 'system wide':
S0-D0-C0 1 63.00 'C temp_cpu
S0-D0-C1 0 <not counted> 'C temp_cpu
S0-D0-C2 0 <not counted> 'C temp_cpu
S0-D0-C3 0 <not counted> 'C temp_cpu
S0-D0-C4 0 <not counted> 'C temp_cpu
S0-D0-C5 0 <not counted> 'C temp_cpu
S0-D0-C6 0 <not counted> 'C temp_cpu
S0-D0-C7 0 <not counted> 'C temp_cpu
0.001375790 seconds time elapsed
```After:
```
$ perf stat --per-core -e temp_cpu -a true
Performance counter stats for 'system wide':
S0-D0-C0 1 38.00 'C temp_cpu
0.001260575 seconds time elapsed
```--- tools/perf/util/stat-display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/stat-display.c +1 -1
@@ -981,7 +981,7 @@ static bool should_skip_zero_counter(struct perf_stat_config *config,* Skip value 0 when it's an uncore event and the given aggr id * does not belong to the PMU cpumask. */ -if (!counter->pmu || !counter->pmu->is_uncore) +if (!counter->pmu || counter->pmu->is_core || !config->aggr_get_id)return false;perf_cpu_map__for_each_cpu (cpu, idx, counter->pmu->cpus) {
Signature · 1 line
2.49.0.472.ge94155a9ec-goog
Quoted 48 lines · Ian Rogers
Aggregation is different for core events compared to uncore. For uncore we don't want the counts for events not in the aggregation id. Switch the !counter->pmu->is_uncore test to a
counter->pmu->is_coreas the hwmon PMU doesn't set the uncore boolean. There are 2 booleans as some PMUs forget to set either cpumask or cpus that are used to determine whether a PMU is uncore or core. Also checkconfig->aggr_get_idis present as the non-core 'software' PMU doesn't have it set.Before:
``` $ perf stat --per-core -e temp_cpu -a true Performance counter stats for 'system wide': S0-D0-C0 1 63.00 'C temp_cpu S0-D0-C1 0 <not counted> 'C temp_cpu S0-D0-C2 0 <not counted> 'C temp_cpu S0-D0-C3 0 <not counted> 'C temp_cpu S0-D0-C4 0 <not counted> 'C temp_cpu S0-D0-C5 0 <not counted> 'C temp_cpu S0-D0-C6 0 <not counted> 'C temp_cpu S0-D0-C7 0 <not counted> 'C temp_cpu 0.001375790 seconds time elapsed ```After:
``` $ perf stat --per-core -e temp_cpu -a true Performance counter stats for 'system wide': S0-D0-C0 1 38.00 'C temp_cpu 0.001260575 seconds time elapsed ```Signed-off-by Ian Rogers <[email protected]>--- tools/perf/util/stat-display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/util/stat-display.c +0
-0
tools/perf/util/stat-display.c static bool should_skip_zero_counter(struct perf_stat_config *config, · line 987
Quoted 8 lines
tools/perf/util/stat-display.c +1
-1@@ -981,7 +981,7 @@ static bool should_skip_zero_counter(struct perf_stat_config *config,* Skip value 0 when it's an uncore event and the given aggr id * does not belong to the PMU cpumask. */ -if (!counter->pmu || !counter->pmu->is_uncore) +if (!counter->pmu || counter->pmu->is_core || !config->aggr_get_id)return false;perf_cpu_map__for_each_cpu (cpu, idx, counter->pmu->cpus) {