perf hwmon related improvements
Ian Rogers
reviewercover perf hwmon related improvements
Try to do less scanning of files/directories with or without hwmon PMUs. Don't merge all events with the same name, only merge those on the same PMU ignoring suffix. Refactor uniquification so the evsels with the same name as other evsels in the evlist are uniquified.
Ian Rogers (4):
perf evsel: Reduce scanning core PMUs in is_hybrid perf pmus: Restructure pmu_read_sysfs to scan fewer PMUs perf stat: Don't merge counters purely on name perf stat: Changes to event name uniquification
tools/perf/util/evsel.c | 4 +- tools/perf/util/evsel.h | 1 + tools/perf/util/pmu.h | 2 + tools/perf/util/pmus.c | 144 +++++++++++++++++++++------------ tools/perf/util/stat-display.c | 111 +++++++++++++++++-------- tools/perf/util/stat.c | 13 ++- 6 files changed, 187 insertions(+), 88 deletions(-)
Signature · 1 line
2.48.0.rc2.279.g1de40edade-goog
Ian Rogers
reviewerPATCH 1/4 perf evsel: Reduce scanning core PMUs in is_hybrid
evsel__is_hybrid returns true if there are multiple core PMUs and the evsel is for a core PMU. Determining the number of core PMUs can require loading/scanning PMUs. There's no point doing the scanning if evsel for the is_hybrid test isn't core so reorder the tests to reduce PMU scanning.
--- tools/perf/util/evsel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/evsel.c +2 -2
@@ -3856,10 +3856,10 @@ void evsel__zero_per_pkg(struct evsel *evsel)*/ bool evsel__is_hybrid (const struct evsel *evsel) { -if (perf_pmus__num_core_pmus () ==1 ) +if (!evsel->core.is_pmu_core)return false; -return evsel->core.is_pmu_core; +return perf_pmus__num_core_pmus () >1 ; }struct evsel *evsel__leader (const struct evsel *evsel)
Signature · 1 line
2.48.0.rc2.279.g1de40edade-goog
Ian Rogers
reviewerPATCH 2/4 perf pmus: Restructure pmu_read_sysfs to scan fewer PMUs
In reply to Ian RogersRather than scanning core or all PMUs, allow pmu_read_sysfs to read some combination of core, other, hwmon and tool PMUs. The PMUs that should be read and are already read are held as bitmaps. It is known that a "hwmon_" prefix is necessary for a hwmon PMU's name, similarly with "tool", so only scan those PMUs in situations the PMU name or the PMU's type number make sense to.
The number of openat system calls reduces from 276 to 98 for a hwmon event. The number of openats for regular perf events isn't changed.
--- tools/perf/util/pmu.h | 2 + tools/perf/util/pmus.c | 144 ++++++++++++++++++++++++++--------------- 2 files changed, 95 insertions(+), 51 deletions(-)
tools/perf/util/pmu.h +2 -0
@@ -37,6 +37,8 @@ struct perf_pmu_caps { };enum { +PERF_PMU_TYPE_PE_START =0 , +PERF_PMU_TYPE_PE_END =0xFFFEFFFF ,PERF_PMU_TYPE_HWMON_START =0xFFFF0000 ,PERF_PMU_TYPE_HWMON_END =0xFFFFFFFD ,PERF_PMU_TYPE_TOOL =0xFFFFFFFE ,
tools/perf/util/pmus.c +93 -51
239 lines not on this page · raw message
Signature · 1 line
2.48.0.rc2.279.g1de40edade-goog
Ian Rogers
reviewerPATCH 3/4 perf stat: Don't merge counters purely on name
In reply to Ian RogersCounter merging was added in commit 942c5593393d ("perf stat: Add perf_stat_merge_counters()"), however, it merges events with the same name on different PMUs regardless of whether the different PMUs are actually of the same type (ie they differ only in the suffix on the PMU). For hwmon events there may be a temp1 event on every PMU, but the PMU names are all unique and don't differ just by a suffix. The merging is over eager and will merge all the hwmon counters together meaning an aggregated and very large temp1 value is shown. The same would be true for say cache events and memory controller events where the PMUs differ but the event names are the same.
Fix the problem by correctly saying two PMUs alias when they differ only by suffix.
Note, there is an overlap with evsel's merged_stat with aggregation and the evsel's metric_leader where aggregation happens for metrics.
--- tools/perf/util/stat.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
tools/perf/util/stat.c +11 -2
@@ -535,7 +535,10 @@ static int evsel__merge_aggr_counters(struct evsel *evsel, struct evsel *alias)return 0 ; } -/* events should have the same name, scale, unit, cgroup but on different PMUs */ +/* +* Events should have the same name, scale, unit, cgroup but on different core +* PMUs or on different but matching uncore PMUs. +*/ static bool evsel__is_alias (struct evsel *evsel_a,struct evsel *evsel_b) {if (strcmp (evsel__name (evsel_a),evsel__name (evsel_b)))
@@ -553,7 +556,13 @@ static bool evsel__is_alias(struct evsel *evsel_a, struct evsel *evsel_b)if (evsel__is_clock (evsel_a) !=evsel__is_clock (evsel_b))return false; -return evsel_a->pmu != evsel_b->pmu; +if (evsel_a->pmu == evsel_b->pmu || evsel_a->pmu ==NULL || evsel_b->pmu ==NULL ) +return false; + +if (evsel_a->pmu->is_core) +return evsel_b->pmu->is_core; + +return pmu__name_match (evsel_a->pmu, evsel_b->pmu->name); }static void evsel__merge_aliases (struct evsel *evsel)
Signature · 1 line
2.48.0.rc2.279.g1de40edade-goog
Ian Rogers
reviewerPATCH 4/4 perf stat: Changes to event name uniquification
In reply to Ian RogersThe existing logic would disable uniquification on an evlist or enable it per evsel, this is unfortunate as uniquification is most needed when events have the same name and so the whole evlist must be considered. Change the initial disable uniquify on an evlist processing to also set a needs_uniquify flag, for cases like the matching event names. This must be done as an initial pass as uniquification of an event name will change the behavior of the check. Keep the per counter uniquification but now only uniquify event names when the needs_uniquify flag is set.
Before this change a hwmon like temp1 wouldn't be uniquified and afterwards it will (ie the PMU is added to the temp1 event's name).
--- tools/perf/util/evsel.h | 1 + tools/perf/util/stat-display.c | 111 +++++++++++++++++++++++---------- 2 files changed, 79 insertions(+), 33 deletions(-)
tools/perf/util/evsel.h +1 -0
@@ -119,6 +119,7 @@ struct evsel {bool errored;bool needs_auxtrace_mmap;bool default_metricgroup;/* A member of the Default metricgroup */ +bool needs_uniquify;struct hashmap *per_pkg_mask;int err;int script_output_type;
tools/perf/util/stat-display.c +78 -33
167 lines not on this page · raw message
Signature · 1 line
2.48.0.rc2.279.g1de40edade-goog