linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] Perf uncore PMU event alias support for Hisi hip08 ARM64 platform
@ 2019-06-10  9:59 John Garry
  2019-06-10  9:59 ` [PATCH 1/5] perf pmu: Fix uncore PMU alias list for ARM64 John Garry
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: John Garry @ 2019-06-10  9:59 UTC (permalink / raw)
  To: peterz, mingo, acme, alexander.shishkin, jolsa, namhyung,
	tmricht, brueckner, kan.liang, ben, mathieu.poirier,
	mark.rutland, will.deacon
  Cc: linux-kernel, linuxarm, linux-arm-kernel, zhangshaokun, ak, John Garry

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.

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                         | 61 ++++++++++++++-----
 5 files changed, 181 insertions(+), 15 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

-- 
2.17.1


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

* [PATCH 1/5] perf pmu: Fix uncore PMU alias list for ARM64
  2019-06-10  9:59 [PATCH 0/5] Perf uncore PMU event alias support for Hisi hip08 ARM64 platform John Garry
@ 2019-06-10  9:59 ` John Garry
  2019-06-10  9:59 ` [PATCH 2/5] perf pmu: Support more complex PMU event aliasing John Garry
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: John Garry @ 2019-06-10  9:59 UTC (permalink / raw)
  To: peterz, mingo, acme, alexander.shishkin, jolsa, namhyung,
	tmricht, brueckner, kan.liang, ben, mathieu.poirier,
	mark.rutland, will.deacon
  Cc: linux-kernel, linuxarm, linux-arm-kernel, zhangshaokun, ak, John Garry

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

Signed-off-by: John Garry <john.garry@huawei.com>
---
 tools/perf/util/pmu.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index e0429f4ef335..036047f56efa 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -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' */
-- 
2.17.1


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

* [PATCH 2/5] perf pmu: Support more complex PMU event aliasing
  2019-06-10  9:59 [PATCH 0/5] Perf uncore PMU event alias support for Hisi hip08 ARM64 platform John Garry
  2019-06-10  9:59 ` [PATCH 1/5] perf pmu: Fix uncore PMU alias list for ARM64 John Garry
@ 2019-06-10  9:59 ` John Garry
  2019-06-11 16:10   ` Jiri Olsa
  2019-06-10  9:59 ` [PATCH 3/5] perf jevents: Add support for Hisi hip08 DDRC PMU aliasing John Garry
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: John Garry @ 2019-06-10  9:59 UTC (permalink / raw)
  To: peterz, mingo, acme, alexander.shishkin, jolsa, namhyung,
	tmricht, brueckner, kan.liang, ben, mathieu.poirier,
	mark.rutland, will.deacon
  Cc: linux-kernel, linuxarm, linux-arm-kernel, zhangshaokun, ak, 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 ','.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 tools/perf/util/pmu.c | 45 ++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 40 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 036047f56efa..f00cae750086 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -700,6 +700,44 @@ 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)
+{
+	/*
+	 * uncore alias may be from different PMU
+	 * with common prefix
+	 */
+	if (!strncmp(pmu_name, name, strlen(pmu_name)))
+		return true;
+
+	/* match strings with delimiter, ',' */
+	while (1) {
+		const char *delimiter;
+		char token[256] = {};
+		const char *found_token;
+		int token_len;
+
+		delimiter = strchr(pmu_name, ',');
+		if (delimiter) {
+			token_len = delimiter - pmu_name;
+		} else {
+			token_len = strlen(pmu_name);
+		}
+
+		memcpy(token, pmu_name, token_len);
+
+		found_token = strstr(name, token);
+		if (!found_token)
+			return false;
+
+		/* No more delimiters, so we must be a match */
+		if (!delimiter)
+			return true;
+
+		pmu_name += token_len + 1;
+		name = found_token + token_len;
+	}
+}
+
 /*
  * 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 +768,9 @@ 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))
-- 
2.17.1


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

* [PATCH 3/5] perf jevents: Add support for Hisi hip08 DDRC PMU aliasing
  2019-06-10  9:59 [PATCH 0/5] Perf uncore PMU event alias support for Hisi hip08 ARM64 platform John Garry
  2019-06-10  9:59 ` [PATCH 1/5] perf pmu: Fix uncore PMU alias list for ARM64 John Garry
  2019-06-10  9:59 ` [PATCH 2/5] perf pmu: Support more complex PMU event aliasing John Garry
@ 2019-06-10  9:59 ` John Garry
  2019-06-10  9:59 ` [PATCH 4/5] perf jevents: Add support for Hisi hip08 HHA " John Garry
  2019-06-10  9:59 ` [PATCH 5/5] perf jevents: Add support for Hisi hip08 L3C " John Garry
  4 siblings, 0 replies; 8+ messages in thread
