2023-09-25 05:58:44

by Jing Zhang

[permalink] [raw]
Subject: [PATCH v10 0/7] Add metrics for Arm CMN

Changes since v8:
- Add fully match identifier check as suggested by Ian.
- Link: https://lore.kernel.org/lkml/[email protected]/

Jing Zhang (7):
perf pmu: "Compat" supports regular expression matching identifiers
perf metric: "Compat" supports regular expression matching identifiers
perf jevents: Support EventidCode and NodeType
perf test: Make matching_pmu effective
perf test: Add pmu-event test for "Compat" and new event_field.
perf jevents: Add support for Arm CMN PMU aliasing
perf vendor events: Add JSON metrics for Arm CMN

.../pmu-events/arch/arm64/arm/cmn/sys/cmn.json | 266 +++++++++++++++++++++
.../pmu-events/arch/arm64/arm/cmn/sys/metric.json | 74 ++++++
.../pmu-events/arch/test/test_soc/sys/uncore.json | 8 +
tools/perf/pmu-events/empty-pmu-events.c | 8 +
tools/perf/pmu-events/jevents.py | 11 +-
tools/perf/tests/pmu-events.c | 65 ++++-
tools/perf/util/metricgroup.c | 2 +-
tools/perf/util/pmu.c | 27 ++-
tools/perf/util/pmu.h | 1 +
9 files changed, 456 insertions(+), 6 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


2023-09-25 05:58:56

by Jing Zhang

[permalink] [raw]
Subject: [PATCH v10 1/7] perf pmu: "Compat" supports regular expression matching identifiers

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.
Since a Compat value can only match one identifier, when adding the
same event alias to PMUs with different identifiers, each identifier
needs to be defined once, which is not streamlined enough.

So let "Compat" support using regular expression to match identifiers
for uncore PMU alias. For example, if the "Compat" value is set to
"43401|43c01", it would be able to match PMU identifiers such as "43401"
or "43c01", which correspond to CMN600_r0p0 or CMN700_r0p0.

Signed-off-by: Jing Zhang <[email protected]>
---
tools/perf/util/pmu.c | 27 +++++++++++++++++++++++++--
tools/perf/util/pmu.h | 1 +
2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index e215985..a5bb9a8 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -28,6 +28,7 @@
#include "strbuf.h"
#include "fncache.h"
#include "util/evsel_config.h"
+#include <regex.h>

struct perf_pmu perf_pmu__fake = {
.name = "fake",
@@ -875,6 +876,28 @@ static bool pmu_uncore_alias_match(const char *pmu_name, const char *name)
return res;
}

