Skip to contentSkip to conversation

Perf uncore PMU event alias support for Hisi hip08 ARM64 platform

PATCH Superseded John Garry 4 participants 19 messages Jun 14, 2019 – Jun 28, 2019

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

John Garry

author
#0 lore raw

v2 cover Perf uncore PMU event alias support for Hisi hip08 ARM64 platform

This patchset adds support for uncore PMU event aliasing for HiSilicon hip08 ARM64 platform.

We can now get proper event description for uncore events for the perf tool.

For HHA, DDRC, and L3C JSONs, we don't have all the event info yet, so I will seek it out to update the JSONs later.

Changes to v2:
- Use strtok_r() in pmu_uncore_alias_match()
- from "sccl" from uncore aliases

John Garry (5):
perf pmu: Fix uncore PMU alias list for ARM64 perf pmu: Support more complex PMU event aliasing perf jevents: Add support for Hisi hip08 DDRC PMU aliasing perf jevents: Add support for Hisi hip08 HHA PMU aliasing perf jevents: Add support for Hisi hip08 L3C PMU aliasing

 .../arm64/hisilicon/hip08/uncore-ddrc.json    | 44 ++++++++++++++
 .../arm64/hisilicon/hip08/uncore-hha.json     | 51 +++++++++++++++++
 .../arm64/hisilicon/hip08/uncore-l3c.json     | 37 ++++++++++++
 tools/perf/pmu-events/jevents.c               |  3 +
 tools/perf/util/pmu.c                         | 57 +++++++++++++------
 5 files changed, 176 insertions(+), 16 deletions(-)
 create mode 100644 tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-ddrc.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-hha.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-l3c.json
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 1/5 perf pmu: Fix uncore PMU alias list for ARM64

In commit 292c34c10249 ("perf pmu: Fix core PMU alias list for X86 platform"), we fixed the issue of CPU events being aliased to uncore events.

Fix this same issue for ARM64, since the said commit left the (broken) behaviour untouched for ARM64.

---
 tools/perf/util/pmu.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)
tools/perf/util/pmu.c +12 -16
index f2eff272279b..7e7299fee550 100644
@@ -709,9 +709,7 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 {
 	int i;
 	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)