From: John Garry @ 2019-06-10  9:59 UTC (permalink / raw)
  To: peterz, mingo, acme, alexander.shishkin, jolsa, namhyung,
	tmricht, brueckner, kan.liang, ben, mathieu.poirier,
	mark.rutland, will.deacon
  Cc: linux-kernel, linuxarm, linux-arm-kernel, zhangshaokun, ak, 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_sccl_ddrc.act_cmd
       [DDRC active commands. Unit: hisi_sccl,ddrc]
  uncore_hisi_sccl_ddrc.flux_rcmd
       [DDRC read commands. Unit: hisi_sccl,ddrc]
  uncore_hisi_sccl_ddrc.flux_wcmd
       [DDRC write commands. Unit: hisi_sccl,ddrc]
  uncore_hisi_sccl_ddrc.flux_wr
       [DDRC precharge commands. Unit: hisi_sccl,ddrc]
  uncore_hisi_sccl_ddrc.rnk_chg
       [DDRC rank commands. Unit: hisi_sccl,ddrc]
  uncore_hisi_sccl_ddrc.rw_chg
       [DDRC read and write changes. Unit: hisi_sccl,ddrc]

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

 Performance counter stats for 'system wide':

                 0      uncore_hisi_sccl_ddrc.flux_rcmd [hisi_sccl1_ddrc0]
                 0      uncore_hisi_sccl_ddrc.flux_rcmd [hisi_sccl3_ddrc1]
                 0      uncore_hisi_sccl_ddrc.flux_rcmd [hisi_sccl1_ddrc3]
                 0      uncore_hisi_sccl_ddrc.flux_rcmd [hisi_sccl1_ddrc1]
                 0      uncore_hisi_sccl_ddrc.flux_rcmd [hisi_sccl3_ddrc2]
                 0      uncore_hisi_sccl_ddrc.flux_rcmd [hisi_sccl3_ddrc0]
            25,722      uncore_hisi_sccl_ddrc.flux_rcmd [hisi_sccl1_ddrc2]
                 0      uncore_hisi_sccl_ddrc.flux_rcmd [hisi_sccl3_ddrc3]

       1.001344685 seconds time elapsed

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

Signed-off-by: John Garry <john.garry@huawei.com>
---
 .../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

diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-ddrc.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-ddrc.json
new file mode 100644
index 000000000000..901b1fe65629
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-ddrc.json
@@ -0,0 +1,44 @@
+[
+   {
+	    "EventCode": "0x02",
+	    "EventName": "uncore_hisi_sccl_ddrc.flux_wcmd",
+	    "BriefDescription": "DDRC write commands",
+	    "PublicDescription": "DDRC write commands",
+	    "Unit": "hisi_sccl,ddrc",
+   },
+   {
+	    "EventCode": "0x03",
+	    "EventName": "uncore_hisi_sccl_ddrc.flux_rcmd",
+	    "BriefDescription": "DDRC read commands",
+	    "PublicDescription": "DDRC read commands",
+	    "Unit": "hisi_sccl,ddrc",
+   },
+   {
+	    "EventCode": "0x04",
+	    "EventName": "uncore_hisi_sccl_ddrc.flux_wr",
+	    "BriefDescription": "DDRC precharge commands",
+	    "PublicDescription": "DDRC precharge commands",
+	    "Unit": "hisi_sccl,ddrc",
+   },
+   {
+	    "EventCode": "0x05",
+	    "EventName": "uncore_hisi_sccl_ddrc.act_cmd",
+	    "BriefDescription": "DDRC active commands",
+	    "PublicDescription": "DDRC active commands",
+	    "Unit": "hisi_sccl,ddrc",
+   },
+   {
+	    "EventCode": "0x06",
+	    "EventName": "uncore_hisi_sccl_ddrc.rnk_chg",
+	    "BriefDescription": "DDRC rank commands",
+	    "PublicDescription": "DDRC rank commands",
+	    "Unit": "hisi_sccl,ddrc",
+   },
+   {
+	    "EventCode": "0x07",
+	    "EventName": "uncore_hisi_sccl_ddrc.rw_chg",
+	    "BriefDescription": "DDRC read and write changes",
+	    "PublicDescription": "DDRC read and write changes",
+	    "Unit": "hisi_sccl,ddrc",
+   },
+]
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index 58f77fd0f59f..cf9a60333554 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -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" },
 	{}
 };
 
-- 
2.17.1


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

* [PATCH 4/5] perf jevents: Add support for Hisi hip08 HHA PMU aliasing
  2019-06-10  9:59 [PATCH 0/5] Perf uncore PMU event alias support for Hisi hip08 ARM64 platform John Garry
                   ` (2 preceding siblings ...)
  2019-06-10  9:59 ` [PATCH 3/5] perf jevents: Add support for Hisi hip08 DDRC PMU aliasing John Garry