+bool pmu_uncore_identifier_match(const char *compat, const char *id)
+{
+ regex_t re;
+ regmatch_t pmatch[1];
+ int match;
+
+ if (regcomp(&re, compat, REG_EXTENDED) != 0) {
+ /* Warn unable to generate match particular string. */
+ pr_info("Invalid regular expression %s\n", compat);
+ return false;
+ }
+
+ match = !regexec(&re, id, 1, pmatch, 0);
+ if (match) {
+ /* Ensure a full match. */
+ match = pmatch[0].rm_so == 0 && (size_t)pmatch[0].rm_eo == strlen(id);
+ }
+ regfree(&re);
+
+ return match;
+}
+
static int pmu_add_cpu_aliases_map_callback(const struct pmu_event *pe,
const struct pmu_events_table *table __maybe_unused,
void *vdata)
@@ -915,8 +938,8 @@ static int pmu_add_sys_aliases_iter_fn(const struct pmu_event *pe,
if (!pe->compat || !pe->pmu)
return 0;

- if (!strcmp(pmu->id, pe->compat) &&
- pmu_uncore_alias_match(pe->pmu, pmu->name)) {
+ if (pmu_uncore_alias_match(pe->pmu, pmu->name) &&
+ pmu_uncore_identifier_match(pe->compat, pmu->id)) {
perf_pmu__new_alias(pmu,
pe->name,
pe->desc,
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index bd5d804..fc155ce 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -240,6 +240,7 @@ void pmu_add_cpu_aliases_table(struct perf_pmu *pmu,
char *perf_pmu__getcpuid(struct perf_pmu *pmu);
const struct pmu_events_table *pmu_events_table__find(void);
const struct pmu_metrics_table *pmu_metrics_table__find(void);
+bool pmu_uncore_identifier_match(const char *compat, const char *id);

int perf_pmu__convert_scale(const char *scale, char **end, double *sval);

--
1.8.3.1

2023-09-25 05:58:58

by Jing Zhang

[permalink] [raw]
Subject: [PATCH v10 6/7] perf jevents: Add support for Arm CMN PMU aliasing

Currently just add aliases 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, which can be obtained from
commit 7819e05a0dce ("perf/arm-cmn: Revamp model detection").

The arm-cmn PMU events got from:
[0] https://developer.arm.com/documentation/100180/0302/?lang=en
[1] https://developer.arm.com/documentation/101408/0100/?lang=en
[2] https://developer.arm.com/documentation/102308/0302/?lang=en
[3] https://developer.arm.com/documentation/101569/0300/?lang=en

Signed-off-by: Jing Zhang <[email protected]>
Reviewed-by: John Garry <[email protected]>
---
.../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..428605c
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/arm/cmn/sys/cmn.json
@@ -0,0 +1,266 @@
+[
+ {
+ "EventName": "hnf_cache_miss",
+ "EventidCode": "0x1",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "0x5",
+ "BriefDescription": "Counts number of retried requests.",
+ "Unit": "arm_cmn",
+ "Compat": "(434|436|43c|43a).*"
+ },
+ {
+ "EventName": "hnf_pocq_reqs_recvd",
+ "EventidCode": "0x5",
+ "NodeType": "0x5",
+ "BriefDescription": "Counts number of requests that HN receives.",
+ "Unit": "arm_cmn",
+ "Compat": "(434|436|43c|43a).*"
+ },
+ {
+ "EventName": "hnf_sf_hit",
+ "EventidCode": "0x6",
+ "NodeType": "0x5",
+ "BriefDescription": "Counts number of SF hits.",
+ "Unit": "arm_cmn",
+ "Compat": "(434|436|43c|43a).*"
+ },
+ {
+ "EventName": "hnf_sf_evictions",
+ "EventidCode": "0x7",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "0x5",
+ "BriefDescription": "Counts number of retried transactions by the MC.",
+ "Unit": "arm_cmn",
+ "Compat": "(434|436|43c|43a).*"
+ },
+ {
+ "EventName": "hnf_mc_reqs",
+ "EventidCode": "0xd",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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",
+ "NodeType": "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 057d51aa..b1ab412 100755
--- a/tools/perf/pmu-events/jevents.py
+++ b/tools/perf/pmu-events/jevents.py
@@ -289,6 +289,7 @@ class JsonEvent:
'cpu_core': 'cpu_core',
'cpu_atom': 'cpu_atom',
'ali_drw': 'ali_drw',
+ 'arm_cmn': 'arm_cmn',
}
return table[unit] if unit in table else f'uncore_{unit.lower()}'

--
1.8.3.1

2023-09-25 05:59:22

by Jing Zhang

[permalink] [raw]
Subject: [PATCH v10 2/7] perf metric: "Compat" supports regular expression matching identifiers

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 metric.
Since a Compat value can only match one identifier, when adding the
same metric to PMUs with different identifiers, each identifier needs
to be defined once, which is not streamlined enough.

So let "Compat" support using regular expression to match multiple
identifiers for uncore PMU metric.

Signed-off-by: Jing Zhang <[email protected]>
Reviewed-by: John Garry <[email protected]>
Reviewed-by: Ian Rogers <[email protected]>
---
tools/perf/util/metricgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 6231044..0484736 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -498,7 +498,7 @@ static int metricgroup__sys_event_iter(const struct pmu_metric *pm,

while ((pmu = perf_pmus__scan(pmu))) {

- if (!pmu->id || strcmp(pmu->id, pm->compat))
+ if (!pmu->id || !pmu_uncore_identifier_match(pm->compat, pmu->id))
continue;

return d->fn(pm, table, d->data);
--
1.8.3.1

2023-09-25 05:59:26

by Jing Zhang

[permalink] [raw]
Subject: [PATCH v10 7/7] perf vendor events: Add JSON metrics for Arm CMN

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 <[email protected]>
Reviewed-by: John Garry <[email protected]>
---
.../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..f7823bd
--- /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

2023-09-25 05:59:51

by Jing Zhang

[permalink] [raw]
Subject: [PATCH v10 3/7] perf jevents: Support EventidCode and NodeType

The previous code assumes an event has either an "event=" or "config"
field at the beginning. For CMN neither of these may be present, as an
event is typically "type=xx,eventid=xxx".

So add EventidCode and NodeType to support CMN event description.

I compared pmu_event.c before and after compiling with JEVENT_ARCH=all,
they are consistent.

Signed-off-by: Jing Zhang <[email protected]>
---
tools/perf/pmu-events/jevents.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
index a7e8833..057d51aa 100755
--- a/tools/perf/pmu-events/jevents.py
+++ b/tools/perf/pmu-events/jevents.py
@@ -298,6 +298,7 @@ class JsonEvent:
if 'ExtSel' in jd:
eventcode |= int(jd['ExtSel']) << 8
configcode = int(jd['ConfigCode'], 0) if 'ConfigCode' in jd else None
+ eventidcode = int(jd['EventidCode'], 0) if 'EventidCode' in jd else None
self.name = jd['EventName'].lower() if 'EventName' in jd else None
self.topic = ''
self.compat = jd.get('Compat')
@@ -335,7 +336,13 @@ 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)}'
+ event = None
+ if configcode is not None:
+ event = f'config={llx(configcode)}'
+ elif eventidcode is not None:
+ event = f'eventid={llx(eventidcode)}'
+ else:
+ event = f'event={llx(eventcode)}'
event_fields = [
('AnyThread', 'any='),
('PortMask', 'ch_mask='),
@@ -345,6 +352,7 @@ class JsonEvent:
('Invert', 'inv='),
('SampleAfterValue', 'period='),
('UMask', 'umask='),
+ ('NodeType', 'type='),
]
for key, value in event_fields:
if key in jd and jd[key] != '0':
--
1.8.3.1

2023-09-25 05:59:52

by Jing Zhang

[permalink] [raw]
Subject: [PATCH v10 5/7] perf test: Add pmu-event test for "Compat" and new event_field.

Add new event test for uncore system event which is used to verify the
functionality of "Compat" matching multiple identifiers and the new event
fields "EventidCode" and "NodeType".

Signed-off-by: Jing Zhang <[email protected]>
---
.../pmu-events/arch/test/test_soc/sys/uncore.json | 8 ++++
tools/perf/pmu-events/empty-pmu-events.c | 8 ++++
tools/perf/tests/pmu-events.c | 55 ++++++++++++++++++++++
3 files changed, 71 insertions(+)

diff --git a/tools/perf/pmu-events/arch/test/test_soc/sys/uncore.json b/tools/perf/pmu-events/arch/test/test_soc/sys/uncore.json
index c7e7528..4d423b1 100644
--- a/tools/perf/pmu-events/arch/test/test_soc/sys/uncore.json
+++ b/tools/perf/pmu-events/arch/test/test_soc/sys/uncore.json
@@ -12,5 +12,13 @@
"EventName": "sys_ccn_pmu.read_cycles",
"Unit": "sys_ccn_pmu",
"Compat": "0x01"
+ },
+ {
+ "BriefDescription": "Counts total cache misses in first lookup result (high priority)",
+ "EventidCode": "0x1",
+ "NodeType": "0x5",
+ "EventName": "sys_cmn_pmu.hnf_cache_miss",
+ "Unit": "sys_cmn_pmu",
+ "Compat": "(434|436|43c|43a).*"
}
]
diff --git a/tools/perf/pmu-events/empty-pmu-events.c b/tools/perf/pmu-events/empty-pmu-events.c
index 12bd043..1372742 100644
--- a/tools/perf/pmu-events/empty-pmu-events.c
+++ b/tools/perf/pmu-events/empty-pmu-events.c
@@ -245,6 +245,14 @@ struct pmu_events_map {
.pmu = "uncore_sys_ccn_pmu",
},
{
+ .name = "sys_cmn_pmu.hnf_cache_miss",
+ .event = "eventid=0x1,type=0x5",
+ .desc = "Counts total cache misses in first lookup result (high priority). Unit: uncore_sys_cmn_pmu ",
+ .compat = "(434|436|43c|43a).*",
+ .topic = "uncore",
+ .pmu = "uncore_sys_cmn_pmu",
+ },
+ {
.name = 0,
.event = 0,
.desc = 0,
diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index 0cf572f..a56d329 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -262,9 +262,24 @@ struct perf_pmu_test_pmu {
.matching_pmu = "uncore_sys_ccn_pmu4",
};

+static const struct perf_pmu_test_event sys_cmn_pmu_hnf_cache_miss = {
+ .event = {
+ .name = "sys_cmn_pmu.hnf_cache_miss",
+ .event = "eventid=0x1,type=0x5",
+ .desc = "Counts total cache misses in first lookup result (high priority)",
+ .topic = "uncore",
+ .pmu = "uncore_sys_cmn_pmu",
+ .compat = "(434|436|43c|43a).*",
+ },
+ .alias_str = "eventid=0x1,type=0x5",
+ .alias_long_desc = "Counts total cache misses in first lookup result (high priority)",
+ .matching_pmu = "uncore_sys_cmn_pmu0",
+};
+
static const struct perf_pmu_test_event *sys_events[] = {
&sys_ddr_pmu_write_cycles,
&sys_ccn_pmu_read_cycles,
+ &sys_cmn_pmu_hnf_cache_miss,
NULL
};

@@ -707,6 +722,46 @@ static int __test_uncore_pmu_event_aliases(struct perf_pmu_test_pmu *test_pmu)
&sys_ccn_pmu_read_cycles,
},
},
+ {
+ .pmu = {
+ .name = (char *)"uncore_sys_cmn_pmu0",
+ .is_uncore = 1,
+ .id = (char *)"43401",
+ },
+ .aliases = {
+ &sys_cmn_pmu_hnf_cache_miss,
+ },
+ },
+ {
+ .pmu = {
+ .name = (char *)"uncore_sys_cmn_pmu0",
+ .is_uncore = 1,
+ .id = (char *)"43602",
+ },
+ .aliases = {
+ &sys_cmn_pmu_hnf_cache_miss,
+ },
+ },
+ {
+ .pmu = {
+ .name = (char *)"uncore_sys_cmn_pmu0",
+ .is_uncore = 1,
+ .id = (char *)"43c03",
+ },
+ .aliases = {
+ &sys_cmn_pmu_hnf_cache_miss,
+ },
+ },
+ {
+ .pmu = {
+ .name = (char *)"uncore_sys_cmn_pmu0",
+ .is_uncore = 1,
+ .id = (char *)"43a01",
+ },
+ .aliases = {
+ &sys_cmn_pmu_hnf_cache_miss,
+ },
+ }
};

/* Test that aliases generated are as expected */
--
1.8.3.1

2023-09-25 06:00:26

by Jing Zhang

[permalink] [raw]
Subject: [PATCH v10 4/7] perf test: Make matching_pmu effective

The perf_pmu_test_event.matching_pmu didn't work. No matter what its
value is, it does not affect the test results. So let matching_pmu be
used for matching perf_pmu_test_pmu.pmu.name.

Signed-off-by: Jing Zhang <[email protected]>
Reviewed-by: John Garry <[email protected]>
---
tools/perf/tests/pmu-events.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index f5321fb..0cf572f 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -245,7 +245,7 @@ struct perf_pmu_test_pmu {
},
.alias_str = "event=0x2b",
.alias_long_desc = "ddr write-cycles event",
- .matching_pmu = "uncore_sys_ddr_pmu",
+ .matching_pmu = "uncore_sys_ddr_pmu0",
};

static const struct perf_pmu_test_event sys_ccn_pmu_read_cycles = {
@@ -259,7 +259,7 @@ struct perf_pmu_test_pmu {
},
.alias_str = "config=0x2c",
.alias_long_desc = "ccn read-cycles event",
- .matching_pmu = "uncore_sys_ccn_pmu",
+ .matching_pmu = "uncore_sys_ccn_pmu4",
};

static const struct perf_pmu_test_event *sys_events[] = {
@@ -615,6 +615,12 @@ static int __test_uncore_pmu_event_aliases(struct perf_pmu_test_pmu *test_pmu)
.count = &matched_count,
};

+ if (strcmp(pmu_name, test_event.matching_pmu)) {
+ pr_debug("testing aliases uncore PMU %s: mismatched matching_pmu, %s vs %s\n",
+ pmu_name, test_event.matching_pmu, pmu_name);
+ return -1;
+ }
+
err = perf_pmu__find_event(pmu, event->name, &args,
test_core_pmu_event_aliases_cb);
if (err) {
--
1.8.3.1

2023-09-25 17:44:08

by Ian Rogers

[permalink] [raw]
Subject: Re: [PATCH v10 0/7] Add metrics for Arm CMN

On Sun, Sep 24, 2023 at 10:58 PM Jing Zhang <[email protected]> wrote:
>
> Changes since v8:
> - Add fully match identifier check as suggested by Ian.
> - Link: https://lore.kernel.org/lkml/[email protected]/
>
> Jing Zhang (7):
> perf pmu: "Compat" supports regular expression matching identifiers
> perf metric: "Compat" supports regular expression matching identifiers
> perf jevents: Support EventidCode and NodeType
> perf test: Make matching_pmu effective
> perf test: Add pmu-event test for "Compat" and new event_field.
> perf jevents: Add support for Arm CMN PMU aliasing
> perf vendor events: Add JSON metrics for Arm CMN

Thanks for the patience with all the to and fro. I was able to test
the series with "git am -3" to get around a merge issue on
perf-tools-next.

Reviewed-by: Ian Rogers <[email protected]>
Tested-by: Ian Rogers <[email protected]>

Thanks,
Ian

> .../pmu-events/arch/arm64/arm/cmn/sys/cmn.json | 266 +++++++++++++++++++++
> .../pmu-events/arch/arm64/arm/cmn/sys/metric.json | 74 ++++++
> .../pmu-events/arch/test/test_soc/sys/uncore.json | 8 +
> tools/perf/pmu-events/empty-pmu-events.c | 8 +
> tools/perf/pmu-events/jevents.py | 11 +-
> tools/perf/tests/pmu-events.c | 65 ++++-
> tools/perf/util/metricgroup.c | 2 +-
> tools/perf/util/pmu.c | 27 ++-
> tools/perf/util/pmu.h | 1 +
> 9 files changed, 456 insertions(+), 6 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
>

2023-09-26 03:20:10

by Jing Zhang

[permalink] [raw]
Subject: Re: [PATCH v10 0/7] Add metrics for Arm CMN



在 2023/9/26 上午12:37, Ian Rogers 写道:
> On Sun, Sep 24, 2023 at 10:58 PM Jing Zhang <[email protected]> wrote:
>>
>> Changes since v8:
>> - Add fully match identifier check as suggested by Ian.
>> - Link: https://lore.kernel.org/lkml/[email protected]/
>>
>> Jing Zhang (7):
>> perf pmu: "Compat" supports regular expression matching identifiers
>> perf metric: "Compat" supports regular expression matching identifiers
>> perf jevents: Support EventidCode and NodeType
>> perf test: Make matching_pmu effective
>> perf test: Add pmu-event test for "Compat" and new event_field.
>> perf jevents: Add support for Arm CMN PMU aliasing
>> perf vendor events: Add JSON metrics for Arm CMN
>
> Thanks for the patience with all the to and fro. I was able to test
> the series with "git am -3" to get around a merge issue on
> perf-tools-next.
>
> Reviewed-by: Ian Rogers <[email protected]>
> Tested-by: Ian Rogers <[email protected]>
>

Thank you for following this series and providing many valuable suggestions.

Thanks,
Jing

> Thanks,
> Ian
>
>> .../pmu-events/arch/arm64/arm/cmn/sys/cmn.json | 266 +++++++++++++++++++++
>> .../pmu-events/arch/arm64/arm/cmn/sys/metric.json | 74 ++++++
>> .../pmu-events/arch/test/test_soc/sys/uncore.json | 8 +
>> tools/perf/pmu-events/empty-pmu-events.c | 8 +
>> tools/perf/pmu-events/jevents.py | 11 +-
>> tools/perf/tests/pmu-events.c | 65 ++++-
>> tools/perf/util/metricgroup.c | 2 +-
>> tools/perf/util/pmu.c | 27 ++-
>> tools/perf/util/pmu.h | 1 +
>> 9 files changed, 456 insertions(+), 6 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
>>

2023-09-27 01:59:24

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH v10 0/7] Add metrics for Arm CMN

Hello,

On Mon, Sep 25, 2023 at 8:15 PM Jing Zhang <[email protected]> wrote:
>
>
>
> 在 2023/9/26 上午12:37, Ian Rogers 写道:
> > On Sun, Sep 24, 2023 at 10:58 PM Jing Zhang <[email protected]> wrote:
> >>
> >> Changes since v8:
> >> - Add fully match identifier check as suggested by Ian.
> >> - Link: https://lore.kernel.org/lkml/[email protected]/
> >>
> >> Jing Zhang (7):
> >> perf pmu: "Compat" supports regular expression matching identifiers
> >> perf metric: "Compat" supports regular expression matching identifiers
> >> perf jevents: Support EventidCode and NodeType
> >> perf test: Make matching_pmu effective
> >> perf test: Add pmu-event test for "Compat" and new event_field.
> >> perf jevents: Add support for Arm CMN PMU aliasing
> >> perf vendor events: Add JSON metrics for Arm CMN
> >
> > Thanks for the patience with all the to and fro. I was able to test
> > the series with "git am -3" to get around a merge issue on
> > perf-tools-next.
> >
> > Reviewed-by: Ian Rogers <[email protected]>
> > Tested-by: Ian Rogers <[email protected]>
> >
>
> Thank you for following this series and providing many valuable suggestions.

It's not applied cleanly. Can you please rebase onto the current
tmp.perf-tools-next branch in the following tree?

git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git

Thanks,
Namhyung

2023-09-27 06:18:35

by Jing Zhang

[permalink] [raw]
Subject: Re: [PATCH v10 0/7] Add metrics for Arm CMN



在 2023/9/27 上午9:00, Namhyung Kim 写道:
> Hello,
>
> On Mon, Sep 25, 2023 at 8:15 PM Jing Zhang <[email protected]> wrote:
>>
>>
>>
>> 在 2023/9/26 上午12:37, Ian Rogers 写道:
>>> On Sun, Sep 24, 2023 at 10:58 PM Jing Zhang <[email protected]> wrote:
>>>>
>>>> Changes since v8:
>>>> - Add fully match identifier check as suggested by Ian.
>>>> - Link: https://lore.kernel.org/lkml/[email protected]/
>>>>
>>>> Jing Zhang (7):
>>>> perf pmu: "Compat" supports regular expression matching identifiers
>>>> perf metric: "Compat" supports regular expression matching identifiers
>>>> perf jevents: Support EventidCode and NodeType
>>>> perf test: Make matching_pmu effective
>>>> perf test: Add pmu-event test for "Compat" and new event_field.
>>>> perf jevents: Add support for Arm CMN PMU aliasing
>>>> perf vendor events: Add JSON metrics for Arm CMN
>>>
>>> Thanks for the patience with all the to and fro. I was able to test
>>> the series with "git am -3" to get around a merge issue on
>>> perf-tools-next.
>>>
>>> Reviewed-by: Ian Rogers <[email protected]>
>>> Tested-by: Ian Rogers <[email protected]>
>>>
>>
>> Thank you for following this series and providing many valuable suggestions.
>
> It's not applied cleanly. Can you please rebase onto the current
> tmp.perf-tools-next branch in the following tree?
>
> git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git
>

Hi Namhyung,

I have sent v11[1] which rebase onto latest tmp.perf-tools-next branch. Please help to apply it, thanks.

[1] https://lore.kernel.org/all/[email protected]/


Thanks,
Jing

> Thanks,
> Namhyung

2023-09-28 04:03:43

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH v10 0/7] Add metrics for Arm CMN

