Skip to contentSkip to conversation

Add metrics for Arm CMN

PATCH Superseded Jing Zhang 2 participants 12 messages Sep 18, 2023 – Sep 25, 2023

Subsystems (4)

v9 of 11 Superseded Latest is v11 →

lore
Share & tools
lore

Jing Zhang

author
#0 lore raw

v9 cover Add metrics for Arm CMN

Changes since v8:
- Compat uses regular expression matching identifier as suggested by Ian.
- Remove [PATCH v8 3/8] and workaround CMN event description issues
through jevent.py as suggested by Ian.
- Link: https://lore.kernel.org/all/[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                              |  23 +-
 tools/perf/util/pmu.h                              |   1 +
 9 files changed, 452 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
Signature · 7 lines
1.8.3.1


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

PATCH v9 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.

---
 tools/perf/util/pmu.c | 23 +++++++++++++++++++++--
 tools/perf/util/pmu.h |  1 +
 2 files changed, 22 insertions(+), 2 deletions(-)
tools/perf/util/pmu.c +21 -2
index e215985..7e2242f 100644
@@ -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,24 @@ 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);
+	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 +934,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,
tools/perf/util/pmu.h +1 -0
index bd5d804..fc155ce 100644
@@ -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);
 
Signature · 7 lines
1.8.3.1


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

Re: [PATCH v9 1/7] perf pmu: "Compat" supports regular expression matching identifiers

Quoted 39 lines · Jing Zhang

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.

---
 tools/perf/util/pmu.c | 23 +++++++++++++++++++++--
 tools/perf/util/pmu.h |  1 +
 2 files changed, 22 insertions(+), 2 deletions(-)
tools/perf/util/pmu.c +4 -0
index e215985..7e2242f 100644
@@ -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,24 @@ 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;

tools/perf/util/pmu.c static bool pmu_uncore_alias_match(const char *pmu_name, const char *name) · line 891

Quoted 10 lines
tools/perf/util/pmu.c +10 -0
+       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);

I wonder if we can make the regular expressions like "^(434|436|43c|43a)" more like "(434|436|43c|43a).*", so that we fully match the id string, by here doing:

if (match) {
/* Ensure a full match. */
match = pmatch[0].rm_so == 0 && pmatch[0].rm_eo == strlen(id);
}

I think longer term we can use jevents.py to generate a pmu-events.l, which would have a contents something like:

(434|436|43c|43a).* { return PMU_....;}

That should make the matching faster but may add some restrictions onto the regular expression.

Thanks,
Ian

Quoted 34 lines
tools/perf/util/pmu.c +7 -2
+       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 +934,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,
tools/perf/util/pmu.h +1 -1
index bd5d804..fc155ce 100644
@@ -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

author
#3 lore raw

Re: [PATCH v9 1/7] perf pmu: "Compat" supports regular expression matching identifiers

Quoted 55 lines · Ian Rogers
Quoted 39 lines · Jing Zhang

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.

---
 tools/perf/util/pmu.c | 23 +++++++++++++++++++++--
 tools/perf/util/pmu.h |  1 +
 2 files changed, 22 insertions(+), 2 deletions(-)
tools/perf/util/pmu.c +4 -0
index e215985..7e2242f 100644
@@ -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,24 @@ 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;

tools/perf/util/pmu.c static bool pmu_uncore_alias_match(const char *pmu_name, const char *name) · line 891

Quoted 10 lines
tools/perf/util/pmu.c +10 -0
+       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);

I wonder if we can make the regular expressions like "^(434|436|43c|43a)" more like "(434|436|43c|43a).*", so that we fully match the id string, by here doing:

Quoted 5 lines

if (match) {
/* Ensure a full match. */
match = pmatch[0].rm_so == 0 && pmatch[0].rm_eo == strlen(id);
}

Ok, will do.

Quoted 7 lines

I think longer term we can use jevents.py to generate a pmu-events.l, which would have a contents something like:

(434|436|43c|43a).* { return PMU_....;}

That should make the matching faster but may add some restrictions onto the regular expression.

Could you please describe the function of pmu-event.l in more detail? I may not fully understand it.

Thanks,
Jing

Quoted 38 lines

Thanks,
Ian

Quoted 34 lines
tools/perf/util/pmu.c +7 -2
+       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 +934,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,
tools/perf/util/pmu.h +1 -1
index bd5d804..fc155ce 100644
@@ -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

reviewer
#4 lore raw

Re: [PATCH v9 1/7] perf pmu: "Compat" supports regular expression matching identifiers

Quoted 71 lines · Jing Zhang
Quoted 55 lines · Ian Rogers
Quoted 39 lines · Jing Zhang

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.

---
 tools/perf/util/pmu.c | 23 +++++++++++++++++++++--
 tools/perf/util/pmu.h |  1 +
 2 files changed, 22 insertions(+), 2 deletions(-)
tools/perf/util/pmu.c +4 -0
index e215985..7e2242f 100644
@@ -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,24 @@ 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;

tools/perf/util/pmu.c static bool pmu_uncore_alias_match(const char *pmu_name, const char *name) · line 891

Quoted 10 lines
tools/perf/util/pmu.c +10 -0
+       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);

I wonder if we can make the regular expressions like "^(434|436|43c|43a)" more like "(434|436|43c|43a).*", so that we fully match the id string, by here doing:

Quoted 5 lines

if (match) {
/* Ensure a full match. */
match = pmatch[0].rm_so == 0 && pmatch[0].rm_eo == strlen(id);
}

Ok, will do.

Quoted 3 lines

I think longer term we can use jevents.py to generate a pmu-events.l, which would have a contents something like:

Quoted 6 lines
Quoted 4 lines

(434|436|43c|43a).* { return PMU_....;}

