linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/4] Add metric for Arm CMN
@ 2023-07-23  8:21 Jing Zhang
  2023-07-23  8:21 ` [PATCH v4 1/4] perf metric: Event "Compat" value supports matching multiple identifiers Jing Zhang
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Jing Zhang @ 2023-07-23  8:21 UTC (permalink / raw)
  To: John Garry, Ian Rogers
  Cc: Will Deacon, Mark Rutland, Robin Murphy, James Clark, Mike Leach,
	Leo Yan, Ilkka Koskinen, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Adrian Hunter, linux-kernel, linux-arm-kernel,
	linux-perf-users, linux-doc, Zhuo Song, Jing Zhang, Shuai Xue

Hi all,

This patch set adds event aliases and metrics for Arm CMN, and expands
Compat's ability to match multiple identifiers and expands event fields
in order to achieve the above capabilities.

If it is no longer necessary to declare the "Compat" or "Unit" value
when the metric is described by event aliases, I will delete "Compat"
and "Unit" in the metric, but keep them for now.

Changes since v3:
- Split the arm CMN and ali_drw PMU patches compare to v3. ali_drw PMU
  related patches are in another patchset.
- "Compat" supports matching multiple identifiers.
- Support more event filed.
- Add alias for part of Arm CMN PMU.
- Fix some bug for CMN metric description.
- Link: https://lore.kernel.org/all/1685438374-33287-1-git-send-email-renyu.zj@linux.alibaba.com/

Jing Zhang (4):
  perf metric: Event "Compat" value supports matching multiple
    identifiers
  perf jevents: Support more event fields
  perf vendor events: Add alias for Arm CMN PMU events.
  perf vendor events: Add metrics for Arm CMN

 .../pmu-events/arch/arm64/arm/cmn/sys/cmn.json     | 266 +++++++++++++++++++++
 .../pmu-events/arch/arm64/arm/cmn/sys/metric.json  |  74 ++++++
 tools/perf/pmu-events/jevents.py                   |  23 +-
 tools/perf/util/metricgroup.c                      |  27 ++-
 4 files changed, 381 insertions(+), 9 deletions(-)
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cmn/sys/cmn.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cmn/sys/metric.json

-- 
1.8.3.1


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

* [PATCH v4 1/4] perf metric: Event "Compat" value supports matching multiple identifiers
  2023-07-23  8:21 [PATCH v4 0/4] Add metric for Arm CMN Jing Zhang
@ 2023-07-23  8:21 ` Jing Zhang
  2023-07-25  8:20   ` John Garry
  2023-07-23  8:21 ` [PATCH v4 2/4] perf jevents: Support more event fields Jing Zhang
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Jing Zhang @ 2023-07-23  8:21 UTC (permalink / raw)
  To: John Garry, Ian Rogers
  Cc: Will Deacon, Mark Rutland, Robin Murphy, James Clark, Mike Leach,
	Leo Yan, Ilkka Koskinen, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Adrian Hunter, linux-kernel, linux-arm-kernel,
	linux-perf-users, linux-doc, Zhuo Song, Jing Zhang, Shuai Xue

The jevent "Compat" is used for uncore PMU alias or metric definitions.

The same PMU driver has different PMU identifiers due to different hardware
versions and types, but they may have some common PMU event/metric. Since a
Compat value can only match one identifier, when adding the same event
alias and metric to PMUs with different identifiers, each identifier needs
to be defined once, which is not streamlined enough.

So let "Compat" value supports matching multiple identifiers. For example,
the Compat value {abcde;123*} can match the PMU identifier "abcde" and the
the PMU identifier with the prefix "123", where "*" is a wildcard.
Tokens in Unit field are delimited by ';' with no spaces.

Signed-off-by: Jing Zhang <renyu.zj@linux.alibaba.com>
---
 tools/perf/util/metricgroup.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index f3559be..c910df0 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -456,6 +456,31 @@ struct metricgroup_iter_data {
 	void *data;
 };
 