@@ -722,28 +720,26 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 	 */
 	i = 0;
 	while (1) {
+		const char *cpu_name = is_arm_pmu_core(name) ? name : "cpu";
+		struct pmu_event *pe = &map->table[i++];
+		const char *pname = pe->pmu ? pe->pmu : cpu_name;
 
-		pe = &map->table[i++];
 		if (!pe->name) {
 			if (pe->metric_group || pe->metric_name)
 				continue;
 			break;
 		}
 
-		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;
+		/*
+		 * 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))
-				continue;
-		}
+		if (strcmp(pname, name))
+			continue;
 
 new_alias:
 		pr_err("%s new_alias name=%s pe->name=%s\n", __func__, name, pe->name);
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH v2 1/5] perf pmu: Fix uncore PMU alias list for ARM64

Em Fri, Jun 14, 2019 at 10:07:59PM +0800, John Garry escreveu:

Quoted 6 lines

In commit 292c34c10249 ("perf pmu: Fix core PMU alias list for X86 platform"), we fixed the issue of CPU events being aliased to uncore events.

Fix this same issue for ARM64, since the said commit left the (broken) behaviour untouched for ARM64.

So I added:

Fixes 292c34c10249 ("perf pmu: Fix core PMU alias list for X86 platform")

So that the stable trees get this fix and add it to the versions where it should have been together with the x86 fix, ok?

- Arnaldo

Quoted 62 lines
---
 tools/perf/util/pmu.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)
tools/perf/util/pmu.c +12 -16
index f2eff272279b..7e7299fee550 100644
@@ -709,9 +709,7 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 {
 	int i;
 	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)
@@ -722,28 +720,26 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 	 */
 	i = 0;
 	while (1) {
+		const char *cpu_name = is_arm_pmu_core(name) ? name : "cpu";
+		struct pmu_event *pe = &map->table[i++];
+		const char *pname = pe->pmu ? pe->pmu : cpu_name;
 
-		pe = &map->table[i++];
 		if (!pe->name) {
 			if (pe->metric_group || pe->metric_name)
 				continue;
 			break;
 		}
 
-		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;
+		/*
+		 * 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))
-				continue;
-		}
+		if (strcmp(pname, name))
+			continue;
 
 new_alias:
 		pr_err("%s new_alias name=%s pe->name=%s\n", __func__, name, pe->name);
Signature · 1 line
2.17.1
Signature · 1 line
- Arnaldo
author
#3 lore raw

Re: [PATCH v2 1/5] perf pmu: Fix uncore PMU alias list for ARM64

Quoted 8 lines · Arnaldo Carvalho de Melo

Em Fri, Jun 14, 2019 at 10:07:59PM +0800, John Garry escreveu:

Quoted 6 lines

In commit 292c34c10249 ("perf pmu: Fix core PMU alias list for X86 platform"), we fixed the issue of CPU events being aliased to uncore events.

Fix this same issue for ARM64, since the said commit left the (broken) behaviour untouched for ARM64.

Quoted 7 lines

So I added:

Fixes 292c34c10249 ("perf pmu: Fix core PMU alias list for X86 platform")

So that the stable trees get this fix and add it to the versions where it should have been together with the x86 fix, ok?

Hi Arnaldo,

I have a slight hesitation about this qualifying for the stable.

It's fixing uncore pmu aliasing for arm64. But this series is also the first to introduce any actual arm64 uncore pmu aliases.

Thanks,
John

Quoted 66 lines

- Arnaldo

Quoted 62 lines
---
 tools/perf/util/pmu.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)
tools/perf/util/pmu.c +12 -17
index f2eff272279b..7e7299fee550 100644
@@ -709,9 +709,7 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 {
 	int i;
 	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)
@@ -722,28 +720,26 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 	 */
 	i = 0;
 	while (1) {
+		const char *cpu_name = is_arm_pmu_core(name) ? name : "cpu";
+		struct pmu_event *pe = &map->table[i++];
+		const char *pname = pe->pmu ? pe->pmu : cpu_name;
 
-		pe = &map->table[i++];
 		if (!pe->name) {
 			if (pe->metric_group || pe->metric_name)
 				continue;
 			break;
 		}
 
-		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;
+		/*
+		 * 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))
-				continue;
-		}
+		if (strcmp(pname, name))
+			continue;
 
 new_alias:
 		pr_err("%s new_alias name=%s pe->name=%s\n", __func__, name, pe->name);
--

2.17.1

#4 lore raw

Re: [PATCH v2 1/5] perf pmu: Fix uncore PMU alias list for ARM64

Em Fri, Jun 14, 2019 at 04:04:26PM +0100, John Garry escreveu:

Quoted 17 lines · Arnaldo Carvalho de Melo
Quoted 8 lines

Em Fri, Jun 14, 2019 at 10:07:59PM +0800, John Garry escreveu:

Quoted 6 lines

In commit 292c34c10249 ("perf pmu: Fix core PMU alias list for X86 platform"), we fixed the issue of CPU events being aliased to uncore events.

Fix this same issue for ARM64, since the said commit left the (broken) behaviour untouched for ARM64.

Quoted 7 lines

So I added:

Fixes 292c34c10249 ("perf pmu: Fix core PMU alias list for X86 platform")

So that the stable trees get this fix and add it to the versions where it should have been together with the x86 fix, ok?

Quoted 6 lines

Hi Arnaldo,

I have a slight hesitation about this qualifying for the stable.

It's fixing uncore pmu aliasing for arm64. But this series is also the first to introduce any actual arm64 uncore pmu aliases.

I'm not talking about the whole series, just the first patch, the one you said should've been done together with the equivalent fix for x86.

- Arnaldo

Quoted 70 lines

Thanks,
John

Quoted 66 lines

- Arnaldo

Quoted 62 lines
---
 tools/perf/util/pmu.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)
tools/perf/util/pmu.c +12 -17
index f2eff272279b..7e7299fee550 100644
@@ -709,9 +709,7 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 {
 	int i;
 	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)
@@ -722,28 +720,26 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 	 */
 	i = 0;
 	while (1) {
+		const char *cpu_name = is_arm_pmu_core(name) ? name : "cpu";
+		struct pmu_event *pe = &map->table[i++];
+		const char *pname = pe->pmu ? pe->pmu : cpu_name;
 
-		pe = &map->table[i++];
 		if (!pe->name) {
 			if (pe->metric_group || pe->metric_name)
 				continue;
 			break;
 		}
 
-		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;
+		/*
+		 * 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))
-				continue;
-		}
+		if (strcmp(pname, name))
+			continue;
 
 new_alias:
 		pr_err("%s new_alias name=%s pe->name=%s\n", __func__, name, pe->name);
--

2.17.1

Signature · 6 lines
- Arnaldo

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#5 lore raw

[tip:perf/core] perf pmu: Fix uncore PMU alias list for ARM64

In reply to John Garry
perf pmu: Fix uncore PMU alias list for ARM64
Commit-ID:  599ee18f0740d7661b8711249096db94c09bc508
Gitweb:     https://git.kernel.org/tip/599ee18f0740d7661b8711249096db94c09bc508
Author:     John Garry <[email protected]>
AuthorDate: Fri, 14 Jun 2019 22:07:59 +0800
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 17 Jun 2019 15:57:19 -0300

perf pmu: Fix uncore PMU alias list for ARM64

In commit 292c34c10249 ("perf pmu: Fix core PMU alias list for X86 platform"), we fixed the issue of CPU events being aliased to uncore events.

Fix this same issue for ARM64, since the said commit left the (broken) behaviour untouched for ARM64.

Cc Alexander Shishkin <[email protected]>
Cc Ben Hutchings <[email protected]>
Cc Hendrik Brueckner <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Mathieu Poirier <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Shaokun Zhang <[email protected]>
Cc Thomas Richter <[email protected]>
Cc Will Deacon <[email protected]>
Fixes 292c34c10249 ("perf pmu: Fix core PMU alias list for X86 platform")
---
 tools/perf/util/pmu.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)
tools/perf/util/pmu.c +12 -16
index e0429f4ef335..faa8eb231e1b 100644
@@ -709,9 +709,7 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 {
 	int i;
 	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)
@@ -722,28 +720,26 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 	 */
 	i = 0;
 	while (1) {
+		const char *cpu_name = is_arm_pmu_core(name) ? name : "cpu";
+		struct pmu_event *pe = &map->table[i++];
+		const char *pname = pe->pmu ? pe->pmu : cpu_name;
 
-		pe = &map->table[i++];
 		if (!pe->name) {
 			if (pe->metric_group || pe->metric_name)
 				continue;
 			break;
 		}
 
-		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;
+		/*
+		 * 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))
-				continue;
-		}
+		if (strcmp(pname, name))
+			continue;
 
 new_alias:
 		/* need type casts to override 'const' */
author
#6 lore raw

PATCH v2 2/5 perf pmu: Support more complex PMU event aliasing

In reply to John Garry

The jevent "Unit" field is used for uncore PMU alias definition.

The form uncore_pmu_example_X is supported, where "X" is a wildcard, to support multiple instances of the same PMU in a system.

Unfortunately this format not suitable for all uncore PMUs; take the Hisi DDRC uncore PMU for example, where the name is in the form hisi_scclX_ddrcY.

For the current jevent parsing, we would be required to hardcode an uncore alias translation for each possible value of X. This is not scalable.

Instead, add support for "Unit" field in the form "hisi_sccl,ddrc", where we can match by hisi_scclX and ddrcY. Tokens in Unit field are delimited by ','.

---
 tools/perf/util/pmu.c | 39 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 5 deletions(-)
tools/perf/util/pmu.c +34 -5
index 7e7299fee550..bc71c60589b5 100644
@@ -700,6 +700,39 @@ struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu)
 	return map;
 }
 
+static bool pmu_uncore_alias_match(const char *pmu_name, const char *name)
+{
+	char *tmp, *tok, *str;
+	bool res;
+
+	str = strdup(pmu_name);
+	if (!str)
+		return false;
+
+	/*
+	 * uncore alias may be from different PMU with common
+	 * prefix or matching tokens.
+	 */
+	tok = strtok_r(str, ",", &tmp);
+	if (strncmp(pmu_name, tok, strlen(tok))) {
+		res = false;
+		goto out;
+	}
+
+	for (; tok; name += strlen(tok), tok = strtok_r(NULL, ",", &tmp)) {
+		name = strstr(name, tok);
+		if (!name) {
+			res = false;
+			goto out;
+		}
+	}
+
+	res = true;
+out:
+	free(str);
+	return res;
+}
+
 /*
  * From the pmu_events_map, find the table of PMU events that corresponds
  * to the current running CPU. Then, add all PMU events from that table
@@ -730,12 +763,8 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 			break;
 		}
 
-		/*
-		 * uncore alias may be from different PMU
-		 * with common prefix
-		 */
 		if (pmu_is_uncore(name) &&
-		    !strncmp(pname, name, strlen(pname)))
+		    pmu_uncore_alias_match(pname, name))
 			goto new_alias;
 
 		if (strcmp(pname, name))
Signature · 1 line
2.17.1
#7 lore raw

Re: [PATCH v2 2/5] perf pmu: Support more complex PMU event aliasing

Em Fri, Jun 14, 2019 at 10:08:00PM +0800, John Garry escreveu:

Quoted 9 lines

The jevent "Unit" field is used for uncore PMU alias definition.

The form uncore_pmu_example_X is supported, where "X" is a wildcard, to support multiple instances of the same PMU in a system.

Unfortunately this format not suitable for all uncore PMUs; take the Hisi DDRC uncore PMU for example, where the name is in the form hisi_scclX_ddrcY.

Quoted 6 lines

For the current jevent parsing, we would be required to hardcode an uncore alias translation for each possible value of X. This is not scalable.

Instead, add support for "Unit" field in the form "hisi_sccl,ddrc", where we can match by hisi_scclX and ddrcY. Tokens in Unit field are delimited by ','.

Looks ok, but would be good to have some Reviewed-by attached as I'm not super familiar with the PMU oddities, Jiri, can you please review this, somebody else?

Thanks,

- Arnaldo

Quoted 65 lines
---
 tools/perf/util/pmu.c | 39 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 5 deletions(-)
tools/perf/util/pmu.c +34 -5
index 7e7299fee550..bc71c60589b5 100644
@@ -700,6 +700,39 @@ struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu)
 	return map;
 }
 
