[lkml]   [2019]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 4.19 115/134] perf pmu: Fix parser error for uncore event alias
4.19-stable review patch.  If anyone has any objections, please let me know.


From: Kan Liang <>

commit e94d6b7f615e6dfbaf9fba7db6011db561461d0c upstream.

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 ...

The strncmp is used to only check the common prefix for uncore event

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 <>
Acked-by: Jiri Olsa <>
Cc: Andi Kleen <>
Cc: Thomas Richter <>
Fixes: ea1fa48c055f ("perf stat: Handle different PMU names with common prefix")
Signed-off-by: Arnaldo Carvalho de Melo <>
Signed-off-by: Greg Kroah-Hartman <>

tools/perf/util/pmu.c | 10 ++++++++++
1 file changed, 10 insertions(+)

--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -773,10 +773,20 @@ static void pmu_add_cpu_aliases(struct l

if (!is_arm_pmu_core(name)) {
pname = pe->pmu ? pe->pmu : "cpu";
+ /*
+ * uncore alias may be from different PMU
+ * with common prefix
+ */
+ if (pmu_is_uncore(name) &&
+ !strncmp(pname, name, strlen(pname)))
+ goto new_alias;
if (strcmp(pname, name))

/* need type casts to override 'const' */
__perf_pmu__new_alias(head, NULL, (char *)pe->name,
(char *)pe->desc, (char *)pe->event,

 \ /
  Last update: 2019-04-01 19:58    [W:0.361 / U:1.792 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site