+static bool match_pmu_identifier(const char *id, const char *compat)
+{
+	char *tmp = NULL, *tok, *str;
+	bool res;
+	int n;
+
+	str = strdup(compat);
+	if (!str)
+		return false;
+
+	tok = strtok_r(str, ";", &tmp);
+	for (; tok; tok = strtok_r(NULL, ";", &tmp)) {
+		n = strlen(tok);
+		if ((tok[n - 1] == '*' && !strncmp(id, tok, n - 1)) ||
+		    !strcmp(id, tok)) {
+			res = true;
+			goto out;
+		}
+	}
+	res = false;
+out:
+	free(str);
+	return res;
+}
+
 static int metricgroup__sys_event_iter(const struct pmu_metric *pm,
 				       const struct pmu_metrics_table *table,
 				       void *data)
@@ -468,7 +493,7 @@ static int metricgroup__sys_event_iter(const struct pmu_metric *pm,
 
 	while ((pmu = perf_pmu__scan(pmu))) {
 
-		if (!pmu->id || strcmp(pmu->id, pm->compat))
+		if (!pmu->id || !match_pmu_identifier(pmu->id, pm->compat))
 			continue;
 
 		return d->fn(pm, table, d->data);
-- 
1.8.3.1


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

* [PATCH v4 2/4] perf jevents: Support more event fields
  2023-07-23  8:21 [PATCH v4 0/4] Add metric for Arm CMN Jing Zhang
  2023-07-23  8:21 ` [PATCH v4 1/4] perf metric: Event "Compat" value supports matching multiple identifiers Jing Zhang
@ 2023-07-23  8:21 ` Jing Zhang
  2023-07-25  9:41   ` John Garry
  2023-07-23  8:21 ` [PATCH v4 3/4] perf vendor events: Add alias for Arm CMN PMU events Jing Zhang
  2023-07-23  8:21 ` [PATCH v4 4/4] perf vendor events: Add metrics for Arm CMN Jing Zhang
  3 siblings, 1 reply; 9+ messages in thread
From: Jing Zhang @ 2023-07-23  8:21 UTC (permalink / raw)
  To: John Garry, Ian Rogers
  Cc: Will Deacon, Mark Rutland, Robin Murphy, James Clark, Mike Leach,
	Leo Yan, Ilkka Koskinen, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Adrian Hunter, linux-kernel, linux-arm-kernel,
	linux-perf-users, linux-doc, Zhuo Song, Jing Zhang, Shuai Xue

The usual event descriptions are "event=xxx" or "config=xxx", while the
event descriptions of CMN are "type=xxx, eventid=xxx" or more complex.

$cat /sys/bus/event_source/devices/arm_cmn_0/events/hnf_cache_fill
type=0x5,eventid=0x3

When adding aliases for events described as "event=xxx" or "config=xxx",
EventCode or ConfigCode can be used in the JSON files to describe the
events. But "eventid=xxx, type=xxx" cannot be supported at present.

If EventCode and ConfigCode is not added in the alias JSON file, the
event description will add "event=0" by default. So, even if the event
field is added to supplement "eventid=xxx" and "type=xxx", the final
parsing result will be "event=0, eventid=xxx, type=xxx".

Therefore, when EventCode and ConfigCode are missing in JSON, "event=0" is
no longer added by default. EventidCode and Type are added to the event
field, and ConfigCode is moved into the event field.

Signed-off-by: Jing Zhang <renyu.zj@linux.alibaba.com>
---
 tools/perf/pmu-events/jevents.py | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
index 2bcd07c..79c3cfa 100755
--- a/tools/perf/pmu-events/jevents.py
+++ b/tools/perf/pmu-events/jevents.py
@@ -259,12 +259,6 @@ class JsonEvent:
       }
       return table[unit] if unit in table else f'uncore_{unit.lower()}'
 
-    eventcode = 0
-    if 'EventCode' in jd:
-      eventcode = int(jd['EventCode'].split(',', 1)[0], 0)
-    if 'ExtSel' in jd:
-      eventcode |= int(jd['ExtSel']) << 8
-    configcode = int(jd['ConfigCode'], 0) if 'ConfigCode' in jd else None
     self.name = jd['EventName'].lower() if 'EventName' in jd else None
     self.topic = ''
     self.compat = jd.get('Compat')
@@ -297,7 +291,15 @@ class JsonEvent:
     if precise and self.desc and '(Precise Event)' not in self.desc:
       extra_desc += ' (Must be precise)' if precise == '2' else (' (Precise '
                                                                  'event)')
-    event = f'config={llx(configcode)}' if configcode is not None else f'event={llx(eventcode)}'
+    eventcode = None
+    if 'EventCode' in jd:
+      eventcode = int(jd['EventCode'].split(',', 1)[0], 0)
+    if 'ExtSel' in jd:
+      if eventcode is None:
+        eventcode = int(jd['ExtSel']) << 8
+      else:
+        eventcode |= int(jd['ExtSel']) << 8
+    event = f'event={llx(eventcode)}' if eventcode is not None else None
     event_fields = [
         ('AnyThread', 'any='),
         ('PortMask', 'ch_mask='),
@@ -307,10 +309,14 @@ class JsonEvent:
         ('Invert', 'inv='),
         ('SampleAfterValue', 'period='),
         ('UMask', 'umask='),
+        ('ConfigCode', 'config='),
+        ('EventIdCode', 'eventid='),
+        ('Type', 'type='),
+        ('OccupId', 'occupid='),
     ]
     for key, value in event_fields:
       if key in jd and jd[key] != '0':
-        event += ',' + value + jd[key]
+        event = event + ',' + value + jd[key] if event is not None else value + jd[key]
     if filter:
       event += f',{filter}'
     if msr:
-- 
1.8.3.1


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

* [PATCH v4 3/4] perf vendor events: Add alias for Arm CMN PMU events.
  2023-07-23  8:21 [PATCH v4 0/4] Add metric for Arm CMN Jing Zhang
  2023-07-23  8:21 ` [PATCH v4 1/4] perf metric: Event "Compat" value supports matching multiple identifiers Jing Zhang
  2023-07-23  8:21 ` [PATCH v4 2/4] perf jevents: Support more event fields Jing Zhang
@ 2023-07-23  8:21 ` Jing Zhang
  2023-07-23  8:21 ` [PATCH v4 4/4] perf vendor events: Add metrics for Arm CMN Jing Zhang
  3 siblings, 0 replies; 9+ messages in thread
From: Jing Zhang @ 2023-07-23  8:21 UTC (permalink / raw)
  To: John Garry, Ian Rogers
  Cc: Will Deacon, Mark Rutland, Robin Murphy, James Clark, Mike Leach,
	Leo Yan, Ilkka Koskinen, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Adrian Hunter, linux-kernel, linux-arm-kernel,
	linux-perf-users, linux-doc, Zhuo Song, Jing Zhang, Shuai Xue

Currently just add alias for part of Arm CMN PMU events which are
general and compatible for any SoC and CMN-ANY.

"Compat" value "434*;436*;43c*;43a*" means it is compatible with all
CMN600/CMN650/CMN700/Ci700.

Signed-off-by: Jing Zhang <renyu.zj@linux.alibaba.com>
---
 .../pmu-events/arch/arm64/arm/cmn/sys/cmn.json     | 266 +++++++++++++++++++++
 tools/perf/pmu-events/jevents.py                   |   1 +
 2 files changed, 267 insertions(+)
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cmn/sys/cmn.json

diff --git a/tools/perf/pmu-events/arch/arm64/arm/cmn/sys/cmn.json b/tools/perf/pmu-events/arch/arm64/arm/cmn/sys/cmn.json
new file mode 100644
index 0000000..e54036c
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/arm/cmn/sys/cmn.json
@@ -0,0 +1,266 @@
+[
+	{
+		"EventName": "hnf_cache_miss",
+		"EventIdCode": "0x1",
+		"Type": "0x5",
+		"BriefDescription": "Counts total cache misses in first lookup result (high priority).",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hnf_slc_sf_cache_access",
+		"EventIdCode": "0x2",
+		"Type": "0x5",
+		"BriefDescription": "Counts number of cache accesses in first access (high priority).",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hnf_cache_fill",
+		"EventIdCode": "0x3",
+		"Type": "0x5",
+		"BriefDescription": "Counts total allocations in HN SLC (all cache line allocations to SLC).",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hnf_pocq_retry",
+		"EventIdCode": "0x4",
+		"Type": "0x5",
+		"BriefDescription": "Counts number of retried requests.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hnf_pocq_reqs_recvd",
+		"EventIdCode": "0x5",
+		"Type": "0x5",
+		"BriefDescription": "Counts number of requests that HN receives.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hnf_sf_hit",
+		"EventIdCode": "0x6",
+		"Type": "0x5",
+		"BriefDescription": "Counts number of SF hits.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hnf_sf_evictions",
+		"EventIdCode": "0x7",
+		"Type": "0x5",
+		"BriefDescription": "Counts number of SF eviction cache invalidations initiated.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hnf_dir_snoops_sent",
+		"EventIdCode": "0x8",
+		"Type": "0x5",
+		"BriefDescription": "Counts number of directed snoops sent (not including SF back invalidation).",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hnf_brd_snoops_sent",
+		"EventIdCode": "0x9",
+		"Type": "0x5",
+		"BriefDescription": "Counts number of multicast snoops sent (not including SF back invalidation).",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hnf_slc_eviction",
+		"EventIdCode": "0xa",
+		"Type": "0x5",
+		"BriefDescription": "Counts number of SLC evictions (dirty only).",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hnf_slc_fill_invalid_way",
+		"EventIdCode": "0xb",
+		"Type": "0x5",
+		"BriefDescription": "Counts number of SLC fills to an invalid way.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hnf_mc_retries",
+		"EventIdCode": "0xc",
+		"Type": "0x5",
+		"BriefDescription": "Counts number of retried transactions by the MC.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hnf_mc_reqs",
+		"EventIdCode": "0xd",
+		"Type": "0x5",
+		"BriefDescription": "Counts number of requests that are sent to MC.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hnf_qos_hh_retry",
+		"EventIdCode": "0xe",
+		"Type": "0x5",
+		"BriefDescription": "Counts number of times a HighHigh priority request is protocolretried at the HN‑F.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "rnid_s0_rdata_beats",
+		"EventIdCode": "0x1",
+		"Type": "0xa",
+		"BriefDescription": "Number of RData beats (RVALID and RREADY) dispatched on port 0. This event measures the read bandwidth, including CMO responses.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "rnid_s1_rdata_beats",
+		"EventIdCode": "0x2",
+		"Type": "0xa",
+		"BriefDescription": "Number of RData beats (RVALID and RREADY) dispatched on port 1. This event measures the read bandwidth, including CMO responses.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "rnid_s2_rdata_beats",
+		"EventIdCode": "0x3",
+		"Type": "0xa",
+		"BriefDescription": "Number of RData beats (RVALID and RREADY) dispatched on port 2. This event measures the read bandwidth, including CMO responses.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "rnid_rxdat_flits",
+		"EventIdCode": "0x4",
+		"Type": "0xa",
+		"BriefDescription": "Number of RXDAT flits received. This event measures the true read data bandwidth, excluding CMOs.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "rnid_txdat_flits",
+		"EventIdCode": "0x5",
+		"Type": "0xa",
+		"BriefDescription": "Number of TXDAT flits dispatched. This event measures the write bandwidth.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "rnid_txreq_flits_total",
+		"EventIdCode": "0x6",
+		"Type": "0xa",
+		"BriefDescription": "Number of TXREQ flits dispatched. This event measures the total request bandwidth.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "rnid_txreq_flits_retried",
+		"EventIdCode": "0x7",
+		"Type": "0xa",
+		"BriefDescription": "Number of retried TXREQ flits dispatched. This event measures the retry rate.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "sbsx_txrsp_retryack",
+		"EventIdCode": "0x4",
+		"Type": "0x7",
+		"BriefDescription": "Number of RXREQ flits dispatched. This event is a measure of the retry rate.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "sbsx_txdat_flitv",
+		"EventIdCode": "0x5",
+		"Type": "0x7",
+		"BriefDescription": "Number of TXDAT flits dispatched from XP to SBSX. This event is a measure of the write bandwidth.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "sbsx_arvalid_no_arready",
+		"EventIdCode": "0x21",
+		"Type": "0x7",
+		"BriefDescription": "Number of cycles the SBSX bridge is stalled because of backpressure on AR channel.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "sbsx_awvalid_no_awready",
+		"EventIdCode": "0x22",
+		"Type": "0x7",
+		"BriefDescription": "Number of cycles the SBSX bridge is stalled because of backpressure on AW channel.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "sbsx_wvalid_no_wready",
+		"EventIdCode": "0x23",
+		"Type": "0x7",
+		"BriefDescription": "Number of cycles the SBSX bridge is stalled because of backpressure on W channel.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hni_txrsp_retryack",
+		"EventIdCode": "0x2a",
+		"Type": "0x4",
+		"BriefDescription": "Number of RXREQ flits dispatched. This event is a measure of the retry rate.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hni_arvalid_no_arready",
+		"EventIdCode": "0x2b",
+		"Type": "0x4",
+		"BriefDescription": "Number of cycles the HN-I bridge is stalled because of backpressure on AR channel.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hni_arready_no_arvalid",
+		"EventIdCode": "0x2c",
+		"Type": "0x4",
+		"BriefDescription": "Number of cycles the AR channel is waiting for new requests from HN-I bridge.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hni_awvalid_no_awready",
+		"EventIdCode": "0x2d",
+		"Type": "0x4",
+		"BriefDescription": "Number of cycles the HN-I bridge is stalled because of backpressure on AW channel.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hni_awready_no_awvalid",
+		"EventIdCode": "0x2e",
+		"Type": "0x4",
+		"BriefDescription": "Number of cycles the AW channel is waiting for new requests from HN-I bridge.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hni_wvalid_no_wready",
+		"EventIdCode": "0x2f",
+		"Type": "0x4",
+		"BriefDescription": "Number of cycles the HN-I bridge is stalled because of backpressure on W channel.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"EventName": "hni_txdat_stall",
+		"EventIdCode": "0x30",
+		"Type": "0x4",
+		"BriefDescription": "TXDAT valid but no link credit available.",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	}
+]
diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
index 79c3cfa..4d8037d 100755
--- a/tools/perf/pmu-events/jevents.py
+++ b/tools/perf/pmu-events/jevents.py
@@ -256,6 +256,7 @@ class JsonEvent:
           'DFPMC': 'amd_df',
           'cpu_core': 'cpu_core',
           'cpu_atom': 'cpu_atom',
+          'arm_cmn': 'arm_cmn',
       }
       return table[unit] if unit in table else f'uncore_{unit.lower()}'
 
-- 
1.8.3.1


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

* [PATCH v4 4/4] perf vendor events: Add metrics for Arm CMN
  2023-07-23  8:21 [PATCH v4 0/4] Add metric for Arm CMN Jing Zhang
                   ` (2 preceding siblings ...)
  2023-07-23  8:21 ` [PATCH v4 3/4] perf vendor events: Add alias for Arm CMN PMU events Jing Zhang
@ 2023-07-23  8:21 ` Jing Zhang
  3 siblings, 0 replies; 9+ messages in thread
From: Jing Zhang @ 2023-07-23  8:21 UTC (permalink / raw)
  To: John Garry, Ian Rogers
  Cc: Will Deacon, Mark Rutland, Robin Murphy, James Clark, Mike Leach,
	Leo Yan, Ilkka Koskinen, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Adrian Hunter, linux-kernel, linux-arm-kernel,
	linux-perf-users, linux-doc, Zhuo Song, Jing Zhang, Shuai Xue

Add JSON metrics for Arm CMN. Currently just add part of CMN PMU
metrics which are general and compatible for any SoC with CMN-ANY.

Signed-off-by: Jing Zhang <renyu.zj@linux.alibaba.com>
---
 .../pmu-events/arch/arm64/arm/cmn/sys/metric.json  | 74 ++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cmn/sys/metric.json

diff --git a/tools/perf/pmu-events/arch/arm64/arm/cmn/sys/metric.json b/tools/perf/pmu-events/arch/arm64/arm/cmn/sys/metric.json
new file mode 100644
index 0000000..64db534
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/arm/cmn/sys/metric.json
@@ -0,0 +1,74 @@
+[
+	{
+		"MetricName": "slc_miss_rate",
+		"BriefDescription": "The system level cache miss rate.",
+		"MetricGroup": "cmn",
+		"MetricExpr": "hnf_cache_miss / hnf_slc_sf_cache_access",
+		"ScaleUnit": "100%",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"MetricName": "hnf_message_retry_rate",
+		"BriefDescription": "HN-F message retry rate indicates whether a lack of credits is causing the bottlenecks.",
+		"MetricGroup": "cmn",
+		"MetricExpr": "hnf_pocq_retry / hnf_pocq_reqs_recvd",
+		"ScaleUnit": "100%",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"MetricName": "sf_hit_rate",
+		"BriefDescription": "Snoop filter hit rate can be used to measure the snoop filter efficiency.",
+		"MetricGroup": "cmn",
+		"MetricExpr": "hnf_sf_hit / hnf_slc_sf_cache_access",
+		"ScaleUnit": "100%",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"MetricName": "mc_message_retry_rate",
+		"BriefDescription": "The memory controller request retries rate indicates whether the memory controller is the bottleneck.",
+		"MetricGroup": "cmn",
+		"MetricExpr": "hnf_mc_retries / hnf_mc_reqs",
+		"ScaleUnit": "100%",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"MetricName": "rni_actual_read_bandwidth.all",
+		"BriefDescription": "This event measure the actual bandwidth that RN-I bridge sends to the interconnect.",
+		"MetricGroup": "cmn",
+		"MetricExpr": "rnid_rxdat_flits * 32 / 1e6 / duration_time",
+		"ScaleUnit": "1MB/s",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"MetricName": "rni_actual_write_bandwidth.all",
+		"BriefDescription": "This event measures the actual write bandwidth at RN-I bridges.",
+		"MetricGroup": "cmn",
+		"MetricExpr": "rnid_txdat_flits * 32 / 1e6 / duration_time",
+		"ScaleUnit": "1MB/s",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"MetricName": "rni_retry_rate",
+		"BriefDescription": "RN-I bridge retry rate indicates whether the memory controller is the bottleneck.",
+		"MetricGroup": "cmn",
+		"MetricExpr": "rnid_txreq_flits_retried / rnid_txreq_flits_total",
+		"ScaleUnit": "100%",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	},
+	{
+		"MetricName": "sbsx_actual_write_bandwidth.all",
+		"BriefDescription": "sbsx actual write bandwidth.",
+		"MetricGroup": "cmn",
+		"MetricExpr": "sbsx_txdat_flitv * 32 / 1e6 / duration_time",
+		"ScaleUnit": "1MB/s",
+		"Unit": "arm_cmn",
+		"Compat": "434*;436*;43c*;43a*"
+	}
+]
-- 
1.8.3.1


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

* Re: [PATCH v4 1/4] perf metric: Event "Compat" value supports matching multiple identifiers
  2023-07-23  8:21 ` [PATCH v4 1/4] perf metric: Event "Compat" value supports matching multiple identifiers Jing Zhang
@ 2023-07-25  8:20   ` John Garry
  2023-07-26  6:15     ` Jing Zhang
  0 siblings, 1 reply; 9+ messages in thread
From: John Garry @ 2023-07-25  8:20 UTC (permalink / raw)
  To: Jing Zhang, Ian Rogers
  Cc: Will Deacon, Mark Rutland, Robin Murphy, James Clark, Mike Leach,
	Leo Yan, Ilkka Koskinen, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Adrian Hunter, linux-kernel, linux-arm-kernel,
	linux-perf-users, linux-doc, Zhuo Song, Shuai Xue

On 23/07/2023 09:21, Jing Zhang wrote:
> The jevent "Compat" is used for uncore PMU alias or metric definitions.
> 
> The same PMU driver has different PMU identifiers due to different hardware
> versions and types, but they may have some common PMU event/metric. Since a
> Compat value can only match one identifier, when adding the same event
> alias and metric to PMUs with different identifiers, each identifier needs
> to be defined once, which is not streamlined enough.
> 
> So let "Compat" value supports matching multiple identifiers. For example,
> the Compat value {abcde;123*} can match the PMU identifier "abcde" and the
> the PMU identifier with the prefix "123", where "*" is a wildcard.
> Tokens in Unit field are delimited by ';' with no spaces.
> 
> Signed-off-by: Jing Zhang <renyu.zj@linux.alibaba.com>
> ---
>   tools/perf/util/metricgroup.c | 27 ++++++++++++++++++++++++++-

Why only support for metrics? Why not support for regular events 
aliases? I would have expected pmu_add_sys_aliases_iter_fn() to have 
been updated for this.

On the basis that we will support regular events aliases, we need perf 
tool self-test cases for this in tools/perf/test/pmu-events.c (I think 
that pmu-events.c would be the most appropriate file)

Thanks,
John


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

* Re: [PATCH v4 2/4] perf jevents: Support more event fields
  2023-07-23  8:21 ` [PATCH v4 2/4] perf jevents: Support more event fields Jing Zhang
@ 2023-07-25  9:41   ` John Garry
  2023-07-26  6:40     ` Jing Zhang
  0 siblings, 1 reply; 9+ messages in thread
From: John Garry @ 2023-07-25  9:41 UTC (permalink / raw)
  To: Jing Zhang, Ian Rogers
  Cc: Will Deacon, Mark Rutland, Robin Murphy, James Clark, Mike Leach,
	Leo Yan, Ilkka Koskinen, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Adrian Hunter, linux-kernel, linux-arm-kernel,
	linux-perf-users, linux-doc, Zhuo Song, Shuai Xue

On 23/07/2023 09:21, Jing Zhang wrote:
> The usual event descriptions are "event=xxx" or "config=xxx", while the
> event descriptions of CMN are "type=xxx, eventid=xxx" or more complex.
> 
> $cat /sys/bus/event_source/devices/arm_cmn_0/events/hnf_cache_fill
> type=0x5,eventid=0x3
> 
> When adding aliases for events described as "event=xxx" or "config=xxx",
> EventCode or ConfigCode can be used in the JSON files to describe the
> events. But "eventid=xxx, type=xxx" cannot be supported at present.
> 
> If EventCode and ConfigCode is not added in the alias JSON file, the
> event description will add "event=0" by default. So, even if the event
> field is added to supplement "eventid=xxx" and "type=xxx", the final
> parsing result will be "event=0, eventid=xxx, type=xxx".
> 
> Therefore, when EventCode and ConfigCode are missing in JSON, "event=0" is
> no longer added by default. EventidCode and Type are added to the event
> field, and ConfigCode is moved into the event field.

What does "ConfigCode is moved into the event field" mean?

> 

There should be perf tool self-tests cases for this, see 
tests/pmu-events.c and tests/parse-events.c, like "umask" is tested

> Signed-off-by: Jing Zhang <renyu.zj@linux.alibaba.com>
> ---
>   tools/perf/pmu-events/jevents.py | 22 ++++++++++++++--------
>   1 file changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
> index 2bcd07c..79c3cfa 100755
> --- a/tools/perf/pmu-events/jevents.py
> +++ b/tools/perf/pmu-events/jevents.py
> @@ -259,12 +259,6 @@ class JsonEvent:
>         }
>         return table[unit] if unit in table else f'uncore_{unit.lower()}'


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

* Re: [PATCH v4 1/4] perf metric: Event "Compat" value supports matching multiple identifiers
  2023-07-25  8:20   ` John Garry
@ 2023-07-26  6:15     ` Jing Zhang
  0 siblings, 0 replies; 9+ messages in thread
From: Jing Zhang @ 2023-07-26  6:15 UTC (permalink / raw)
  To: John Garry, Ian Rogers
  Cc: Will Deacon, Mark Rutland, Robin Murphy, James Clark, Mike Leach,
	Leo Yan, Ilkka Koskinen, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Adrian Hunter, linux-kernel, linux-arm-kernel,
	linux-perf-users, linux-doc, Zhuo Song, Shuai Xue



在 2023/7/25 下午4:20, John Garry 写道:
> On 23/07/2023 09:21, Jing Zhang wrote:
>> The jevent "Compat" is used for uncore PMU alias or metric definitions.
>>
>> The same PMU driver has different PMU identifiers due to different hardware
>> versions and types, but they may have some common PMU event/metric. Since a
>> Compat value can only match one identifier, when adding the same event
>> alias and metric to PMUs with different identifiers, each identifier needs
>> to be defined once, which is not streamlined enough.
>>
>> So let "Compat" value supports matching multiple identifiers. For example,
>> the Compat value {abcde;123*} can match the PMU identifier "abcde" and the
>> the PMU identifier with the prefix "123", where "*" is a wildcard.
>> Tokens in Unit field are delimited by ';' with no spaces.
>>
>> Signed-off-by: Jing Zhang <renyu.zj@linux.alibaba.com>
>> ---
>>   tools/perf/util/metricgroup.c | 27 ++++++++++++++++++++++++++-
> 
> Why only support for metrics? Why not support for regular events aliases? I would have expected pmu_add_sys_aliases_iter_fn() to have been updated for this.
> 

Oh, you are right. I forgot to modify pmu_add_sys_aliases_iter_fn().

> On the basis that we will support regular events aliases, we need perf tool self-test cases for this in tools/perf/test/pmu-events.c (I think that pmu-events.c would be the most appropriate file)
> 

Ok, I will support it for regular events aliases and add self-test cases in the next version.

Thanks,
Jing

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

* Re: [PATCH v4 2/4] perf jevents: Support more event fields
  2023-07-25  9:41   ` John Garry
@ 2023-07-26  6:40     ` Jing Zhang
  0 siblings, 0 replies; 9+ messages in thread
From: Jing Zhang @ 2023-07-26  6:40 UTC (permalink / raw)
  To: John Garry, Ian Rogers
  Cc: Will Deacon, Mark Rutland, Robin Murphy, James Clark, Mike Leach,
	Leo Yan, Ilkka Koskinen, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Adrian Hunter, linux-kernel, linux-arm-kernel,
	linux-perf-users, linux-doc, Zhuo Song, Shuai Xue



在 2023/7/25 下午5:41, John Garry 写道:
> On 23/07/2023 09:21, Jing Zhang wrote:
>> The usual event descriptions are "event=xxx" or "config=xxx", while the
>> event descriptions of CMN are "type=xxx, eventid=xxx" or more complex.
>>
>> $cat /sys/bus/event_source/devices/arm_cmn_0/events/hnf_cache_fill
>> type=0x5,eventid=0x3
>>
>> When adding aliases for events described as "event=xxx" or "config=xxx",
>> EventCode or ConfigCode can be used in the JSON files to describe the
>> events. But "eventid=xxx, type=xxx" cannot be supported at present.
>>
>> If EventCode and ConfigCode is not added in the alias JSON file, the
>> event description will add "event=0" by default. So, even if the event
>> field is added to supplement "eventid=xxx" and "type=xxx", the final
>> parsing result will be "event=0, eventid=xxx, type=xxx".
>>
>> Therefore, when EventCode and ConfigCode are missing in JSON, "event=0" is
>> no longer added by default. EventidCode and Type are added to the event
>> field, and ConfigCode is moved into the event field.
> 
> What does "ConfigCode is moved into the event field" mean?
> 

What I want to express is to move "ConfigCode" into the event_filed array which can also guarantee its original function. like this:
event_fields = [
	  ...
          ('AnyThread', 'any='),
          ('PortMask', 'ch_mask='),
          ('ConfigCode', 'config='),
	  ...
]

Haha, my English language proficiency still needs improvement, please forgive me.

>>
> 
> There should be perf tool self-tests cases for this, see tests/pmu-events.c and tests/parse-events.c, like "umask" is tested
> 

Ok, will do.


Thanks,
Jing

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

end of thread, other threads:[~2023-07-26  6:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-23  8:21 [PATCH v4 0/4] Add metric for Arm CMN Jing Zhang
2023-07-23  8:21 ` [PATCH v4 1/4] perf metric: Event "Compat" value supports matching multiple identifiers Jing Zhang
2023-07-25  8:20   ` John Garry
2023-07-26  6:15     ` Jing Zhang
2023-07-23  8:21 ` [PATCH v4 2/4] perf jevents: Support more event fields Jing Zhang
2023-07-25  9:41   ` John Garry
2023-07-26  6:40     ` Jing Zhang
2023-07-23  8:21 ` [PATCH v4 3/4] perf vendor events: Add alias for Arm CMN PMU events Jing Zhang
2023-07-23  8:21 ` [PATCH v4 4/4] perf vendor events: Add metrics for Arm CMN Jing Zhang

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