+static bool pmu_uncore_alias_match(const char *pmu_name, const char *name)
+{
+	char *tmp, *tok, *str;
+	bool res;
+
+	str = strdup(pmu_name);
+	if (!str)
+		return false;
+
+	/*
+	 * uncore alias may be from different PMU with common
+	 * prefix or matching tokens.
+	 */
+	tok = strtok_r(str, ",", &tmp);
+	if (strncmp(pmu_name, tok, strlen(tok))) {
+		res = false;
+		goto out;
+	}
+
+	for (; tok; name += strlen(tok), tok = strtok_r(NULL, ",", &tmp)) {
+		name = strstr(name, tok);
+		if (!name) {
+			res = false;
+			goto out;
+		}
+	}
+
+	res = true;
+out:
+	free(str);
+	return res;
+}
+
 /*
  * From the pmu_events_map, find the table of PMU events that corresponds
  * to the current running CPU. Then, add all PMU events from that table
@@ -730,12 +763,8 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 			break;
 		}
 
-		/*
-		 * uncore alias may be from different PMU
-		 * with common prefix
-		 */
 		if (pmu_is_uncore(name) &&
-		    !strncmp(pname, name, strlen(pname)))
+		    pmu_uncore_alias_match(pname, name))
 			goto new_alias;
 
 		if (strcmp(pname, name))
Signature · 1 line
2.17.1
Signature · 1 line
- Arnaldo
#8 lore raw

Re: [PATCH v2 2/5] perf pmu: Support more complex PMU event aliasing

In reply to John Garry
Quoted 34 lines · John Garry

The jevent "Unit" field is used for uncore PMU alias definition.

The form uncore_pmu_example_X is supported, where "X" is a wildcard, to support multiple instances of the same PMU in a system.

Unfortunately this format not suitable for all uncore PMUs; take the Hisi DDRC uncore PMU for example, where the name is in the form hisi_scclX_ddrcY.

For the current jevent parsing, we would be required to hardcode an uncore alias translation for each possible value of X. This is not scalable.

Instead, add support for "Unit" field in the form "hisi_sccl,ddrc", where we can match by hisi_scclX and ddrcY. Tokens in Unit field are delimited by ','.

---
 tools/perf/util/pmu.c | 39 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 5 deletions(-)
tools/perf/util/pmu.c +5 -0
index 7e7299fee550..bc71c60589b5 100644
@@ -700,6 +700,39 @@ struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu)
 	return map;
 }
 
+static bool pmu_uncore_alias_match(const char *pmu_name, const char *name)
+{
+	char *tmp, *tok, *str;
+	bool res;
+

tools/perf/util/pmu.c struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu) · line 717

Quoted 10 lines
tools/perf/util/pmu.c +10 -0
+	str = strdup(pmu_name);
+	if (!str)
+		return false;
+
+	/*
+	 * uncore alias may be from different PMU with common
+	 * prefix or matching tokens.
+	 */
+	tok = strtok_r(str, ",", &tmp);
+	if (strncmp(pmu_name, tok, strlen(tok))) {

if tok is NULL in here we crash

tools/perf/util/pmu.c struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu) · line 722

Quoted 5 lines
tools/perf/util/pmu.c +5 -0
+		res = false;
+		goto out;
+	}
+
+	for (; tok; name += strlen(tok), tok = strtok_r(NULL, ",", &tmp)) {

why is name shifted in here?

jirka

Quoted 33 lines
tools/perf/util/pmu.c +14 -5
+		name = strstr(name, tok);
+		if (!name) {
+			res = false;
+			goto out;
+		}
+	}
+
+	res = true;
+out:
+	free(str);
+	return res;
+}
+
 /*
  * From the pmu_events_map, find the table of PMU events that corresponds
  * to the current running CPU. Then, add all PMU events from that table
@@ -730,12 +763,8 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 			break;
 		}
 
-		/*
-		 * uncore alias may be from different PMU
-		 * with common prefix
-		 */
 		if (pmu_is_uncore(name) &&
-		    !strncmp(pname, name, strlen(pname)))
+		    pmu_uncore_alias_match(pname, name))
 			goto new_alias;
 
 		if (strcmp(pname, name))
