Skip to content

Commit e94d6b7

Browse files
Kan Liangacmel
authored andcommitted
perf pmu: Fix parser error for uncore event alias
Perf fails to parse uncore event alias, for example: # perf stat -e unc_m_clockticks -a --no-merge sleep 1 event syntax error: 'unc_m_clockticks' \___ parser error Current code assumes that the event alias is from one specific PMU. To find the PMU, perf strcmps the PMU name of event alias with the real PMU name on the system. However, the uncore event alias may be from multiple PMUs with common prefix. The PMU name of uncore event alias is the common prefix. For example, UNC_M_CLOCKTICKS is clock event for iMC, which include 6 PMUs with the same prefix "uncore_imc" on a skylake server. The real PMU names on the system for iMC are uncore_imc_0 ... uncore_imc_5. The strncmp is used to only check the common prefix for uncore event alias. With the patch: # perf stat -e unc_m_clockticks -a --no-merge sleep 1 Performance counter stats for 'system wide': 723,594,722 unc_m_clockticks [uncore_imc_5] 724,001,954 unc_m_clockticks [uncore_imc_3] 724,042,655 unc_m_clockticks [uncore_imc_1] 724,161,001 unc_m_clockticks [uncore_imc_4] 724,293,713 unc_m_clockticks [uncore_imc_2] 724,340,901 unc_m_clockticks [uncore_imc_0] 1.002090060 seconds time elapsed Signed-off-by: Kan Liang <kan.liang@linux.intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Andi Kleen <ak@linux.intel.com> Cc: Thomas Richter <tmricht@linux.ibm.com> Cc: stable@vger.kernel.org Fixes: ea1fa48 ("perf stat: Handle different PMU names with common prefix") Link: http://lkml.kernel.org/r/1552672814-156173-1-git-send-email-kan.liang@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 606bd60 commit e94d6b7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tools/perf/util/pmu.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,10 +732,20 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
732732

733733
if (!is_arm_pmu_core(name)) {
734734
pname = pe->pmu ? pe->pmu : "cpu";
735+
736+
/*
737+
* uncore alias may be from different PMU
738+
* with common prefix
739+
*/
740+
if (pmu_is_uncore(name) &&
741+
!strncmp(pname, name, strlen(pname)))
742+
goto new_alias;
743+
735744
if (strcmp(pname, name))
736745
continue;
737746
}
738747

748+
new_alias:
739749
/* need type casts to override 'const' */
740750
__perf_pmu__new_alias(head, NULL, (char *)pe->name,
741751
(char *)pe->desc, (char *)pe->event,

0 commit comments

Comments
 (0)