@ 2019-06-10  9:59 ` John Garry
  2019-06-10  9:59 ` [PATCH 5/5] perf jevents: Add support for Hisi hip08 L3C " John Garry
  4 siblings, 0 replies; 8+ messages in thread
From: John Garry @ 2019-06-10  9:59 UTC (permalink / raw)
  To: peterz, mingo, acme, alexander.shishkin, jolsa, namhyung,
	tmricht, brueckner, kan.liang, ben, mathieu.poirier,
	mark.rutland, will.deacon
  Cc: linux-kernel, linuxarm, linux-arm-kernel, zhangshaokun, ak, John Garry

Add support for Hisi hip08 HHA PMU aliasing.

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

Signed-off-by: John Garry <john.garry@huawei.com>
---
 .../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

diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-hha.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-hha.json
new file mode 100644
index 000000000000..f94b8513166e
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-hha.json
@@ -0,0 +1,51 @@
+[
+   {
+	    "EventCode": "0x00",
+	    "EventName": "uncore_hisi_sccl_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_sccl_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_sccl_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_sccl_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_sccl_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_sccl_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_sccl_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",
+   },
+]
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index cf9a60333554..909e53e3b5bd 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -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" },
 	{}
 };
 
-- 
2.17.1


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

* [PATCH 5/5] perf jevents: Add support for Hisi hip08 L3C PMU aliasing
  2019-06-10  9:59 [PATCH 0/5] Perf uncore PMU event alias support for Hisi hip08 ARM64 platform John Garry
                   ` (3 preceding siblings ...)
  2019-06-10  9:59 ` [PATCH 4/5] perf jevents: Add support for Hisi hip08 HHA " John Garry
@ 2019-06-10  9:59 ` John Garry
  4 siblings, 0 replies; 8+ messages in thread
From: John Garry @ 2019-06-10  9:59 UTC (permalink / raw)
  To: peterz, mingo, acme, alexander.shishkin, jolsa, namhyung,
	tmricht, brueckner, kan.liang, ben, mathieu.poirier,
	mark.rutland, will.deacon
  Cc: linux-kernel, linuxarm, linux-arm-kernel, zhangshaokun, ak, John Garry

Add support for Hisi hip08 L3C PMU event aliasing.

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

Signed-off-by: John Garry <john.garry@huawei.com>
---
 .../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

diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-l3c.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-l3c.json
new file mode 100644
index 000000000000..5bdc1a533d5e
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-l3c.json
@@ -0,0 +1,37 @@
+[
+   {
+	    "EventCode": "0x00",
+	    "EventName": "uncore_hisi_sccl_l3c.rd_cpipe",
+	    "BriefDescription": "Total read accesses",
+	    "PublicDescription": "Total read accesses",
+	    "Unit": "hisi_sccl,l3c",
+   },
+   {
+	    "EventCode": "0x01",
+	    "EventName": "uncore_hisi_sccl_l3c.wr_cpipe",
+	    "BriefDescription": "Total write accesses",
+	    "PublicDescription": "Total write accesses",
+	    "Unit": "hisi_sccl,l3c",
+   },
+   {
+	    "EventCode": "0x02",
+	    "EventName": "uncore_hisi_sccl_l3c.rd_hit_cpipe",
+	    "BriefDescription": "Total read hits",
+	    "PublicDescription": "Total read hits",
+	    "Unit": "hisi_sccl,l3c",
+   },
+   {
+	    "EventCode": "0x03",
+	    "EventName": "uncore_hisi_sccl_l3c.wr_hit_cpipe",
+	    "BriefDescription": "Total write hits",
+	    "PublicDescription": "Total write hits",
+	    "Unit": "hisi_sccl,l3c",
+   },
+   {
+	    "EventCode": "0x04",
+	    "EventName": "uncore_hisi_sccl_l3c.victim_num",
+	    "BriefDescription": "l3c precharge commands",
+	    "PublicDescription": "l3c precharge commands",
+	    "Unit": "hisi_sccl,l3c",
+   },
+]
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index 909e53e3b5bd..7d241efd03de 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -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" },
 	{}
 };
 
-- 
2.17.1


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

* Re: [PATCH 2/5] perf pmu: Support more complex PMU event aliasing
  2019-06-10  9:59 ` [PATCH 2/5] perf pmu: Support more complex PMU event aliasing John Garry
@ 2019-06-11 16:10   ` Jiri Olsa
  2019-06-11 16:22     ` John Garry
  0 siblings, 1 reply; 8+ messages in thread
From: Jiri Olsa @ 2019-06-11 16:10 UTC (permalink / raw)
  To: John Garry
  Cc: peterz, mingo, acme, alexander.shishkin, namhyung, tmricht,
	brueckner, kan.liang, ben, mathieu.poirier, mark.rutland,
	will.deacon, linux-kernel, linuxarm, linux-arm-kernel,
	zhangshaokun, ak