Signature · 1 line
2.17.1
author
#9 lore raw

Re: [PATCH v2 2/5] perf pmu: Support more complex PMU event aliasing

Quoted 30 lines · Jiri Olsa
Quoted 29 lines · John Garry

The jevent "Unit" field is used for uncore PMU alias definition.

The form uncore_pmu_example_X is supported, where "X" is a wildcard, to support multiple instances of the same PMU in a system.

Unfortunately this format not suitable for all uncore PMUs; take the Hisi DDRC uncore PMU for example, where the name is in the form hisi_scclX_ddrcY.

For the current jevent parsing, we would be required to hardcode an uncore alias translation for each possible value of X. This is not scalable.

Instead, add support for "Unit" field in the form "hisi_sccl,ddrc", where we can match by hisi_scclX and ddrcY. Tokens in Unit field are delimited by ','.

---
 tools/perf/util/pmu.c | 39 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 5 deletions(-)
tools/perf/util/pmu.c +0 -0
index 7e7299fee550..bc71c60589b5 100644
@@ -700,6 +700,39 @@ struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu)
 	return map;
 }
 
Quoted 16 lines
Quoted 5 lines
tools/perf/util/pmu.c +5 -0
+static bool pmu_uncore_alias_match(const char *pmu_name, const char *name)
+{
+	char *tmp, *tok, *str;
+	bool res;
+

tools/perf/util/pmu.c struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu) · line 717

Quoted 10 lines
tools/perf/util/pmu.c +10 -0
+	str = strdup(pmu_name);
+	if (!str)
+		return false;
+
+	/*
+	 * uncore alias may be from different PMU with common
+	 * prefix or matching tokens.
+	 */
+	tok = strtok_r(str, ",", &tmp);
+	if (strncmp(pmu_name, tok, strlen(tok))) {

Hi Jirka,

Quoted 2 lines

if tok is NULL in here we crash

As I see, tok could not be NULL. If str contains no delimiters, then we just return same as str in tok.

Can you see tok being NULL?

Quoted 7 lines

tools/perf/util/pmu.c struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu) · line 722

Quoted 5 lines
tools/perf/util/pmu.c +5 -0
+		res = false;
+		goto out;
+	}
+
+	for (; tok; name += strlen(tok), tok = strtok_r(NULL, ",", &tmp)) {

why is name shifted in here?

I want to ensure that we match the tokens in order and also guard against possible repeated token matches in 'name'.

Thanks,
John

Quoted 39 lines

jirka

Quoted 31 lines
tools/perf/util/pmu.c +14 -6
+		name = strstr(name, tok);
+		if (!name) {
+			res = false;
+			goto out;
+		}
+	}
+
+	res = true;
+out:
+	free(str);
+	return res;
+}
+
 /*
  * From the pmu_events_map, find the table of PMU events that corresponds
  * to the current running CPU. Then, add all PMU events from that table
@@ -730,12 +763,8 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 			break;
 		}
 
-		/*
-		 * uncore alias may be from different PMU
-		 * with common prefix
-		 */
 		if (pmu_is_uncore(name) &&
-		    !strncmp(pname, name, strlen(pname)))
+		    pmu_uncore_alias_match(pname, name))
 			goto new_alias;
 
 		if (strcmp(pname, name))
--
Quoted 2 lines

2.17.1

.

#10 lore raw

Re: [PATCH v2 2/5] perf pmu: Support more complex PMU event aliasing

Quoted 48 lines · John Garry
Quoted 30 lines · Jiri Olsa
Quoted 29 lines · John Garry

The jevent "Unit" field is used for uncore PMU alias definition.

The form uncore_pmu_example_X is supported, where "X" is a wildcard, to support multiple instances of the same PMU in a system.

Unfortunately this format not suitable for all uncore PMUs; take the Hisi DDRC uncore PMU for example, where the name is in the form hisi_scclX_ddrcY.

For the current jevent parsing, we would be required to hardcode an uncore alias translation for each possible value of X. This is not scalable.

Instead, add support for "Unit" field in the form "hisi_sccl,ddrc", where we can match by hisi_scclX and ddrcY. Tokens in Unit field are delimited by ','.

---
 tools/perf/util/pmu.c | 39 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 5 deletions(-)
tools/perf/util/pmu.c +0 -0
index 7e7299fee550..bc71c60589b5 100644
@@ -700,6 +700,39 @@ struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu)
 	return map;
 }
 
Quoted 16 lines
Quoted 5 lines
tools/perf/util/pmu.c +5 -0
+static bool pmu_uncore_alias_match(const char *pmu_name, const char *name)
+{
+	char *tmp, *tok, *str;
+	bool res;
+

tools/perf/util/pmu.c struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu) · line 717

Quoted 10 lines
tools/perf/util/pmu.c +10 -0
+	str = strdup(pmu_name);
+	if (!str)
+		return false;
+
+	/*
+	 * uncore alias may be from different PMU with common
+	 * prefix or matching tokens.
+	 */
+	tok = strtok_r(str, ",", &tmp);
+	if (strncmp(pmu_name, tok, strlen(tok))) {
Quoted 1 line

Hi Jirka,

heya,
sry for late reply

Quoted 8 lines
Quoted 3 lines

if tok is NULL in here we crash

As I see, tok could not be NULL. If str contains no delimiters, then we just return same as str in tok.

Can you see tok being NULL?

well, if there's no ',' in the str it returns NULL, right? and IIUC this function is still called for standard uncore pmu names

Quoted 11 lines
Quoted 8 lines

tools/perf/util/pmu.c struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu) · line 722