That should make the matching faster but may add some restrictions onto the regular expression.

Could you please describe the function of pmu-event.l in more detail? I may not fully understand it.

So for now there's no need for a pmu-event.l, I'm fine with the code as-is. The issue for using regular expressions is that we need to compile (regcomp) then use them (regexec), and in this new code the result of the parsing is discarded - perhaps we can save on some compiling with a 1 element cache, let's wait to see performance data saying it is an issue. If we were to compile the regular expressions at build time with flex then the runtime cost, any caching, etc. is unnecessary.

Hope this makes sense. Thanks,
Ian

Quoted 41 lines

Thanks,
Jing

Quoted 38 lines

Thanks,
Ian

Quoted 34 lines
tools/perf/util/pmu.c +7 -2
+       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 +934,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,
tools/perf/util/pmu.h +1 -1
index bd5d804..fc155ce 100644
@@ -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

author
#5 lore raw

Re: [PATCH v9 1/7] perf pmu: "Compat" supports regular expression matching identifiers

Quoted 79 lines · Ian Rogers
Quoted 71 lines · Jing Zhang
Quoted 55 lines · Ian Rogers
Quoted 39 lines · Jing Zhang

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.

---
 tools/perf/util/pmu.c | 23 +++++++++++++++++++++--
 tools/perf/util/pmu.h |  1 +
 2 files changed, 22 insertions(+), 2 deletions(-)
tools/perf/util/pmu.c +4 -0
index e215985..7e2242f 100644
@@ -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,24 @@ 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;

tools/perf/util/pmu.c static bool pmu_uncore_alias_match(const char *pmu_name, const char *name) · line 891

Quoted 10 lines
tools/perf/util/pmu.c +10 -0
+       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);

I wonder if we can make the regular expressions like "^(434|436|43c|43a)" more like "(434|436|43c|43a).*", so that we fully match the id string, by here doing:

Quoted 5 lines

if (match) {
/* Ensure a full match. */
match = pmatch[0].rm_so == 0 && pmatch[0].rm_eo == strlen(id);
}

Ok, will do.

Quoted 3 lines

I think longer term we can use jevents.py to generate a pmu-events.l, which would have a contents something like:

Quoted 6 lines
Quoted 4 lines

(434|436|43c|43a).* { return PMU_....;}

That should make the matching faster but may add some restrictions onto the regular expression.

Could you please describe the function of pmu-event.l in more detail? I may not fully understand it.

Quoted 9 lines

So for now there's no need for a pmu-event.l, I'm fine with the code as-is. The issue for using regular expressions is that we need to compile (regcomp) then use them (regexec), and in this new code the result of the parsing is discarded - perhaps we can save on some compiling with a 1 element cache, let's wait to see performance data saying it is an issue. If we were to compile the regular expressions at build time with flex then the runtime cost, any caching, etc. is unnecessary.

I see, thanks for the explanation.

Thanks,
Jing

Quoted 44 lines

Hope this makes sense. Thanks,
Ian

Quoted 41 lines

Thanks,
Jing

Quoted 38 lines

Thanks,
Ian

Quoted 34 lines
tools/perf/util/pmu.c +7 -2
+       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 +934,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,
tools/perf/util/pmu.h +1 -1
index bd5d804..fc155ce 100644
@@ -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

author
#6 lore raw

PATCH v9 2/7 perf metric: "Compat" supports regular expression matching identifiers

In reply to Jing Zhang

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.

---
 tools/perf/util/metricgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/metricgroup.c +1 -1
index 6231044..0484736 100644
@@ -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);
Signature · 7 lines
1.8.3.1


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

PATCH v9 3/7 perf jevents: Support EventidCode and NodeType

In reply to Jing Zhang

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.

---
 tools/perf/pmu-events/jevents.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
tools/perf/pmu-events/jevents.py +9 -1
index a7e8833..057d51aa 100755
@@ -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':
Signature · 7 lines
1.8.3.1


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

PATCH v9 4/7 perf test: Make matching_pmu effective

In reply to Jing Zhang

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.

---
 tools/perf/tests/pmu-events.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tools/perf/tests/pmu-events.c +8 -2
index f5321fb..0cf572f 100644
@@ -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) {
Signature · 7 lines
1.8.3.1


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

PATCH v9 5/7 perf test: Add pmu-event test for "Compat" and new event_field.

In reply to Jing Zhang

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

---
 .../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(+)
tools/perf/pmu-events/arch/test/test_soc/sys/uncore.json +8 -0
index c7e7528..701df3b 100644
@@ -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)"
    }
 ]
tools/perf/pmu-events/empty-pmu-events.c +8 -0
index 12bd043..b380836 100644
@@ -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,
tools/perf/tests/pmu-events.c +55 -0

70 lines not on this page · raw message

Signature · 7 lines
1.8.3.1


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

PATCH v9 6/7 perf jevents: Add support for Arm CMN PMU aliasing

In reply to Jing Zhang

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

---
 .../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
tools/perf/pmu-events/arch/arm64/arm/cmn/sys/cmn.json new file +266 -0
new file mode 100644
index 0000000..dd5d4ec
@@ -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)"
+	}
+]
tools/perf/pmu-events/jevents.py +1 -0
index 057d51aa..b1ab412 100755
@@ -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()}'
 
Signature · 7 lines
1.8.3.1


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

PATCH v9 7/7 perf vendor events: Add JSON metrics for Arm CMN

In reply to Jing Zhang

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.

---
 .../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
tools/perf/pmu-events/arch/arm64/arm/cmn/sys/metric.json new file +74 -0
new file mode 100644
index 0000000..0e30026
@@ -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)"
+	}
+]
Signature · 1 line
1.8.3.1