Skip to content

Commit e0257a0

Browse files
John Garryacmel
authored andcommitted
perf pmu: Fix alias events list
Commit 0e0ae87 ("perf list: Display hybrid PMU events with cpu type") changes the event list for uncore PMUs or arm64 heterogeneous CPU systems, such that duplicate aliases are incorrectly listed per PMU (which they should not be), like: # perf list ... unc_cbo_cache_lookup.any_es [Unit: uncore_cbox L3 Lookup any request that access cache and found line in E or S-state] unc_cbo_cache_lookup.any_es [Unit: uncore_cbox L3 Lookup any request that access cache and found line in E or S-state] unc_cbo_cache_lookup.any_i [Unit: uncore_cbox L3 Lookup any request that access cache and found line in I-state] unc_cbo_cache_lookup.any_i [Unit: uncore_cbox L3 Lookup any request that access cache and found line in I-state] ... Notice how the events are listed twice. The named commit changed how we remove duplicate events, in that events for different PMUs are not treated as duplicates. I suppose this is to handle how "Each hybrid pmu event has been assigned with a pmu name". Fix PMU alias listing by restoring behaviour to remove duplicates for non-hybrid PMUs. Fixes: 0e0ae87 ("perf list: Display hybrid PMU events with cpu type") Signed-off-by: John Garry <[email protected]> Tested-by: Zhengjun Xing <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 0f80bfb commit e0257a0

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

tools/perf/util/pmu.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,21 @@ bool is_pmu_core(const char *name)
16591659
return !strcmp(name, "cpu") || is_arm_pmu_core(name);
16601660
}
16611661

1662+
static bool pmu_alias_is_duplicate(struct sevent *alias_a,
1663+
struct sevent *alias_b)
1664+
{
1665+
/* Different names -> never duplicates */
1666+
if (strcmp(alias_a->name, alias_b->name))
1667+
return false;
1668+
1669+
/* Don't remove duplicates for hybrid PMUs */
1670+
if (perf_pmu__is_hybrid(alias_a->pmu) &&
1671+
perf_pmu__is_hybrid(alias_b->pmu))
1672+
return false;
1673+
1674+
return true;
1675+
}
1676+
16621677
void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
16631678
bool long_desc, bool details_flag, bool deprecated,
16641679
const char *pmu_name)
@@ -1744,12 +1759,8 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
17441759
qsort(aliases, len, sizeof(struct sevent), cmp_sevent);
17451760
for (j = 0; j < len; j++) {
17461761
/* Skip duplicates */
1747-
if (j > 0 && !strcmp(aliases[j].name, aliases[j - 1].name)) {
1748-
if (!aliases[j].pmu || !aliases[j - 1].pmu ||
1749-
!strcmp(aliases[j].pmu, aliases[j - 1].pmu)) {
1750-
continue;
1751-
}
1752-
}
1762+
if (j > 0 && pmu_alias_is_duplicate(&aliases[j], &aliases[j - 1]))
1763+
continue;
17531764

17541765
if (name_only) {
17551766
printf("%s ", aliases[j].name);

0 commit comments

Comments
 (0)