All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] perf pmu: Fix core PMU alias list for X86 platform
@ 2018-04-24 18:20 kan.liang
  2018-04-24 18:20 ` [PATCH 2/5] perf stat: Print out hint for mixed PMU group error kan.liang
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: kan.liang @ 2018-04-24 18:20 UTC (permalink / raw)
  To: acme, mingo, peterz, linux-kernel
  Cc: jolsa, namhyung, ganapatrao.kulkarni, zhangshaokun, yao.jin,
	will.deacon, ak, agustinv, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

When counting uncore event with alias, core event is mistakenly
involved, for example:

  perf stat --no-merge -e "unc_m_cas_count.all" -C0  sleep 1

  Performance counter stats for 'CPU(s) 0':

                 0      unc_m_cas_count.all [uncore_imc_4]
                 0      unc_m_cas_count.all [uncore_imc_2]
                 0      unc_m_cas_count.all [uncore_imc_0]
           153,640      unc_m_cas_count.all [cpu]
                 0      unc_m_cas_count.all [uncore_imc_5]
            25,026      unc_m_cas_count.all [uncore_imc_3]
                 0      unc_m_cas_count.all [uncore_imc_1]

       1.001447890 seconds time elapsed

The reason is that current implementation doesn't check PMU name of a
event when adding its alias into the alias list for core PMU. The
uncore event aliases are mistakenly added.

This bug was introduced in:
  commit 14b22ae028de ("perf pmu: Add helper function is_pmu_core to
  detect PMU CORE devices")

Checking the PMU name for all PMUs on X86 and other architectures except
ARM.
There is no behavior change for ARM.

Fixes: 14b22ae028de ("perf pmu: Add helper function is_pmu_core to detect PMU CORE devices")
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/util/pmu.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 064bdcb..0df2a02 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -539,9 +539,10 @@ static bool pmu_is_uncore(const char *name)
 
 /*
  *  PMU CORE devices have different name other than cpu in sysfs on some
- *  platforms. looking for possible sysfs files to identify as core device.
+ *  platforms.
+ *  Looking for possible sysfs files to identify the arm core device.
  */
-static int is_pmu_core(const char *name)
+static int is_arm_pmu_core(const char *name)
 {
 	struct stat st;
 	char path[PATH_MAX];
@@ -550,12 +551,6 @@ static int is_pmu_core(const char *name)
 	if (!sysfs)
 		return 0;
 
-	/* Look for cpu sysfs (x86 and others) */
-	scnprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu", sysfs);
-	if ((stat(path, &st) == 0) &&
-			(strncmp(name, "cpu", strlen("cpu")) == 0))
-		return 1;
-
 	/* Look for cpu sysfs (specific to arm) */
 	scnprintf(path, PATH_MAX, "%s/bus/event_source/devices/%s/cpus",
 				sysfs, name);
@@ -662,6 +657,7 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 	struct pmu_events_map *map;
 	struct pmu_event *pe;
 	const char *name = pmu->name;
+	const char *pname;
 
 	map = perf_pmu__find_map(pmu);
 	if (!map)
@@ -680,11 +676,9 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 			break;
 		}
 
-		if (!is_pmu_core(name)) {
-			/* check for uncore devices */
-			if (pe->pmu == NULL)
-				continue;
-			if (strncmp(pe->pmu, name, strlen(pe->pmu)))
+		if (!is_arm_pmu_core(name)) {
+			pname = pe->pmu ? pe->pmu : "cpu";
+			if (strncmp(pname, name, strlen(pname)))
 				continue;
 		}
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2018-04-26  5:59 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-24 18:20 [PATCH 1/5] perf pmu: Fix core PMU alias list for X86 platform kan.liang
2018-04-24 18:20 ` [PATCH 2/5] perf stat: Print out hint for mixed PMU group error kan.liang
2018-04-26  5:56   ` [tip:perf/urgent] " tip-bot for Kan Liang
2018-04-24 18:20 ` [PATCH 3/5] perf evsel: Only fall back group read for leader kan.liang
2018-04-26  5:57   ` [tip:perf/urgent] " tip-bot for Kan Liang
2018-04-24 18:20 ` [PATCH 4/5] perf parse-events: Specially handle uncore event alias in small groups kan.liang
2018-04-24 19:17   ` Arnaldo Carvalho de Melo
2018-04-24 19:23     ` Liang, Kan
2018-04-24 19:29       ` Arnaldo Carvalho de Melo
2018-04-25 12:27         ` Liang, Kan
2018-04-25 12:59           ` Arnaldo Carvalho de Melo
2018-04-25 13:39             ` Liang, Kan
2018-04-24 18:20 ` [PATCH 5/5] perf stat: Fix duplicate PMU name for interval print kan.liang
2018-04-24 18:53   ` Arnaldo Carvalho de Melo
2018-04-24 19:18     ` Liang, Kan
2018-04-24 19:29       ` Arnaldo Carvalho de Melo
2018-04-26  5:57   ` [tip:perf/urgent] " tip-bot for Kan Liang
2018-04-26  5:56 ` [tip:perf/urgent] perf pmu: Fix core PMU alias list for X86 platform tip-bot for Kan Liang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.