On Tue, Sep 26, 2023 at 11:06 PM Jing Zhang <[email protected]> wrote:
>
>
>
> 在 2023/9/27 上午9:00, Namhyung Kim 写道:
> > Hello,
> >
> > On Mon, Sep 25, 2023 at 8:15 PM Jing Zhang <[email protected]> wrote:
> >>
> >>
> >>
> >> 在 2023/9/26 上午12:37, Ian Rogers 写道:
> >>> On Sun, Sep 24, 2023 at 10:58 PM Jing Zhang <[email protected]> wrote:
> >>>>
> >>>> Changes since v8:
> >>>> - Add fully match identifier check as suggested by Ian.
> >>>> - Link: https://lore.kernel.org/lkml/[email protected]/
> >>>>
> >>>> Jing Zhang (7):
> >>>> perf pmu: "Compat" supports regular expression matching identifiers
> >>>> perf metric: "Compat" supports regular expression matching identifiers
> >>>> perf jevents: Support EventidCode and NodeType
> >>>> perf test: Make matching_pmu effective
> >>>> perf test: Add pmu-event test for "Compat" and new event_field.
> >>>> perf jevents: Add support for Arm CMN PMU aliasing
> >>>> perf vendor events: Add JSON metrics for Arm CMN
> >>>
> >>> Thanks for the patience with all the to and fro. I was able to test
> >>> the series with "git am -3" to get around a merge issue on
> >>> perf-tools-next.
> >>>
> >>> Reviewed-by: Ian Rogers <[email protected]>
> >>> Tested-by: Ian Rogers <[email protected]>
> >>>
> >>
> >> Thank you for following this series and providing many valuable suggestions.
> >
> > It's not applied cleanly. Can you please rebase onto the current
> > tmp.perf-tools-next branch in the following tree?
> >
> > git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git
> >
>
> Hi Namhyung,
>
> I have sent v11[1] which rebase onto latest tmp.perf-tools-next branch. Please help to apply it, thanks.
>
> [1] https://lore.kernel.org/all/[email protected]/

Yep, it looks good... testing now.

Thanks,
Namhyung