Quoted 6 lines
tools/perf/util/pmu.c +5 -0
+		res = false;
+		goto out;
+	}
+
+	for (; tok; name += strlen(tok), tok = strtok_r(NULL, ",", &tmp)) {

why is name shifted in here?

I want to ensure that we match the tokens in order and also guard against possible repeated token matches in 'name'.

i might not understand this correctly.. so

str is the alias name that can contain ',' now, like:
hisi_sccl,ddrc

and name is still pmu with no ',' ... please make this or proper version that in some comment

thanks,
jirka

author
#11 lore raw

Re: [PATCH v2 2/5] perf pmu: Support more complex PMU event aliasing

Quoted 32 lines · Jiri Olsa
Quoted 31 lines · John Garry
Quoted 30 lines · Jiri Olsa
Quoted 29 lines · John Garry

The jevent "Unit" field is used for uncore PMU alias definition.

The form uncore_pmu_example_X is supported, where "X" is a wildcard, to support multiple instances of the same PMU in a system.

Unfortunately this format not suitable for all uncore PMUs; take the Hisi DDRC uncore PMU for example, where the name is in the form hisi_scclX_ddrcY.

For the current jevent parsing, we would be required to hardcode an uncore alias translation for each possible value of X. This is not scalable.

Instead, add support for "Unit" field in the form "hisi_sccl,ddrc", where we can match by hisi_scclX and ddrcY. Tokens in Unit field are delimited by ','.

---
 tools/perf/util/pmu.c | 39 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 5 deletions(-)
tools/perf/util/pmu.c +0 -0
index 7e7299fee550..bc71c60589b5 100644
@@ -700,6 +700,39 @@ struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu)
 	return map;
 }
 
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

tools/perf/util/pmu.c struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu) · line 710

Quoted 8 lines
tools/perf/util/pmu.c +8 -0
+static bool pmu_uncore_alias_match(const char *pmu_name, const char *name)
+{
+	char *tmp, *tok, *str;
+	bool res;
+
+	str = strdup(pmu_name);
+	if (!str)
+		return false;

Hi Jirka,

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

tools/perf/util/pmu.c struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu) · line 716

Quoted 6 lines
tools/perf/util/pmu.c +6 -0
+
+	/*
+	 * uncore alias may be from different PMU with common
+	 * prefix or matching tokens.
+	 */
+	tok = strtok_r(str, ",", &tmp);

If str contains no delimiter, then it returns str in tok.

Quoted 1 line
Quoted 1 line
Quoted 1 line

tools/perf/util/pmu.c struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu) · line 717

Quoted 1 line
tools/perf/util/pmu.c +1 -0
+	if (strncmp(pmu_name, tok, strlen(tok))) {

So this above check covers the case of str with and without a delimiter.

Quoted 11 lines
Quoted 3 lines
Quoted 1 line

Hi Jirka,

heya,
sry for late reply

Quoted 4 lines
Quoted 3 lines

if tok is NULL in here we crash

Quoted 6 lines
Quoted 4 lines

As I see, tok could not be NULL. If str contains no delimiters, then we just return same as str in tok.

Can you see tok being NULL?

well, if there's no ',' in the str it returns NULL, right?

No, it would return str in tok.

Quoted 12 lines

and IIUC this function is still called for standard uncore pmu names

Quoted 9 lines
Quoted 8 lines

tools/perf/util/pmu.c struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu) · line 722

Quoted 6 lines
tools/perf/util/pmu.c +5 -0
+		res = false;
+		goto out;
+	}
+
+	for (; tok; name += strlen(tok), tok = strtok_r(NULL, ",", &tmp)) {

why is name shifted in here?

Quoted 7 lines
Quoted 2 lines

I want to ensure that we match the tokens in order and also guard against possible repeated token matches in 'name'.

i might not understand this correctly.. so

str is the alias name that can contain ',' now, like:
hisi_sccl,ddrc

For example of pmu_nmame=hisi_sccl,ddrc and pmu=hisi_sccl1_ddrc0, we match in this sequence:

loop 1. tok=hisi_sccl name=hisi_sccl1_ddrc0
loop 2. tok=ddrc name=ddrc0
loop 3. tok=NULL -> breakout and return true

A couple of notes:
a. loop 1. could be omitted, but the code becomes a bit more complicated
2. I don't have to advance name. But then we would match something like hisi_ddrc0_sccl1. Maybe this is ok.

Quoted 5 lines

and name is still pmu with no ',' ...
please make this or
proper version that in some comment

I didn't really get your meaning here. Please check my replies and see if you have further doubt or concern.

Much appreciated,
John

Quoted 5 lines

thanks,
jirka

.

author
#12 lore raw

Re: [PATCH v2 2/5] perf pmu: Support more complex PMU event aliasing

Quoted 118 lines · John Garry
Quoted 36 lines · Jiri Olsa
Quoted 35 lines · John Garry
Quoted 34 lines · Jiri Olsa
Quoted 33 lines · John Garry

The jevent "Unit" field is used for uncore PMU alias definition.

The form uncore_pmu_example_X is supported, where "X" is a wildcard, to support multiple instances of the same PMU in a system.

Unfortunately this format not suitable for all uncore PMUs; take the Hisi
DDRC uncore PMU for example, where the name is in the form hisi_scclX_ddrcY.

For the current jevent parsing, we would be required to hardcode an uncore
alias translation for each possible value of X. This is not scalable.

Instead, add support for "Unit" field in the form "hisi_sccl,ddrc", where
we can match by hisi_scclX and ddrcY. Tokens in Unit field are delimited by ','.

---
 tools/perf/util/pmu.c | 39 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 5 deletions(-)
tools/perf/util/pmu.c +0 -0
index 7e7299fee550..bc71c60589b5 100644
@@ -700,6 +700,39 @@ struct pmu_events_map
 *perf_pmu__find_map(struct perf_pmu *pmu)
     return map;
 }
 
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

tools/perf/util/pmu.c struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu) · line 710

Quoted 9 lines
tools/perf/util/pmu.c +8 -0
+static bool pmu_uncore_alias_match(const char *pmu_name, const
 char *name)
+{
+    char *tmp, *tok, *str;
+    bool res;
+
+    str = strdup(pmu_name);
+    if (!str)
+        return false;

Hi Jirka,

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

tools/perf/util/pmu.c struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu) · line 716