On Mon, Jun 10, 2019 at 05:59:29PM +0800, John Garry wrote:
> 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 ','.
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
>  tools/perf/util/pmu.c | 45 ++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 40 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index 036047f56efa..f00cae750086 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -700,6 +700,44 @@ 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)
> +{
> +	/*
> +	 * uncore alias may be from different PMU
> +	 * with common prefix
> +	 */
> +	if (!strncmp(pmu_name, name, strlen(pmu_name)))
> +		return true;
> +
> +	/* match strings with delimiter, ',' */
> +	while (1) {
> +		const char *delimiter;
> +		char token[256] = {};
> +		const char *found_token;
> +		int token_len;
> +
> +		delimiter = strchr(pmu_name, ',');
> +		if (delimiter) {
> +			token_len = delimiter - pmu_name;
> +		} else {
> +			token_len = strlen(pmu_name);
> +		}
> +
> +		memcpy(token, pmu_name, token_len);
> +
> +		found_token = strstr(name, token);
> +		if (!found_token)
> +			return false;
> +
> +		/* No more delimiters, so we must be a match */
> +		if (!delimiter)
> +			return true;
> +
> +		pmu_name += token_len + 1;
> +		name = found_token + token_len;
> +	}

hum, would this be easier with strtok_r?

jirka

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

* Re: [PATCH 2/5] perf pmu: Support more complex PMU event aliasing
  2019-06-11 16:10   ` Jiri Olsa
@ 2019-06-11 16:22     ` John Garry
  0 siblings, 0 replies; 8+ messages in thread
From: John Garry @ 2019-06-11 16:22 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: peterz, mingo, acme, alexander.shishkin, namhyung, tmricht,
	brueckner, kan.liang, ben, mathieu.poirier, mark.rutland,
	will.deacon, linux-kernel, linuxarm, linux-arm-kernel,
	zhangshaokun, ak

On 11/06/2019 17:10, Jiri Olsa wrote:
> On Mon, Jun 10, 2019 at 05:59:29PM +0800, John Garry wrote:
>> 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 ','.
>>
>> Signed-off-by: John Garry <john.garry@huawei.com>
>> ---
>>  tools/perf/util/pmu.c | 45 ++++++++++++++++++++++++++++++++++++++-----
>>  1 file changed, 40 insertions(+), 5 deletions(-)
>>
>> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
>> index 036047f56efa..f00cae750086 100644
>> --- a/tools/perf/util/pmu.c
>> +++ b/tools/perf/util/pmu.c
>> @@ -700,6 +700,44 @@ 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)
>> +{
>> +	/*
>> +	 * uncore alias may be from different PMU
>> +	 * with common prefix
>> +	 */
>> +	if (!strncmp(pmu_name, name, strlen(pmu_name)))
>> +		return true;
>> +
>> +	/* match strings with delimiter, ',' */
>> +	while (1) {
>> +		const char *delimiter;
>> +		char token[256] = {};
>> +		const char *found_token;
>> +		int token_len;
>> +
>> +		delimiter = strchr(pmu_name, ',');
>> +		if (delimiter) {
>> +			token_len = delimiter - pmu_name;
>> +		} else {
>> +			token_len = strlen(pmu_name);
>> +		}
>> +
>> +		memcpy(token, pmu_name, token_len);
>> +
>> +		found_token = strstr(name, token);
>> +		if (!found_token)
>> +			return false;
>> +
>> +		/* No more delimiters, so we must be a match */
>> +		if (!delimiter)
>> +			return true;
>> +
>> +		pmu_name += token_len + 1;
>> +		name = found_token + token_len;
>> +	}
>
> hum, would this be easier with strtok_r?

Yes, I think so.

Cheers,

>
> jirka
>
> .
>



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

end of thread, other threads:[~2019-06-11 16:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-10  9:59 [PATCH 0/5] Perf uncore PMU event alias support for Hisi hip08 ARM64 platform John Garry
2019-06-10  9:59 ` [PATCH 1/5] perf pmu: Fix uncore PMU alias list for ARM64 John Garry
2019-06-10  9:59 ` [PATCH 2/5] perf pmu: Support more complex PMU event aliasing John Garry
2019-06-11 16:10   ` Jiri Olsa
2019-06-11 16:22     ` John Garry
2019-06-10  9:59 ` [PATCH 3/5] perf jevents: Add support for Hisi hip08 DDRC PMU aliasing John Garry
2019-06-10  9:59 ` [PATCH 4/5] perf jevents: Add support for Hisi hip08 HHA " John Garry
2019-06-10  9:59 ` [PATCH 5/5] perf jevents: Add support for Hisi hip08 L3C " John Garry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).