Quoted 6 lines
tools/perf/util/pmu.c +6 -0
+
+    /*
+     * uncore alias may be from different PMU with common
+     * prefix or matching tokens.
+     */
+    tok = strtok_r(str, ",", &tmp);

If str contains no delimiter, then it returns str in tok.

Quoted 1 line
Quoted 1 line
Quoted 1 line

tools/perf/util/pmu.c struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu) · line 717

Quoted 1 line
tools/perf/util/pmu.c +1 -0
+    if (strncmp(pmu_name, tok, strlen(tok))) {

So this above check covers the case of str with and without a delimiter.

Quoted 11 lines
Quoted 3 lines
Quoted 1 line

Hi Jirka,

heya,
sry for late reply

Quoted 4 lines
Quoted 3 lines

if tok is NULL in here we crash

Quoted 7 lines
Quoted 5 lines

As I see, tok could not be NULL. If str contains no delimiters, then we just
return same as str in tok.

Can you see tok being NULL?

well, if there's no ',' in the str it returns NULL, right?

No, it would return str in tok.

Quoted 13 lines

and IIUC this function is still called for standard uncore pmu names

Quoted 10 lines
Quoted 9 lines

tools/perf/util/pmu.c struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu)

Quoted 7 lines
tools/perf/util/pmu.c +5 -0
+        res = false;
+        goto out;
+    }
+
+    for (; tok; name += strlen(tok), tok = strtok_r(NULL, ",",
 &tmp)) {

why is name shifted in here?

Quoted 8 lines
Quoted 3 lines

I want to ensure that we match the tokens in order and also guard against
possible repeated token matches in 'name'.

i might not understand this correctly.. so

str is the alias name that can contain ',' now, like:
hisi_sccl,ddrc

For example of pmu_nmame=hisi_sccl,ddrc and pmu=hisi_sccl1_ddrc0, we match in this sequence:

loop 1. tok=hisi_sccl name=hisi_sccl1_ddrc0
loop 2. tok=ddrc name=ddrc0
loop 3. tok=NULL -> breakout and return true

A couple of notes:
a. loop 1. could be omitted, but the code becomes a bit more complicated
2. I don't have to advance name. But then we would match something like hisi_ddrc0_sccl1. Maybe this is ok.

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

and name is still pmu with no ',' ...
please make this or
proper version that in some comment

I didn't really get your meaning here. Please check my replies and see if you have further doubt or concern.

Hi Jirka,

I was just wondering if you have any further comments or questions here?

Much appreciated,
John

#13 lore raw

Re: [PATCH v2 2/5] perf pmu: Support more complex PMU event aliasing

On Thu, Jun 27, 2019 at 05:27:32PM +0100, John Garry wrote:

SNIP

Quoted 18 lines
Quoted 9 lines

loop 2. tok=ddrc name=ddrc0
loop 3. tok=NULL -> breakout and return true

A couple of notes:
a. loop 1. could be omitted, but the code becomes a bit more complicated
2. I don't have to advance name. But then we would match something like hisi_ddrc0_sccl1. Maybe this is ok.

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

and name is still pmu with no ',' ...
please make this or
proper version that in some comment

I didn't really get your meaning here. Please check my replies and see if you have further doubt or concern.

Quoted 5 lines

Hi Jirka,

I was just wondering if you have any further comments or questions here?

Much appreciated,

sorry, forgot about this one.. will check soon

jirka

#14 lore raw

Re: [PATCH v2 2/5] perf pmu: Support more complex PMU event aliasing

In reply to John Garry

On Thu, Jun 27, 2019 at 05:27:32PM +0100, John Garry wrote:

SNIP

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

heya,
sry for late reply

Quoted 8 lines
Quoted 3 lines

if tok is NULL in here we crash

As I see, tok could not be NULL. If str contains no delimiters, then we just
return same as str in tok.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Can you see tok being NULL?

well, if there's no ',' in the str it returns NULL, right?

No, it would return str in tok.

ok

Quoted 23 lines
Quoted 23 lines
Quoted 22 lines

and IIUC this function is still called for standard uncore pmu names

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
tools/perf/util/pmu.c +5 -0
+        res = false;
+        goto out;
+    }
+
+    for (; tok; name += strlen(tok), tok = strtok_r(NULL, ",",

&tmp)) {

Quoted 5 lines
Quoted 1 line

why is name shifted in here?

I want to ensure that we match the tokens in order and also guard against
possible repeated token matches in 'name'.

i might not understand this correctly.. so

str is the alias name that can contain ',' now, like:
hisi_sccl,ddrc

Quoted 6 lines
Quoted 6 lines

For example of pmu_nmame=hisi_sccl,ddrc and pmu=hisi_sccl1_ddrc0, we match in this sequence:

loop 1. tok=hisi_sccl name=hisi_sccl1_ddrc0
loop 2. tok=ddrc name=ddrc0
loop 3. tok=NULL -> breakout and return true

ok, plz put something like above into comment

thanks,
jirka

author
#15 lore raw

Re: [PATCH v2 2/5] perf pmu: Support more complex PMU event aliasing

Quoted 16 lines · Jiri Olsa

On Thu, Jun 27, 2019 at 05:27:32PM +0100, John Garry wrote:

SNIP

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

heya,
sry for late reply

Quoted 8 lines
Quoted 3 lines

if tok is NULL in here we crash

As I see, tok could not be NULL. If str contains no delimiters, then we just
return same as str in tok.

Quoted 38 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Can you see tok being NULL?

well, if there's no ',' in the str it returns NULL, right?

No, it would return str in tok.

ok

Quoted 29 lines
Quoted 29 lines
Quoted 14 lines

and IIUC this function is still called for standard uncore pmu names

Quoted 10 lines
Quoted 9 lines
Quoted 7 lines
(quoted diff) +5 -0
+        res = false;
+        goto out;
+    }
+
+    for (; tok; name += strlen(tok), tok = strtok_r(NULL, ",",

&tmp)) {

why is name shifted in here?

Quoted 8 lines
Quoted 3 lines

I want to ensure that we match the tokens in order and also guard against
possible repeated token matches in 'name'.

i might not understand this correctly.. so

str is the alias name that can contain ',' now, like:
hisi_sccl,ddrc

For example of pmu_nmame=hisi_sccl,ddrc and pmu=hisi_sccl1_ddrc0, we match in this sequence:

loop 1. tok=hisi_sccl name=hisi_sccl1_ddrc0
loop 2. tok=ddrc name=ddrc0
loop 3. tok=NULL -> breakout and return true

Hi jirka,

Quoted 2 lines

ok, plz put something like above into comment

ok, can do.

Thanks again,
John

Quoted 5 lines

thanks,
jirka

.

author
#16 lore raw

PATCH v2 3/5 perf jevents: Add support for Hisi hip08 DDRC PMU aliasing

In reply to John Garry

Add support for Hisi hip08 DDRC PMU event aliasing. We can now do something like this:

$perf list

[snip]

uncore ddrc:
uncore_hisi_ddrc.act_cmd
[DDRC active commands. Unit: hisi_sccl,ddrc]
uncore_hisi_ddrc.flux_rcmd
[DDRC read commands. Unit: hisi_sccl,ddrc]
uncore_hisi_ddrc.flux_wcmd
[DDRC write commands. Unit: hisi_sccl,ddrc]
uncore_hisi_ddrc.flux_wr
[DDRC precharge commands. Unit: hisi_sccl,ddrc]
uncore_hisi_ddrc.rnk_chg
[DDRC rank commands. Unit: hisi_sccl,ddrc]
uncore_hisi_ddrc.rw_chg
[DDRC read and write changes. Unit: hisi_sccl,ddrc]

$sudo ./perf stat -e uncore_hisi_ddrc.flux_rcmd --no-merge sleep 1

Performance counter stats for 'system wide':

                 0      uncore_hisi_ddrc.flux_rcmd [hisi_sccl1_ddrc0]
                 0      uncore_hisi_ddrc.flux_rcmd [hisi_sccl3_ddrc1]
                 0      uncore_hisi_ddrc.flux_rcmd [hisi_sccl5_ddrc2]
                 0      uncore_hisi_ddrc.flux_rcmd [hisi_sccl7_ddrc3]
                 0      uncore_hisi_ddrc.flux_rcmd [hisi_sccl5_ddrc0]
                 0      uncore_hisi_ddrc.flux_rcmd [hisi_sccl7_ddrc1]
                 0      uncore_hisi_ddrc.flux_rcmd [hisi_sccl1_ddrc3]
                 0      uncore_hisi_ddrc.flux_rcmd [hisi_sccl1_ddrc1]
                 0      uncore_hisi_ddrc.flux_rcmd [hisi_sccl3_ddrc2]
                 0      uncore_hisi_ddrc.flux_rcmd [hisi_sccl5_ddrc3]
                 0      uncore_hisi_ddrc.flux_rcmd [hisi_sccl3_ddrc0]
                 0      uncore_hisi_ddrc.flux_rcmd [hisi_sccl5_ddrc1]
                 0      uncore_hisi_ddrc.flux_rcmd [hisi_sccl7_ddrc2]
                 0      uncore_hisi_ddrc.flux_rcmd [hisi_sccl7_ddrc0]
            20,421      uncore_hisi_ddrc.flux_rcmd [hisi_sccl1_ddrc2]
                 0      uncore_hisi_ddrc.flux_rcmd [hisi_sccl3_ddrc3]
       1.001559011 seconds time elapsed

The kernel driver is in drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c

---
 .../arm64/hisilicon/hip08/uncore-ddrc.json    | 44 +++++++++++++++++++
 tools/perf/pmu-events/jevents.c               |  1 +
 2 files changed, 45 insertions(+)
 create mode 100644 tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-ddrc.json
tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-ddrc.json new file +44 -0
new file mode 100644
index 000000000000..0d1556fcdffe
@@ -0,0 +1,44 @@
+[
+   {
+	    "EventCode": "0x02",
+	    "EventName": "uncore_hisi_ddrc.flux_wcmd",
+	    "BriefDescription": "DDRC write commands",
+	    "PublicDescription": "DDRC write commands",
+	    "Unit": "hisi_sccl,ddrc",
+   },
+   {
+	    "EventCode": "0x03",
+	    "EventName": "uncore_hisi_ddrc.flux_rcmd",
+	    "BriefDescription": "DDRC read commands",
+	    "PublicDescription": "DDRC read commands",
+	    "Unit": "hisi_sccl,ddrc",
+   },
+   {
+	    "EventCode": "0x04",
+	    "EventName": "uncore_hisi_ddrc.flux_wr",
+	    "BriefDescription": "DDRC precharge commands",
+	    "PublicDescription": "DDRC precharge commands",
+	    "Unit": "hisi_sccl,ddrc",
+   },
+   {
+	    "EventCode": "0x05",
+	    "EventName": "uncore_hisi_ddrc.act_cmd",
+	    "BriefDescription": "DDRC active commands",
+	    "PublicDescription": "DDRC active commands",
+	    "Unit": "hisi_sccl,ddrc",
+   },
+   {
+	    "EventCode": "0x06",
+	    "EventName": "uncore_hisi_ddrc.rnk_chg",
+	    "BriefDescription": "DDRC rank commands",
+	    "PublicDescription": "DDRC rank commands",
+	    "Unit": "hisi_sccl,ddrc",
+   },
+   {
+	    "EventCode": "0x07",
+	    "EventName": "uncore_hisi_ddrc.rw_chg",
+	    "BriefDescription": "DDRC read and write changes",
+	    "PublicDescription": "DDRC read and write changes",
+	    "Unit": "hisi_sccl,ddrc",
+   },
+]
tools/perf/pmu-events/jevents.c +1 -0
index 58f77fd0f59f..cf9a60333554 100644
@@ -236,6 +236,7 @@ static struct map {
 	{ "CPU-M-CF", "cpum_cf" },
 	{ "CPU-M-SF", "cpum_sf" },
 	{ "UPI LL", "uncore_upi" },
+	{ "hisi_sccl,ddrc", "hisi_sccl,ddrc" },
 	{}
 };
 
Signature · 1 line
2.17.1
author
#17 lore raw

PATCH v2 4/5 perf jevents: Add support for Hisi hip08 HHA PMU aliasing

In reply to John Garry

Add support for Hisi hip08 HHA PMU aliasing.

The kernel driver is in drivers/perf/hisilicon/hisi_uncore_hha_pmu.c

---
 .../arm64/hisilicon/hip08/uncore-hha.json     | 51 +++++++++++++++++++
 tools/perf/pmu-events/jevents.c               |  1 +
 2 files changed, 52 insertions(+)
 create mode 100644 tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-hha.json
tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-hha.json new file +51 -0
new file mode 100644
index 000000000000..447d3064de90
@@ -0,0 +1,51 @@
+[
+   {
+	    "EventCode": "0x00",
+	    "EventName": "uncore_hisi_hha.rx_ops_num",
+	    "BriefDescription": "The number of all operations received by the HHA",
+	    "PublicDescription": "The number of all operations received by the HHA",
+	    "Unit": "hisi_sccl,hha",
+   },
+   {
+	    "EventCode": "0x01",
+	    "EventName": "uncore_hisi_hha.rx_outer",
+	    "BriefDescription": "The number of all operations received by the HHA from another socket",
+	    "PublicDescription": "The number of all operations received by the HHA from another socket",
+	    "Unit": "hisi_sccl,hha",
+   },
+   {
+	    "EventCode": "0x02",
+	    "EventName": "uncore_hisi_hha.rx_sccl",
+	    "BriefDescription": "The number of all operations received by the HHA from another SCCL in this socket",
+	    "PublicDescription": "The number of all operations received by the HHA from another SCCL in this socket",
+	    "Unit": "hisi_sccl,hha",
+   },
+   {
+	    "EventCode": "0x1c",
+	    "EventName": "uncore_hisi_hha.rd_ddr_64b",
+	    "BriefDescription": "The number of read operations sent by HHA to DDRC which size is 64 bytes",
+	    "PublicDescription": "The number of read operations sent by HHA to DDRC which size is 64bytes",
+	    "Unit": "hisi_sccl,hha",
+   },
+   {
+	    "EventCode": "0x1d",
+	    "EventName": "uncore_hisi_hha.wr_dr_64b",
+	    "BriefDescription": "The number of write operations sent by HHA to DDRC which size is 64 bytes",
+	    "PublicDescription": "The number of write operations sent by HHA to DDRC which size is 64 bytes",
+	    "Unit": "hisi_sccl,hha",
+   },
+   {
+	    "EventCode": "0x1e",
+	    "EventName": "uncore_hisi_hha.rd_ddr_128b",
+	    "BriefDescription": "The number of read operations sent by HHA to DDRC which size is 128 bytes",
+	    "PublicDescription": "The number of read operations sent by HHA to DDRC which size is 128 bytes",
+	    "Unit": "hisi_sccl,hha",
+   },
+   {
+	    "EventCode": "0x1f",
+	    "EventName": "uncore_hisi_hha.wr_ddr_128b",
+	    "BriefDescription": "The number of write operations sent by HHA to DDRC which size is 128 bytes",
+	    "PublicDescription": "The number of write operations sent by HHA to DDRC which size is 128 bytes",
+	    "Unit": "hisi_sccl,hha",
+   },
+]
tools/perf/pmu-events/jevents.c +1 -0
index cf9a60333554..909e53e3b5bd 100644
@@ -237,6 +237,7 @@ static struct map {
 	{ "CPU-M-SF", "cpum_sf" },
 	{ "UPI LL", "uncore_upi" },
 	{ "hisi_sccl,ddrc", "hisi_sccl,ddrc" },
+	{ "hisi_sccl,hha", "hisi_sccl,hha" },
 	{}
 };
 
Signature · 1 line
2.17.1
author
#18 lore raw

PATCH v2 5/5 perf jevents: Add support for Hisi hip08 L3C PMU aliasing

In reply to John Garry

Add support for Hisi hip08 L3C PMU aliasing.

The kernel driver is in drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c

---
 .../arm64/hisilicon/hip08/uncore-l3c.json     | 37 +++++++++++++++++++
 tools/perf/pmu-events/jevents.c               |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-l3c.json
tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-l3c.json new file +37 -0
new file mode 100644
index 000000000000..ca48747642e1
@@ -0,0 +1,37 @@
+[
+   {
+	    "EventCode": "0x00",
+	    "EventName": "uncore_hisi_l3c.rd_cpipe",
+	    "BriefDescription": "Total read accesses",
+	    "PublicDescription": "Total read accesses",
+	    "Unit": "hisi_sccl,l3c",
+   },
+   {
+	    "EventCode": "0x01",
+	    "EventName": "uncore_hisi_l3c.wr_cpipe",
+	    "BriefDescription": "Total write accesses",
+	    "PublicDescription": "Total write accesses",
+	    "Unit": "hisi_sccl,l3c",
+   },
+   {
+	    "EventCode": "0x02",
+	    "EventName": "uncore_hisi_l3c.rd_hit_cpipe",
+	    "BriefDescription": "Total read hits",
+	    "PublicDescription": "Total read hits",
+	    "Unit": "hisi_sccl,l3c",
+   },
+   {
+	    "EventCode": "0x03",
+	    "EventName": "uncore_hisi_l3c.wr_hit_cpipe",
+	    "BriefDescription": "Total write hits",
+	    "PublicDescription": "Total write hits",
+	    "Unit": "hisi_sccl,l3c",
+   },
+   {
+	    "EventCode": "0x04",
+	    "EventName": "uncore_hisi_l3c.victim_num",
+	    "BriefDescription": "l3c precharge commands",
+	    "PublicDescription": "l3c precharge commands",
+	    "Unit": "hisi_sccl,l3c",
+   },
+]
tools/perf/pmu-events/jevents.c +1 -0
index 909e53e3b5bd..7d241efd03de 100644
@@ -238,6 +238,7 @@ static struct map {
 	{ "UPI LL", "uncore_upi" },
 	{ "hisi_sccl,ddrc", "hisi_sccl,ddrc" },
 	{ "hisi_sccl,hha", "hisi_sccl,hha" },
+	{ "hisi_sccl,l3c", "hisi_sccl,l3c" },
 	{}
 };
 
Signature · 1 line
2.17.1