All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] perf arm64 metricgroup support
@ 2021-03-03 15:22 ` John Garry
  0 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-03 15:22 UTC (permalink / raw)
  To: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: irogers, linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain, John Garry

This series contains support to get basic metricgroups working for
arm64 CPUs.

Initial support is added for HiSilicon hip08 platform.

Some sample usage on Huawei D06 board:

 $ ./perf list metric    

List of pre-defined events (to be used in -e): 

Metrics:     

  bp_misp_flush
       [BP misp flush L3 topdown metric]
  branch_mispredicts
       [Branch mispredicts L2 topdown metric]
  core_bound
       [Core bound L2 topdown metric]
  divider
       [Divider L3 topdown metric]
  exe_ports_util
       [EXE ports util L3 topdown metric]
  fetch_bandwidth_bound
       [Fetch bandwidth bound L2 topdown metric]
  fetch_latency_bound
       [Fetch latency bound L2 topdown metric]
  fsu_stall
       [FSU stall L3 topdown metric]
  idle_by_icache_miss

$ sudo ./perf stat -v -M core_bound sleep 1
Using CPUID 0x00000000480fd010
metric expr (exe_stall_cycle - (mem_stall_anyload + armv8_pmuv3_0@event\=0x7005@)) / cpu_cycles for core_bound
found event cpu_cycles
found event armv8_pmuv3_0/event=0x7005/
found event exe_stall_cycle
found event mem_stall_anyload
adding {cpu_cycles -> armv8_pmuv3_0/event=0x7001/
mem_stall_anyload -> armv8_pmuv3_0/event=0x7004/
Control descriptor is not initialized
cpu_cycles: 989433 385050 385050
armv8_pmuv3_0/event=0x7005/: 19207 385050 385050
exe_stall_cycle: 900825 385050 385050
mem_stall_anyload: 253516 385050 385050

Performance counter stats for 'sleep':

989,433      cpu_cycles      #     0.63 core_bound
  19,207      armv8_pmuv3_0/event=0x7005/
 900,825      exe_stall_cycle
 253,516      mem_stall_anyload

       0.000805809 seconds time elapsed

       0.000875000 seconds user
       0.000000000 seconds sys
       
perf stat --topdown is not supported, as this requires the CPU PMU to
expose (alias) events for the TopDown L1 metrics from sysfs, which arm 
does not do. To get that to work, we probably need to make perf use the
pmu-events cpumap to learn about those alias events.

John Garry (5):
  perf metricgroup: Support printing metrics for arm64
  perf metricgroup: Support adding metrics for arm64
  perf vendor events arm64: Add Hisi hip08 L1 metrics
  perf vendor events arm64: Add Hisi hip08 L2 metrics
  perf vendor events arm64: Add Hisi hip08 L3 metrics

 .../arch/arm64/hisilicon/hip08/metrics.json   | 233 ++++++++++++++++++
 tools/perf/util/metricgroup.c                 |  27 +-
 2 files changed, 257 insertions(+), 3 deletions(-)
 create mode 100644 tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json

-- 
2.26.2


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

* [PATCH 0/5] perf arm64 metricgroup support
@ 2021-03-03 15:22 ` John Garry
  0 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-03 15:22 UTC (permalink / raw)
  To: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: irogers, linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain, John Garry

This series contains support to get basic metricgroups working for
arm64 CPUs.

Initial support is added for HiSilicon hip08 platform.

Some sample usage on Huawei D06 board:

 $ ./perf list metric    

List of pre-defined events (to be used in -e): 

Metrics:     

  bp_misp_flush
       [BP misp flush L3 topdown metric]
  branch_mispredicts
       [Branch mispredicts L2 topdown metric]
  core_bound
       [Core bound L2 topdown metric]
  divider
       [Divider L3 topdown metric]
  exe_ports_util
       [EXE ports util L3 topdown metric]
  fetch_bandwidth_bound
       [Fetch bandwidth bound L2 topdown metric]
  fetch_latency_bound
       [Fetch latency bound L2 topdown metric]
  fsu_stall
       [FSU stall L3 topdown metric]
  idle_by_icache_miss

$ sudo ./perf stat -v -M core_bound sleep 1
Using CPUID 0x00000000480fd010
metric expr (exe_stall_cycle - (mem_stall_anyload + armv8_pmuv3_0@event\=0x7005@)) / cpu_cycles for core_bound
found event cpu_cycles
found event armv8_pmuv3_0/event=0x7005/
found event exe_stall_cycle
found event mem_stall_anyload
adding {cpu_cycles -> armv8_pmuv3_0/event=0x7001/
mem_stall_anyload -> armv8_pmuv3_0/event=0x7004/
Control descriptor is not initialized
cpu_cycles: 989433 385050 385050
armv8_pmuv3_0/event=0x7005/: 19207 385050 385050
exe_stall_cycle: 900825 385050 385050
mem_stall_anyload: 253516 385050 385050

Performance counter stats for 'sleep':

989,433      cpu_cycles      #     0.63 core_bound
  19,207      armv8_pmuv3_0/event=0x7005/
 900,825      exe_stall_cycle
 253,516      mem_stall_anyload

       0.000805809 seconds time elapsed

       0.000875000 seconds user
       0.000000000 seconds sys
       
perf stat --topdown is not supported, as this requires the CPU PMU to
expose (alias) events for the TopDown L1 metrics from sysfs, which arm 
does not do. To get that to work, we probably need to make perf use the
pmu-events cpumap to learn about those alias events.

John Garry (5):
  perf metricgroup: Support printing metrics for arm64
  perf metricgroup: Support adding metrics for arm64
  perf vendor events arm64: Add Hisi hip08 L1 metrics
  perf vendor events arm64: Add Hisi hip08 L2 metrics
  perf vendor events arm64: Add Hisi hip08 L3 metrics

 .../arch/arm64/hisilicon/hip08/metrics.json   | 233 ++++++++++++++++++
 tools/perf/util/metricgroup.c                 |  27 +-
 2 files changed, 257 insertions(+), 3 deletions(-)
 create mode 100644 tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json

-- 
2.26.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 1/5] perf metricgroup: Support printing metrics for arm64
  2021-03-03 15:22 ` John Garry
@ 2021-03-03 15:22   ` John Garry
  -1 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-03 15:22 UTC (permalink / raw)
  To: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: irogers, linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain, John Garry

Calling perf_pmu__find_map(NULL) returns the cpumap for the common CPU
PMU. However arm64 supports heterogeneous-CPU based systems, and so there
may be no common CPU PMU. As such, perf_pmu__find_map(NULL) returns NULL
for arm64.

To support printing metrics for arm64, iterate through all PMUs, looking
for a CPU PMU, and use the cpumap there for determining supported metrics.

For heterogeneous systems (like arm big.LITTLE), supporting metrics has
potential challenges, like not all CPUs in a system not supporting a
specific metric event. So just don't support it for now.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 tools/perf/util/metricgroup.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 26c990e32378..9a2a23093961 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -6,6 +6,7 @@
 /* Manage metrics and groups of metrics from JSON files */
 
 #include "metricgroup.h"
+#include "cpumap.h"
 #include "debug.h"
 #include "evlist.h"
 #include "evsel.h"
@@ -615,10 +616,31 @@ static int metricgroup__print_sys_event_iter(struct pmu_event *pe, void *data)
 				     d->details, d->groups, d->metriclist);
 }
 
+static struct pmu_events_map *find_cpumap(void)
+{
+	struct perf_pmu *pmu = NULL;
+
+	while ((pmu = perf_pmu__scan(pmu))) {
+		if (!is_pmu_core(pmu->name))
+			continue;
+
+		/*
+		 * The cpumap should cover all CPUs. Otherwise, some CPUs may
+		 * not support some events or have different event IDs.
+		 */
+		if (pmu->cpus && pmu->cpus->nr != cpu__max_cpu())
+			return NULL;
+
+		return perf_pmu__find_map(pmu);
+	}
+
+	return NULL;
+}
+
 void metricgroup__print(bool metrics, bool metricgroups, char *filter,
 			bool raw, bool details)
 {
-	struct pmu_events_map *map = perf_pmu__find_map(NULL);
+	struct pmu_events_map *map = find_cpumap();
 	struct pmu_event *pe;
 	int i;
 	struct rblist groups;
-- 
2.26.2


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

* [PATCH 1/5] perf metricgroup: Support printing metrics for arm64
@ 2021-03-03 15:22   ` John Garry
  0 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-03 15:22 UTC (permalink / raw)
  To: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: irogers, linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain, John Garry

Calling perf_pmu__find_map(NULL) returns the cpumap for the common CPU
PMU. However arm64 supports heterogeneous-CPU based systems, and so there
may be no common CPU PMU. As such, perf_pmu__find_map(NULL) returns NULL
for arm64.

To support printing metrics for arm64, iterate through all PMUs, looking
for a CPU PMU, and use the cpumap there for determining supported metrics.

For heterogeneous systems (like arm big.LITTLE), supporting metrics has
potential challenges, like not all CPUs in a system not supporting a
specific metric event. So just don't support it for now.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 tools/perf/util/metricgroup.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 26c990e32378..9a2a23093961 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -6,6 +6,7 @@
 /* Manage metrics and groups of metrics from JSON files */
 
 #include "metricgroup.h"
+#include "cpumap.h"
 #include "debug.h"
 #include "evlist.h"
 #include "evsel.h"
@@ -615,10 +616,31 @@ static int metricgroup__print_sys_event_iter(struct pmu_event *pe, void *data)
 				     d->details, d->groups, d->metriclist);
 }
 
+static struct pmu_events_map *find_cpumap(void)
+{
+	struct perf_pmu *pmu = NULL;
+
+	while ((pmu = perf_pmu__scan(pmu))) {
+		if (!is_pmu_core(pmu->name))
+			continue;
+
+		/*
+		 * The cpumap should cover all CPUs. Otherwise, some CPUs may
+		 * not support some events or have different event IDs.
+		 */
+		if (pmu->cpus && pmu->cpus->nr != cpu__max_cpu())
+			return NULL;
+
+		return perf_pmu__find_map(pmu);
+	}
+
+	return NULL;
+}
+
 void metricgroup__print(bool metrics, bool metricgroups, char *filter,
 			bool raw, bool details)
 {
-	struct pmu_events_map *map = perf_pmu__find_map(NULL);
+	struct pmu_events_map *map = find_cpumap();
 	struct pmu_event *pe;
 	int i;
 	struct rblist groups;
-- 
2.26.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/5] perf metricgroup: Support adding metrics for arm64
  2021-03-03 15:22 ` John Garry
@ 2021-03-03 15:22   ` John Garry
  -1 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-03 15:22 UTC (permalink / raw)
  To: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: irogers, linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain, John Garry

Use find_cpumap() to get the cpumap for the common CPU PMU, if one exists.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 tools/perf/util/metricgroup.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 9a2a23093961..c7c9ee9c04be 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -1275,8 +1275,7 @@ int metricgroup__parse_groups(const struct option *opt,
 			      struct rblist *metric_events)
 {
 	struct evlist *perf_evlist = *(struct evlist **)opt->value;
-	struct pmu_events_map *map = perf_pmu__find_map(NULL);
-
+	struct pmu_events_map *map = find_cpumap();
 
 	return parse_groups(perf_evlist, str, metric_no_group,
 			    metric_no_merge, NULL, metric_events, map);
-- 
2.26.2


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

* [PATCH 2/5] perf metricgroup: Support adding metrics for arm64
@ 2021-03-03 15:22   ` John Garry
  0 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-03 15:22 UTC (permalink / raw)
  To: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: irogers, linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain, John Garry

Use find_cpumap() to get the cpumap for the common CPU PMU, if one exists.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 tools/perf/util/metricgroup.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 9a2a23093961..c7c9ee9c04be 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -1275,8 +1275,7 @@ int metricgroup__parse_groups(const struct option *opt,
 			      struct rblist *metric_events)
 {
 	struct evlist *perf_evlist = *(struct evlist **)opt->value;
-	struct pmu_events_map *map = perf_pmu__find_map(NULL);
-
+	struct pmu_events_map *map = find_cpumap();
 
 	return parse_groups(perf_evlist, str, metric_no_group,
 			    metric_no_merge, NULL, metric_events, map);
-- 
2.26.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 3/5] perf vendor events arm64: Add Hisi hip08 L1 metrics
  2021-03-03 15:22 ` John Garry
@ 2021-03-03 15:22   ` John Garry
  -1 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-03 15:22 UTC (permalink / raw)
  To: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: irogers, linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain, John Garry

Add L1 metrics. Formula is as consistent as possible with standard.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 .../arch/arm64/hisilicon/hip08/metrics.json   | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json

diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
new file mode 100644
index 000000000000..dc5ff3051639
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
@@ -0,0 +1,30 @@
+[
+    {
+        "MetricExpr": "FETCH_BUBBLE / (4 * CPU_CYCLES)",
+        "PublicDescription": "Frontend bound L1 topdown metric",
+        "BriefDescription": "Frontend bound L1 topdown metric",
+        "MetricGroup": "TopDownL1",
+        "MetricName": "frontend_bound"
+    },
+    {
+        "MetricExpr": "(INST_SPEC - INST_RETIRED) / (4 * CPU_CYCLES)",
+        "PublicDescription": "Bad Speculation L1 topdown metric",
+        "BriefDescription": "Bad Speculation L1 topdown metric",
+        "MetricGroup": "TopDownL1",
+        "MetricName": "bad_speculation"
+    },
+    {
+        "MetricExpr": "INST_RETIRED / (CPU_CYCLES * 4)",
+        "PublicDescription": "Retiring L1 topdown metric",
+        "BriefDescription": "Retiring L1 topdown metric",
+        "MetricGroup": "TopDownL1",
+        "MetricName": "retiring"
+    },
+    {
+        "MetricExpr": "1 - (frontend_bound + bad_speculation + retiring)",
+        "PublicDescription": "Backend Bound L1 topdown metric",
+        "BriefDescription": "Backend Bound L1 topdown metric",
+        "MetricGroup": "TopDownL1",
+        "MetricName": "backend_bound"
+    },
+]
-- 
2.26.2


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

* [PATCH 3/5] perf vendor events arm64: Add Hisi hip08 L1 metrics
@ 2021-03-03 15:22   ` John Garry
  0 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-03 15:22 UTC (permalink / raw)
  To: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: irogers, linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain, John Garry

Add L1 metrics. Formula is as consistent as possible with standard.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 .../arch/arm64/hisilicon/hip08/metrics.json   | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json

diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
new file mode 100644
index 000000000000..dc5ff3051639
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
@@ -0,0 +1,30 @@
+[
+    {
+        "MetricExpr": "FETCH_BUBBLE / (4 * CPU_CYCLES)",
+        "PublicDescription": "Frontend bound L1 topdown metric",
+        "BriefDescription": "Frontend bound L1 topdown metric",
+        "MetricGroup": "TopDownL1",
+        "MetricName": "frontend_bound"
+    },
+    {
+        "MetricExpr": "(INST_SPEC - INST_RETIRED) / (4 * CPU_CYCLES)",
+        "PublicDescription": "Bad Speculation L1 topdown metric",
+        "BriefDescription": "Bad Speculation L1 topdown metric",
+        "MetricGroup": "TopDownL1",
+        "MetricName": "bad_speculation"
+    },
+    {
+        "MetricExpr": "INST_RETIRED / (CPU_CYCLES * 4)",
+        "PublicDescription": "Retiring L1 topdown metric",
+        "BriefDescription": "Retiring L1 topdown metric",
+        "MetricGroup": "TopDownL1",
+        "MetricName": "retiring"
+    },
+    {
+        "MetricExpr": "1 - (frontend_bound + bad_speculation + retiring)",
+        "PublicDescription": "Backend Bound L1 topdown metric",
+        "BriefDescription": "Backend Bound L1 topdown metric",
+        "MetricGroup": "TopDownL1",
+        "MetricName": "backend_bound"
+    },
+]
-- 
2.26.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 4/5] perf vendor events arm64: Add Hisi hip08 L2 metrics
  2021-03-03 15:22 ` John Garry
@ 2021-03-03 15:22   ` John Garry
  -1 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-03 15:22 UTC (permalink / raw)
  To: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: irogers, linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain, John Garry

Add L2 metrics.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 .../arch/arm64/hisilicon/hip08/metrics.json   | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
index dc5ff3051639..dda898d23c2d 100644
--- a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
+++ b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
@@ -27,4 +27,46 @@
         "MetricGroup": "TopDownL1",
         "MetricName": "backend_bound"
     },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x201d@ / CPU_CYCLES",
+        "PublicDescription": "Fetch latency bound L2 topdown metric",
+        "BriefDescription": "Fetch latency bound L2 topdown metric",
+        "MetricGroup": "TopDownL2",
+        "MetricName": "fetch_latency_bound"
+    },
+    {
+        "MetricExpr": "frontend_bound - fetch_latency_bound",
+        "PublicDescription": "Fetch bandwidth bound L2 topdown metric",
+        "BriefDescription": "Fetch bandwidth bound L2 topdown metric",
+        "MetricGroup": "TopDownL2",
+        "MetricName": "fetch_bandwidth_bound"
+    },
+    {
+        "MetricExpr": "(bad_speculation * BR_MIS_PRED) / (BR_MIS_PRED + armv8_pmuv3_0@event\\=0x2013@)",
+        "PublicDescription": "Branch mispredicts L2 topdown metric",
+        "BriefDescription": "Branch mispredicts L2 topdown metric",
+        "MetricGroup": "TopDownL2",
+        "MetricName": "branch_mispredicts"
+    },
+    {
+        "MetricExpr": "bad_speculation - branch_mispredicts",
+        "PublicDescription": "Machine clears L2 topdown metric",
+        "BriefDescription": "Machine clears L2 topdown metric",
+        "MetricGroup": "TopDownL2",
+        "MetricName": "machine_clears"
+    },
+    {
+        "MetricExpr": "(EXE_STALL_CYCLE - (MEM_STALL_ANYLOAD + armv8_pmuv3_0@event\\=0x7005@)) / CPU_CYCLES",
+        "PublicDescription": "Core bound L2 topdown metric",
+        "BriefDescription": "Core bound L2 topdown metric",
+        "MetricGroup": "TopDownL2",
+        "MetricName": "core_bound"
+    },
+    {
+        "MetricExpr": "(MEM_STALL_ANYLOAD + armv8_pmuv3_0@event\\=0x7005@) / CPU_CYCLES",
+        "PublicDescription": "Memory bound L2 topdown metric",
+        "BriefDescription": "Memory bound L2 topdown metric",
+        "MetricGroup": "TopDownL2",
+        "MetricName": "memory_bound"
+    },
 ]
-- 
2.26.2


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

* [PATCH 4/5] perf vendor events arm64: Add Hisi hip08 L2 metrics
@ 2021-03-03 15:22   ` John Garry
  0 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-03 15:22 UTC (permalink / raw)
  To: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: irogers, linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain, John Garry

Add L2 metrics.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 .../arch/arm64/hisilicon/hip08/metrics.json   | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
index dc5ff3051639..dda898d23c2d 100644
--- a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
+++ b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
@@ -27,4 +27,46 @@
         "MetricGroup": "TopDownL1",
         "MetricName": "backend_bound"
     },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x201d@ / CPU_CYCLES",
+        "PublicDescription": "Fetch latency bound L2 topdown metric",
+        "BriefDescription": "Fetch latency bound L2 topdown metric",
+        "MetricGroup": "TopDownL2",
+        "MetricName": "fetch_latency_bound"
+    },
+    {
+        "MetricExpr": "frontend_bound - fetch_latency_bound",
+        "PublicDescription": "Fetch bandwidth bound L2 topdown metric",
+        "BriefDescription": "Fetch bandwidth bound L2 topdown metric",
+        "MetricGroup": "TopDownL2",
+        "MetricName": "fetch_bandwidth_bound"
+    },
+    {
+        "MetricExpr": "(bad_speculation * BR_MIS_PRED) / (BR_MIS_PRED + armv8_pmuv3_0@event\\=0x2013@)",
+        "PublicDescription": "Branch mispredicts L2 topdown metric",
+        "BriefDescription": "Branch mispredicts L2 topdown metric",
+        "MetricGroup": "TopDownL2",
+        "MetricName": "branch_mispredicts"
+    },
+    {
+        "MetricExpr": "bad_speculation - branch_mispredicts",
+        "PublicDescription": "Machine clears L2 topdown metric",
+        "BriefDescription": "Machine clears L2 topdown metric",
+        "MetricGroup": "TopDownL2",
+        "MetricName": "machine_clears"
+    },
+    {
+        "MetricExpr": "(EXE_STALL_CYCLE - (MEM_STALL_ANYLOAD + armv8_pmuv3_0@event\\=0x7005@)) / CPU_CYCLES",
+        "PublicDescription": "Core bound L2 topdown metric",
+        "BriefDescription": "Core bound L2 topdown metric",
+        "MetricGroup": "TopDownL2",
+        "MetricName": "core_bound"
+    },
+    {
+        "MetricExpr": "(MEM_STALL_ANYLOAD + armv8_pmuv3_0@event\\=0x7005@) / CPU_CYCLES",
+        "PublicDescription": "Memory bound L2 topdown metric",
+        "BriefDescription": "Memory bound L2 topdown metric",
+        "MetricGroup": "TopDownL2",
+        "MetricName": "memory_bound"
+    },
 ]
-- 
2.26.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 5/5] perf vendor events arm64: Add Hisi hip08 L3 metrics
  2021-03-03 15:22 ` John Garry
@ 2021-03-03 15:22   ` John Garry
  -1 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-03 15:22 UTC (permalink / raw)
  To: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: irogers, linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain, John Garry

Add L3 metrics.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 .../arch/arm64/hisilicon/hip08/metrics.json   | 161 ++++++++++++++++++
 1 file changed, 161 insertions(+)

diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
index dda898d23c2d..dda8e59149d2 100644
--- a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
+++ b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
@@ -69,4 +69,165 @@
         "MetricGroup": "TopDownL2",
         "MetricName": "memory_bound"
     },
+    {
+        "MetricExpr": "(((L2I_TLB - L2I_TLB_REFILL) * 15) + (L2I_TLB_REFILL * 100)) / CPU_CYCLES",
+        "PublicDescription": "Idle by itlb miss L3 topdown metric",
+        "BriefDescription": "Idle by itlb miss L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "idle_by_itlb_miss"
+    },
+    {
+        "MetricExpr": "(((L2I_CACHE - L2I_CACHE_REFILL) * 15) + (L2I_CACHE_REFILL * 100)) / CPU_CYCLES",
+        "PublicDescription": "Idle by icache miss L3 topdown metric",
+        "BriefDescription": "Idle by icache miss L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "idle_by_icache_miss"
+    },
+    {
+        "MetricExpr": "(BR_MIS_PRED * 5) / CPU_CYCLES",
+        "PublicDescription": "BP misp flush L3 topdown metric",
+        "BriefDescription": "BP misp flush L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "bp_misp_flush"
+    },
+    {
+        "MetricExpr": "(armv8_pmuv3_0@event\\=0x2013@ * 5) / CPU_CYCLES",
+        "PublicDescription": "OOO flush L3 topdown metric",
+        "BriefDescription": "OOO flush L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "ooo_flush"
+    },
+    {
+        "MetricExpr": "(armv8_pmuv3_0@event\\=0x1001@ * 5) / CPU_CYCLES",
+        "PublicDescription": "Static predictor flush L3 topdown metric",
+        "BriefDescription": "Static predictor flush L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "sp_flush"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x1010@ / BR_MIS_PRED",
+        "PublicDescription": "Indirect branch L3 topdown metric",
+        "BriefDescription": "Indirect branch L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "indirect_branch"
+    },
+    {
+        "MetricExpr": "(armv8_pmuv3_0@event\\=0x1014@ + armv8_pmuv3_0@event\\=0x1018@) / BR_MIS_PRED",
+        "PublicDescription": "Push branch L3 topdown metric",
+        "BriefDescription": "Push branch L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "push_branch"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x100c@ / BR_MIS_PRED",
+        "PublicDescription": "Pop branch L3 topdown metric",
+        "BriefDescription": "Pop branch L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "pop_branch"
+    },
+    {
+        "MetricExpr": "(BR_MIS_PRED - armv8_pmuv3_0@event\\=0x1010@ - armv8_pmuv3_0@event\\=0x1014@ - armv8_pmuv3_0@event\\=0x1018@ - armv8_pmuv3_0@event\\=0x100c@) / BR_MIS_PRED",
+        "PublicDescription": "Other branch L3 topdown metric",
+        "BriefDescription": "Other branch L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "other_branch"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x2012@ / armv8_pmuv3_0@event\\=0x2013@",
+        "PublicDescription": "Nuke flush L3 topdown metric",
+        "BriefDescription": "Nuke flush L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "nuke_flush"
+    },
+    {
+        "MetricExpr": "1 - nuke_flush",
+        "PublicDescription": "Other flush L3 topdown metric",
+        "BriefDescription": "Other flush L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "other_flush"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x2010@ / CPU_CYCLES",
+        "PublicDescription": "Sync stall L3 topdown metric",
+        "BriefDescription": "Sync stall L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "sync_stall"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x2004@ / CPU_CYCLES",
+        "PublicDescription": "Rob stall L3 topdown metric",
+        "BriefDescription": "Rob stall L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "rob_stall"
+    },
+    {
+        "MetricExpr": "(armv8_pmuv3_0@event\\=0x2006@ + armv8_pmuv3_0@event\\=0x2007@ + armv8_pmuv3_0@event\\=0x2008@) / CPU_CYCLES",
+        "PublicDescription": "Ptag stall L3 topdown metric",
+        "BriefDescription": "Ptag stall L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "ptag_stall"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x201e@ / CPU_CYCLES",
+        "PublicDescription": "SaveOpQ stall L3 topdown metric",
+        "BriefDescription": "SaveOpQ stall L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "saveopq_stall"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x2005@ / CPU_CYCLES",
+        "PublicDescription": "PC buffer stall L3 topdown metric",
+        "BriefDescription": "PC buffer stall L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "pc_buffer_stall"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x7002@ / CPU_CYCLES",
+        "PublicDescription": "Divider L3 topdown metric",
+        "BriefDescription": "Divider L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "divider"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x7003@ / CPU_CYCLES",
+        "PublicDescription": "FSU stall L3 topdown metric",
+        "BriefDescription": "FSU stall L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "fsu_stall"
+    },
+    {
+        "MetricExpr": "core_bound - divider - fsu_stall",
+        "PublicDescription": "EXE ports util L3 topdown metric",
+        "BriefDescription": "EXE ports util L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "exe_ports_util"
+    },
+    {
+        "MetricExpr": "(MEM_STALL_ANYLOAD - MEM_STALL_L1MISS) / CPU_CYCLES",
+        "PublicDescription": "L1 bound L3 topdown metric",
+        "BriefDescription": "L1 bound L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "l1_bound"
+    },
+    {
+        "MetricExpr": "(MEM_STALL_L1MISS - MEM_STALL_L2MISS) / CPU_CYCLES",
+        "PublicDescription": "L2 bound L3 topdown metric",
+        "BriefDescription": "L2 bound L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "l2_bound"
+    },
+    {
+        "MetricExpr": "MEM_STALL_L2MISS / CPU_CYCLES",
+        "PublicDescription": "Mem bound L3 topdown metric",
+        "BriefDescription": "Mem bound L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "mem_bound"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x7005@ / CPU_CYCLES",
+        "PublicDescription": "Store bound L3 topdown metric",
+        "BriefDescription": "Store bound L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "store_bound"
+    },
 ]
-- 
2.26.2


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

* [PATCH 5/5] perf vendor events arm64: Add Hisi hip08 L3 metrics
@ 2021-03-03 15:22   ` John Garry
  0 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-03 15:22 UTC (permalink / raw)
  To: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: irogers, linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain, John Garry

Add L3 metrics.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 .../arch/arm64/hisilicon/hip08/metrics.json   | 161 ++++++++++++++++++
 1 file changed, 161 insertions(+)

diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
index dda898d23c2d..dda8e59149d2 100644
--- a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
+++ b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json
@@ -69,4 +69,165 @@
         "MetricGroup": "TopDownL2",
         "MetricName": "memory_bound"
     },
+    {
+        "MetricExpr": "(((L2I_TLB - L2I_TLB_REFILL) * 15) + (L2I_TLB_REFILL * 100)) / CPU_CYCLES",
+        "PublicDescription": "Idle by itlb miss L3 topdown metric",
+        "BriefDescription": "Idle by itlb miss L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "idle_by_itlb_miss"
+    },
+    {
+        "MetricExpr": "(((L2I_CACHE - L2I_CACHE_REFILL) * 15) + (L2I_CACHE_REFILL * 100)) / CPU_CYCLES",
+        "PublicDescription": "Idle by icache miss L3 topdown metric",
+        "BriefDescription": "Idle by icache miss L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "idle_by_icache_miss"
+    },
+    {
+        "MetricExpr": "(BR_MIS_PRED * 5) / CPU_CYCLES",
+        "PublicDescription": "BP misp flush L3 topdown metric",
+        "BriefDescription": "BP misp flush L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "bp_misp_flush"
+    },
+    {
+        "MetricExpr": "(armv8_pmuv3_0@event\\=0x2013@ * 5) / CPU_CYCLES",
+        "PublicDescription": "OOO flush L3 topdown metric",
+        "BriefDescription": "OOO flush L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "ooo_flush"
+    },
+    {
+        "MetricExpr": "(armv8_pmuv3_0@event\\=0x1001@ * 5) / CPU_CYCLES",
+        "PublicDescription": "Static predictor flush L3 topdown metric",
+        "BriefDescription": "Static predictor flush L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "sp_flush"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x1010@ / BR_MIS_PRED",
+        "PublicDescription": "Indirect branch L3 topdown metric",
+        "BriefDescription": "Indirect branch L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "indirect_branch"
+    },
+    {
+        "MetricExpr": "(armv8_pmuv3_0@event\\=0x1014@ + armv8_pmuv3_0@event\\=0x1018@) / BR_MIS_PRED",
+        "PublicDescription": "Push branch L3 topdown metric",
+        "BriefDescription": "Push branch L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "push_branch"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x100c@ / BR_MIS_PRED",
+        "PublicDescription": "Pop branch L3 topdown metric",
+        "BriefDescription": "Pop branch L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "pop_branch"
+    },
+    {
+        "MetricExpr": "(BR_MIS_PRED - armv8_pmuv3_0@event\\=0x1010@ - armv8_pmuv3_0@event\\=0x1014@ - armv8_pmuv3_0@event\\=0x1018@ - armv8_pmuv3_0@event\\=0x100c@) / BR_MIS_PRED",
+        "PublicDescription": "Other branch L3 topdown metric",
+        "BriefDescription": "Other branch L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "other_branch"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x2012@ / armv8_pmuv3_0@event\\=0x2013@",
+        "PublicDescription": "Nuke flush L3 topdown metric",
+        "BriefDescription": "Nuke flush L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "nuke_flush"
+    },
+    {
+        "MetricExpr": "1 - nuke_flush",
+        "PublicDescription": "Other flush L3 topdown metric",
+        "BriefDescription": "Other flush L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "other_flush"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x2010@ / CPU_CYCLES",
+        "PublicDescription": "Sync stall L3 topdown metric",
+        "BriefDescription": "Sync stall L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "sync_stall"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x2004@ / CPU_CYCLES",
+        "PublicDescription": "Rob stall L3 topdown metric",
+        "BriefDescription": "Rob stall L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "rob_stall"
+    },
+    {
+        "MetricExpr": "(armv8_pmuv3_0@event\\=0x2006@ + armv8_pmuv3_0@event\\=0x2007@ + armv8_pmuv3_0@event\\=0x2008@) / CPU_CYCLES",
+        "PublicDescription": "Ptag stall L3 topdown metric",
+        "BriefDescription": "Ptag stall L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "ptag_stall"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x201e@ / CPU_CYCLES",
+        "PublicDescription": "SaveOpQ stall L3 topdown metric",
+        "BriefDescription": "SaveOpQ stall L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "saveopq_stall"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x2005@ / CPU_CYCLES",
+        "PublicDescription": "PC buffer stall L3 topdown metric",
+        "BriefDescription": "PC buffer stall L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "pc_buffer_stall"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x7002@ / CPU_CYCLES",
+        "PublicDescription": "Divider L3 topdown metric",
+        "BriefDescription": "Divider L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "divider"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x7003@ / CPU_CYCLES",
+        "PublicDescription": "FSU stall L3 topdown metric",
+        "BriefDescription": "FSU stall L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "fsu_stall"
+    },
+    {
+        "MetricExpr": "core_bound - divider - fsu_stall",
+        "PublicDescription": "EXE ports util L3 topdown metric",
+        "BriefDescription": "EXE ports util L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "exe_ports_util"
+    },
+    {
+        "MetricExpr": "(MEM_STALL_ANYLOAD - MEM_STALL_L1MISS) / CPU_CYCLES",
+        "PublicDescription": "L1 bound L3 topdown metric",
+        "BriefDescription": "L1 bound L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "l1_bound"
+    },
+    {
+        "MetricExpr": "(MEM_STALL_L1MISS - MEM_STALL_L2MISS) / CPU_CYCLES",
+        "PublicDescription": "L2 bound L3 topdown metric",
+        "BriefDescription": "L2 bound L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "l2_bound"
+    },
+    {
+        "MetricExpr": "MEM_STALL_L2MISS / CPU_CYCLES",
+        "PublicDescription": "Mem bound L3 topdown metric",
+        "BriefDescription": "Mem bound L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "mem_bound"
+    },
+    {
+        "MetricExpr": "armv8_pmuv3_0@event\\=0x7005@ / CPU_CYCLES",
+        "PublicDescription": "Store bound L3 topdown metric",
+        "BriefDescription": "Store bound L3 topdown metric",
+        "MetricGroup": "TopDownL3",
+        "MetricName": "store_bound"
+    },
 ]
-- 
2.26.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/5] perf metricgroup: Support printing metrics for arm64
  2021-03-03 15:22   ` John Garry
@ 2021-03-04 20:05     ` Jiri Olsa
  -1 siblings, 0 replies; 22+ messages in thread
From: Jiri Olsa @ 2021-03-04 20:05 UTC (permalink / raw)
  To: John Garry
  Cc: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, namhyung, irogers,
	linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain

On Wed, Mar 03, 2021 at 11:22:14PM +0800, John Garry wrote:
> Calling perf_pmu__find_map(NULL) returns the cpumap for the common CPU
> PMU. However arm64 supports heterogeneous-CPU based systems, and so there
> may be no common CPU PMU. As such, perf_pmu__find_map(NULL) returns NULL
> for arm64.
> 
> To support printing metrics for arm64, iterate through all PMUs, looking
> for a CPU PMU, and use the cpumap there for determining supported metrics.
> 
> For heterogeneous systems (like arm big.LITTLE), supporting metrics has
> potential challenges, like not all CPUs in a system not supporting a
> specific metric event. So just don't support it for now.
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
>  tools/perf/util/metricgroup.c | 24 +++++++++++++++++++++++-
>  1 file changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index 26c990e32378..9a2a23093961 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -6,6 +6,7 @@
>  /* Manage metrics and groups of metrics from JSON files */
>  
>  #include "metricgroup.h"
> +#include "cpumap.h"
>  #include "debug.h"
>  #include "evlist.h"
>  #include "evsel.h"
> @@ -615,10 +616,31 @@ static int metricgroup__print_sys_event_iter(struct pmu_event *pe, void *data)
>  				     d->details, d->groups, d->metriclist);
>  }
>  
> +static struct pmu_events_map *find_cpumap(void)
> +{
> +	struct perf_pmu *pmu = NULL;
> +
> +	while ((pmu = perf_pmu__scan(pmu))) {
> +		if (!is_pmu_core(pmu->name))
> +			continue;
> +
> +		/*
> +		 * The cpumap should cover all CPUs. Otherwise, some CPUs may
> +		 * not support some events or have different event IDs.
> +		 */
> +		if (pmu->cpus && pmu->cpus->nr != cpu__max_cpu())
> +			return NULL;
> +
> +		return perf_pmu__find_map(pmu);
> +	}
> +
> +	return NULL;
> +}
> +
>  void metricgroup__print(bool metrics, bool metricgroups, char *filter,
>  			bool raw, bool details)
>  {
> -	struct pmu_events_map *map = perf_pmu__find_map(NULL);
> +	struct pmu_events_map *map = find_cpumap();

so this is just for arm at the moment right?

could we rather make this arch specific code, so we don't need
to do the scanning on archs where this is not needed?

like marking perf_pmu__find_map as __weak and add arm specific
version?

thanks,
jirka

>  	struct pmu_event *pe;
>  	int i;
>  	struct rblist groups;
> -- 
> 2.26.2
> 


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

* Re: [PATCH 1/5] perf metricgroup: Support printing metrics for arm64
@ 2021-03-04 20:05     ` Jiri Olsa
  0 siblings, 0 replies; 22+ messages in thread
From: Jiri Olsa @ 2021-03-04 20:05 UTC (permalink / raw)
  To: John Garry
  Cc: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, namhyung, irogers,
	linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain

On Wed, Mar 03, 2021 at 11:22:14PM +0800, John Garry wrote:
> Calling perf_pmu__find_map(NULL) returns the cpumap for the common CPU
> PMU. However arm64 supports heterogeneous-CPU based systems, and so there
> may be no common CPU PMU. As such, perf_pmu__find_map(NULL) returns NULL
> for arm64.
> 
> To support printing metrics for arm64, iterate through all PMUs, looking
> for a CPU PMU, and use the cpumap there for determining supported metrics.
> 
> For heterogeneous systems (like arm big.LITTLE), supporting metrics has
> potential challenges, like not all CPUs in a system not supporting a
> specific metric event. So just don't support it for now.
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
>  tools/perf/util/metricgroup.c | 24 +++++++++++++++++++++++-
>  1 file changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index 26c990e32378..9a2a23093961 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -6,6 +6,7 @@
>  /* Manage metrics and groups of metrics from JSON files */
>  
>  #include "metricgroup.h"
> +#include "cpumap.h"
>  #include "debug.h"
>  #include "evlist.h"
>  #include "evsel.h"
> @@ -615,10 +616,31 @@ static int metricgroup__print_sys_event_iter(struct pmu_event *pe, void *data)
>  				     d->details, d->groups, d->metriclist);
>  }
>  
> +static struct pmu_events_map *find_cpumap(void)
> +{
> +	struct perf_pmu *pmu = NULL;
> +
> +	while ((pmu = perf_pmu__scan(pmu))) {
> +		if (!is_pmu_core(pmu->name))
> +			continue;
> +
> +		/*
> +		 * The cpumap should cover all CPUs. Otherwise, some CPUs may
> +		 * not support some events or have different event IDs.
> +		 */
> +		if (pmu->cpus && pmu->cpus->nr != cpu__max_cpu())
> +			return NULL;
> +
> +		return perf_pmu__find_map(pmu);
> +	}
> +
> +	return NULL;
> +}
> +
>  void metricgroup__print(bool metrics, bool metricgroups, char *filter,
>  			bool raw, bool details)
>  {
> -	struct pmu_events_map *map = perf_pmu__find_map(NULL);
> +	struct pmu_events_map *map = find_cpumap();

so this is just for arm at the moment right?

could we rather make this arch specific code, so we don't need
to do the scanning on archs where this is not needed?

like marking perf_pmu__find_map as __weak and add arm specific
version?

thanks,
jirka

>  	struct pmu_event *pe;
>  	int i;
>  	struct rblist groups;
> -- 
> 2.26.2
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/5] perf metricgroup: Support printing metrics for arm64
  2021-03-04 20:05     ` Jiri Olsa
@ 2021-03-05 11:06       ` John Garry
  -1 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-05 11:06 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, namhyung, irogers,
	linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain


Hi Jirka,

>> -	struct pmu_events_map *map = perf_pmu__find_map(NULL);
>> +	struct pmu_events_map *map = find_cpumap();
> so this is just for arm at the moment right?
> 

Yes - but to be more accurate, arm64.

At the moment, from the archs which use pmu-events, only arm64 and nds32 
have versions of get_cpuid_str() which require a non-NULL pmu argument.

But then apparently nds32 only supports a single CPU, so this issue of 
heterogeneous CPUs should not be a concern there :)

> could we rather make this arch specific code, so we don't need
> to do the scanning on archs where this is not needed?
> 
> like marking perf_pmu__find_map as __weak and add arm specific
> version?

Well I was thinking that this code should not be in metricgroup.c anyway.

So there is code which is common in current perf_pmu__find_map() for all 
archs.

I could factor that out into a common function, below. Just a bit 
worried about perf_pmu__find_map() and perf_pmu__find_pmu_map() being 
confused.

Here's how that would look:

+++ b/tools/perf/arch/arm64/util/pmu.c

#include "../../util/cpumap.h"
#include "../../util/pmu.h"

struct pmu_events_map *perf_pmu__find_map(void)
{
	struct perf_pmu *pmu = perf_pmu__find("armv8_pmuv3_0");

	if (!pmu || !pmu->cpus || pmu->cpus->nr != cpu__max_cpu())
		return NULL;

	return perf_pmu__find_pmu_map(pmu);
}

And:

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 26c990e32378..312164ce9299 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -618,7 +618,7 @@ static int metricgroup__print_sys_event_iter(struct 
pmu_event *pe, void *data)
  void metricgroup__print(bool metrics, bool metricgroups, char *filter,
  			bool raw, bool details)
  {
-	struct pmu_events_map *map = perf_pmu__find_map(NULL);
+	struct pmu_events_map *map = perf_pmu__find_map();
  	struct pmu_event *pe;
  	int i;
  	struct rblist groups;
@@ -1253,8 +1253,7 @@ int metricgroup__parse_groups(const struct option 
*opt,
  			      struct rblist *metric_events)
  {
  	struct evlist *perf_evlist = *(struct evlist **)opt->value;
-	struct pmu_events_map *map = perf_pmu__find_map(NULL);
-
+	struct pmu_events_map *map = perf_pmu__find_map();

  	return parse_groups(perf_evlist, str, metric_no_group,
  			    metric_no_merge, NULL, metric_events, map);
@@ -1273,7 +1272,7 @@ int metricgroup__parse_groups_test(struct evlist 
*evlist,

  bool metricgroup__has_metric(const char *metric)
  {
-	struct pmu_events_map *map = perf_pmu__find_map(NULL);
+	struct pmu_events_map *map = perf_pmu__find_map();
  	struct pmu_event *pe;
  	int i;

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 44ef28302fc7..d49bf20b6058 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -690,7 +690,7 @@ static char *perf_pmu__getcpuid(struct perf_pmu *pmu)
  	return cpuid;
  }

-struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu)
+struct pmu_events_map *perf_pmu__find_pmu_map(struct perf_pmu *pmu)
  {
  	struct pmu_events_map *map;
  	char *cpuid = perf_pmu__getcpuid(pmu);
@@ -717,6 +717,11 @@ struct pmu_events_map *perf_pmu__find_map(struct 
perf_pmu *pmu)
  	return map;
  }

+struct pmu_events_map *__weak perf_pmu__find_map(void)
+{
+	return perf_pmu__find_pmu_map(NULL);
+}
+
  bool pmu_uncore_alias_match(const char *pmu_name, const char *name)
  {
  	char *tmp = NULL, *tok, *str;
@@ -805,7 +810,7 @@ static void pmu_add_cpu_aliases(struct list_head 
*head, struct perf_pmu *pmu)
  {
  	struct pmu_events_map *map;

-	map = perf_pmu__find_map(pmu);
+	map = perf_pmu__find_pmu_map(pmu);
  	if (!map)
  		return;


Thoughts?

Thanks!

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

* Re: [PATCH 1/5] perf metricgroup: Support printing metrics for arm64
@ 2021-03-05 11:06       ` John Garry
  0 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-05 11:06 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, namhyung, irogers,
	linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain


Hi Jirka,

>> -	struct pmu_events_map *map = perf_pmu__find_map(NULL);
>> +	struct pmu_events_map *map = find_cpumap();
> so this is just for arm at the moment right?
> 

Yes - but to be more accurate, arm64.

At the moment, from the archs which use pmu-events, only arm64 and nds32 
have versions of get_cpuid_str() which require a non-NULL pmu argument.

But then apparently nds32 only supports a single CPU, so this issue of 
heterogeneous CPUs should not be a concern there :)

> could we rather make this arch specific code, so we don't need
> to do the scanning on archs where this is not needed?
> 
> like marking perf_pmu__find_map as __weak and add arm specific
> version?

Well I was thinking that this code should not be in metricgroup.c anyway.

So there is code which is common in current perf_pmu__find_map() for all 
archs.

I could factor that out into a common function, below. Just a bit 
worried about perf_pmu__find_map() and perf_pmu__find_pmu_map() being 
confused.

Here's how that would look:

+++ b/tools/perf/arch/arm64/util/pmu.c

#include "../../util/cpumap.h"
#include "../../util/pmu.h"

struct pmu_events_map *perf_pmu__find_map(void)
{
	struct perf_pmu *pmu = perf_pmu__find("armv8_pmuv3_0");

	if (!pmu || !pmu->cpus || pmu->cpus->nr != cpu__max_cpu())
		return NULL;

	return perf_pmu__find_pmu_map(pmu);
}

And:

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 26c990e32378..312164ce9299 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -618,7 +618,7 @@ static int metricgroup__print_sys_event_iter(struct 
pmu_event *pe, void *data)
  void metricgroup__print(bool metrics, bool metricgroups, char *filter,
  			bool raw, bool details)
  {
-	struct pmu_events_map *map = perf_pmu__find_map(NULL);
+	struct pmu_events_map *map = perf_pmu__find_map();
  	struct pmu_event *pe;
  	int i;
  	struct rblist groups;
@@ -1253,8 +1253,7 @@ int metricgroup__parse_groups(const struct option 
*opt,
  			      struct rblist *metric_events)
  {
  	struct evlist *perf_evlist = *(struct evlist **)opt->value;
-	struct pmu_events_map *map = perf_pmu__find_map(NULL);
-
+	struct pmu_events_map *map = perf_pmu__find_map();

  	return parse_groups(perf_evlist, str, metric_no_group,
  			    metric_no_merge, NULL, metric_events, map);
@@ -1273,7 +1272,7 @@ int metricgroup__parse_groups_test(struct evlist 
*evlist,

  bool metricgroup__has_metric(const char *metric)
  {
-	struct pmu_events_map *map = perf_pmu__find_map(NULL);
+	struct pmu_events_map *map = perf_pmu__find_map();
  	struct pmu_event *pe;
  	int i;

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 44ef28302fc7..d49bf20b6058 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -690,7 +690,7 @@ static char *perf_pmu__getcpuid(struct perf_pmu *pmu)
  	return cpuid;
  }

-struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu)
+struct pmu_events_map *perf_pmu__find_pmu_map(struct perf_pmu *pmu)
  {
  	struct pmu_events_map *map;
  	char *cpuid = perf_pmu__getcpuid(pmu);
@@ -717,6 +717,11 @@ struct pmu_events_map *perf_pmu__find_map(struct 
perf_pmu *pmu)
  	return map;
  }

+struct pmu_events_map *__weak perf_pmu__find_map(void)
+{
+	return perf_pmu__find_pmu_map(NULL);
+}
+
  bool pmu_uncore_alias_match(const char *pmu_name, const char *name)
  {
  	char *tmp = NULL, *tok, *str;
@@ -805,7 +810,7 @@ static void pmu_add_cpu_aliases(struct list_head 
*head, struct perf_pmu *pmu)
  {
  	struct pmu_events_map *map;

-	map = perf_pmu__find_map(pmu);
+	map = perf_pmu__find_pmu_map(pmu);
  	if (!map)
  		return;


Thoughts?

Thanks!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/5] perf metricgroup: Support printing metrics for arm64
  2021-03-05 11:06       ` John Garry
@ 2021-03-06 19:34         ` Jiri Olsa
  -1 siblings, 0 replies; 22+ messages in thread
From: Jiri Olsa @ 2021-03-06 19:34 UTC (permalink / raw)
  To: John Garry
  Cc: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, namhyung, irogers,
	linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain

On Fri, Mar 05, 2021 at 11:06:58AM +0000, John Garry wrote:
> 
> Hi Jirka,
> 
> > > -	struct pmu_events_map *map = perf_pmu__find_map(NULL);
> > > +	struct pmu_events_map *map = find_cpumap();
> > so this is just for arm at the moment right?
> > 
> 
> Yes - but to be more accurate, arm64.
> 
> At the moment, from the archs which use pmu-events, only arm64 and nds32
> have versions of get_cpuid_str() which require a non-NULL pmu argument.
> 
> But then apparently nds32 only supports a single CPU, so this issue of
> heterogeneous CPUs should not be a concern there :)
> 
> > could we rather make this arch specific code, so we don't need
> > to do the scanning on archs where this is not needed?
> > 
> > like marking perf_pmu__find_map as __weak and add arm specific
> > version?
> 
> Well I was thinking that this code should not be in metricgroup.c anyway.
> 
> So there is code which is common in current perf_pmu__find_map() for all
> archs.
> 
> I could factor that out into a common function, below. Just a bit worried
> about perf_pmu__find_map() and perf_pmu__find_pmu_map() being confused.

right, so perf_pmu__find_map does not take perf_pmu as argument
anymore, so the prefix does not fit, how about pmu_events_map__find ?

thanks,
jirka


> 
> Here's how that would look:
> 
> +++ b/tools/perf/arch/arm64/util/pmu.c
> 
> #include "../../util/cpumap.h"
> #include "../../util/pmu.h"
> 
> struct pmu_events_map *perf_pmu__find_map(void)
> {
> 	struct perf_pmu *pmu = perf_pmu__find("armv8_pmuv3_0");
> 
> 	if (!pmu || !pmu->cpus || pmu->cpus->nr != cpu__max_cpu())
> 		return NULL;
> 
> 	return perf_pmu__find_pmu_map(pmu);
> }
> 
> And:
> 
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index 26c990e32378..312164ce9299 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -618,7 +618,7 @@ static int metricgroup__print_sys_event_iter(struct
> pmu_event *pe, void *data)
>  void metricgroup__print(bool metrics, bool metricgroups, char *filter,
>  			bool raw, bool details)
>  {
> -	struct pmu_events_map *map = perf_pmu__find_map(NULL);
> +	struct pmu_events_map *map = perf_pmu__find_map();
>  	struct pmu_event *pe;
>  	int i;
>  	struct rblist groups;
> @@ -1253,8 +1253,7 @@ int metricgroup__parse_groups(const struct option
> *opt,
>  			      struct rblist *metric_events)
>  {
>  	struct evlist *perf_evlist = *(struct evlist **)opt->value;
> -	struct pmu_events_map *map = perf_pmu__find_map(NULL);
> -
> +	struct pmu_events_map *map = perf_pmu__find_map();
> 
>  	return parse_groups(perf_evlist, str, metric_no_group,
>  			    metric_no_merge, NULL, metric_events, map);
> @@ -1273,7 +1272,7 @@ int metricgroup__parse_groups_test(struct evlist
> *evlist,
> 
>  bool metricgroup__has_metric(const char *metric)
>  {
> -	struct pmu_events_map *map = perf_pmu__find_map(NULL);
> +	struct pmu_events_map *map = perf_pmu__find_map();
>  	struct pmu_event *pe;
>  	int i;
> 
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index 44ef28302fc7..d49bf20b6058 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -690,7 +690,7 @@ static char *perf_pmu__getcpuid(struct perf_pmu *pmu)
>  	return cpuid;
>  }
> 
> -struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu)
> +struct pmu_events_map *perf_pmu__find_pmu_map(struct perf_pmu *pmu)
>  {
>  	struct pmu_events_map *map;
>  	char *cpuid = perf_pmu__getcpuid(pmu);
> @@ -717,6 +717,11 @@ struct pmu_events_map *perf_pmu__find_map(struct
> perf_pmu *pmu)
>  	return map;
>  }
> 
> +struct pmu_events_map *__weak perf_pmu__find_map(void)
> +{
> +	return perf_pmu__find_pmu_map(NULL);
> +}
> +
>  bool pmu_uncore_alias_match(const char *pmu_name, const char *name)
>  {
>  	char *tmp = NULL, *tok, *str;
> @@ -805,7 +810,7 @@ static void pmu_add_cpu_aliases(struct list_head *head,
> struct perf_pmu *pmu)
>  {
>  	struct pmu_events_map *map;
> 
> -	map = perf_pmu__find_map(pmu);
> +	map = perf_pmu__find_pmu_map(pmu);
>  	if (!map)
>  		return;
> 
> 
> Thoughts?
> 
> Thanks!
> 


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

* Re: [PATCH 1/5] perf metricgroup: Support printing metrics for arm64
@ 2021-03-06 19:34         ` Jiri Olsa
  0 siblings, 0 replies; 22+ messages in thread
From: Jiri Olsa @ 2021-03-06 19:34 UTC (permalink / raw)
  To: John Garry
  Cc: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, namhyung, irogers,
	linux-kernel, linux-arm-kernel, linuxarm, zhangshaokun,
	qiangqing.zhang, kjain

On Fri, Mar 05, 2021 at 11:06:58AM +0000, John Garry wrote:
> 
> Hi Jirka,
> 
> > > -	struct pmu_events_map *map = perf_pmu__find_map(NULL);
> > > +	struct pmu_events_map *map = find_cpumap();
> > so this is just for arm at the moment right?
> > 
> 
> Yes - but to be more accurate, arm64.
> 
> At the moment, from the archs which use pmu-events, only arm64 and nds32
> have versions of get_cpuid_str() which require a non-NULL pmu argument.
> 
> But then apparently nds32 only supports a single CPU, so this issue of
> heterogeneous CPUs should not be a concern there :)
> 
> > could we rather make this arch specific code, so we don't need
> > to do the scanning on archs where this is not needed?
> > 
> > like marking perf_pmu__find_map as __weak and add arm specific
> > version?
> 
> Well I was thinking that this code should not be in metricgroup.c anyway.
> 
> So there is code which is common in current perf_pmu__find_map() for all
> archs.
> 
> I could factor that out into a common function, below. Just a bit worried
> about perf_pmu__find_map() and perf_pmu__find_pmu_map() being confused.

right, so perf_pmu__find_map does not take perf_pmu as argument
anymore, so the prefix does not fit, how about pmu_events_map__find ?

thanks,
jirka


> 
> Here's how that would look:
> 
> +++ b/tools/perf/arch/arm64/util/pmu.c
> 
> #include "../../util/cpumap.h"
> #include "../../util/pmu.h"
> 
> struct pmu_events_map *perf_pmu__find_map(void)
> {
> 	struct perf_pmu *pmu = perf_pmu__find("armv8_pmuv3_0");
> 
> 	if (!pmu || !pmu->cpus || pmu->cpus->nr != cpu__max_cpu())
> 		return NULL;
> 
> 	return perf_pmu__find_pmu_map(pmu);
> }
> 
> And:
> 
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index 26c990e32378..312164ce9299 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -618,7 +618,7 @@ static int metricgroup__print_sys_event_iter(struct
> pmu_event *pe, void *data)
>  void metricgroup__print(bool metrics, bool metricgroups, char *filter,
>  			bool raw, bool details)
>  {
> -	struct pmu_events_map *map = perf_pmu__find_map(NULL);
> +	struct pmu_events_map *map = perf_pmu__find_map();
>  	struct pmu_event *pe;
>  	int i;
>  	struct rblist groups;
> @@ -1253,8 +1253,7 @@ int metricgroup__parse_groups(const struct option
> *opt,
>  			      struct rblist *metric_events)
>  {
>  	struct evlist *perf_evlist = *(struct evlist **)opt->value;
> -	struct pmu_events_map *map = perf_pmu__find_map(NULL);
> -
> +	struct pmu_events_map *map = perf_pmu__find_map();
> 
>  	return parse_groups(perf_evlist, str, metric_no_group,
>  			    metric_no_merge, NULL, metric_events, map);
> @@ -1273,7 +1272,7 @@ int metricgroup__parse_groups_test(struct evlist
> *evlist,
> 
>  bool metricgroup__has_metric(const char *metric)
>  {
> -	struct pmu_events_map *map = perf_pmu__find_map(NULL);
> +	struct pmu_events_map *map = perf_pmu__find_map();
>  	struct pmu_event *pe;
>  	int i;
> 
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index 44ef28302fc7..d49bf20b6058 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -690,7 +690,7 @@ static char *perf_pmu__getcpuid(struct perf_pmu *pmu)
>  	return cpuid;
>  }
> 
> -struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu)
> +struct pmu_events_map *perf_pmu__find_pmu_map(struct perf_pmu *pmu)
>  {
>  	struct pmu_events_map *map;
>  	char *cpuid = perf_pmu__getcpuid(pmu);
> @@ -717,6 +717,11 @@ struct pmu_events_map *perf_pmu__find_map(struct
> perf_pmu *pmu)
>  	return map;
>  }
> 
> +struct pmu_events_map *__weak perf_pmu__find_map(void)
> +{
> +	return perf_pmu__find_pmu_map(NULL);
> +}
> +
>  bool pmu_uncore_alias_match(const char *pmu_name, const char *name)
>  {
>  	char *tmp = NULL, *tok, *str;
> @@ -805,7 +810,7 @@ static void pmu_add_cpu_aliases(struct list_head *head,
> struct perf_pmu *pmu)
>  {
>  	struct pmu_events_map *map;
> 
> -	map = perf_pmu__find_map(pmu);
> +	map = perf_pmu__find_pmu_map(pmu);
>  	if (!map)
>  		return;
> 
> 
> Thoughts?
> 
> Thanks!
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/5] perf metricgroup: Support printing metrics for arm64
  2021-03-06 19:34         ` Jiri Olsa
@ 2021-03-08 16:34           ` John Garry
  -1 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-08 16:34 UTC (permalink / raw)
  To: Jiri Olsa, will, mark.rutland
  Cc: mathieu.poirier, leo.yan, peterz, mingo, acme,
	alexander.shishkin, namhyung, irogers, linux-kernel,
	linux-arm-kernel, Linuxarm, Zhangshaokun, qiangqing.zhang, kjain

On 06/03/2021 19:34, Jiri Olsa wrote:
> On Fri, Mar 05, 2021 at 11:06:58AM +0000, John Garry wrote:
>> Hi Jirka,
>>
>>>> -	struct pmu_events_map *map = perf_pmu__find_map(NULL);
>>>> +	struct pmu_events_map *map = find_cpumap();
>>> so this is just for arm at the moment right?
>>>
>> Yes - but to be more accurate, arm64.
>>
>> At the moment, from the archs which use pmu-events, only arm64 and nds32
>> have versions of get_cpuid_str() which require a non-NULL pmu argument.
>>
>> But then apparently nds32 only supports a single CPU, so this issue of
>> heterogeneous CPUs should not be a concern there:)
>>
>>> could we rather make this arch specific code, so we don't need
>>> to do the scanning on archs where this is not needed?
>>>
>>> like marking perf_pmu__find_map as __weak and add arm specific
>>> version?
>> Well I was thinking that this code should not be in metricgroup.c anyway.
>>
>> So there is code which is common in current perf_pmu__find_map() for all
>> archs.
>>
>> I could factor that out into a common function, below. Just a bit worried
>> about perf_pmu__find_map() and perf_pmu__find_pmu_map() being confused.
> right, so perf_pmu__find_map does not take perf_pmu as argument
> anymore, so the prefix does not fit, how about pmu_events_map__find ?

I think it could be ok.

But now I am slightly concerned that we don't put anything like this in 
arch/arm64, based on this earlier discussion on close topic:

https://lore.kernel.org/lkml/20190719075450.xcm4i4a5sfaxlfap@willie-the-truck/

Hi Will, Mark,

Do you have any objection to add arm64 specific code here?

So what I had originally in this patch was to iterate PMUs  in common 
code and find the CPU PMU and use that to match CPU metrics, as long as 
it's not a heterogeneous system.

Now the suggestion was to move that into arch specific code, as it's not 
needed for all archs.

Thanks,
John

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

* Re: [PATCH 1/5] perf metricgroup: Support printing metrics for arm64
@ 2021-03-08 16:34           ` John Garry
  0 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-08 16:34 UTC (permalink / raw)
  To: Jiri Olsa, will, mark.rutland
  Cc: mathieu.poirier, leo.yan, peterz, mingo, acme,
	alexander.shishkin, namhyung, irogers, linux-kernel,
	linux-arm-kernel, Linuxarm, Zhangshaokun, qiangqing.zhang, kjain

On 06/03/2021 19:34, Jiri Olsa wrote:
> On Fri, Mar 05, 2021 at 11:06:58AM +0000, John Garry wrote:
>> Hi Jirka,
>>
>>>> -	struct pmu_events_map *map = perf_pmu__find_map(NULL);
>>>> +	struct pmu_events_map *map = find_cpumap();
>>> so this is just for arm at the moment right?
>>>
>> Yes - but to be more accurate, arm64.
>>
>> At the moment, from the archs which use pmu-events, only arm64 and nds32
>> have versions of get_cpuid_str() which require a non-NULL pmu argument.
>>
>> But then apparently nds32 only supports a single CPU, so this issue of
>> heterogeneous CPUs should not be a concern there:)
>>
>>> could we rather make this arch specific code, so we don't need
>>> to do the scanning on archs where this is not needed?
>>>
>>> like marking perf_pmu__find_map as __weak and add arm specific
>>> version?
>> Well I was thinking that this code should not be in metricgroup.c anyway.
>>
>> So there is code which is common in current perf_pmu__find_map() for all
>> archs.
>>
>> I could factor that out into a common function, below. Just a bit worried
>> about perf_pmu__find_map() and perf_pmu__find_pmu_map() being confused.
> right, so perf_pmu__find_map does not take perf_pmu as argument
> anymore, so the prefix does not fit, how about pmu_events_map__find ?

I think it could be ok.

But now I am slightly concerned that we don't put anything like this in 
arch/arm64, based on this earlier discussion on close topic:

https://lore.kernel.org/lkml/20190719075450.xcm4i4a5sfaxlfap@willie-the-truck/

Hi Will, Mark,

Do you have any objection to add arm64 specific code here?

So what I had originally in this patch was to iterate PMUs  in common 
code and find the CPU PMU and use that to match CPU metrics, as long as 
it's not a heterogeneous system.

Now the suggestion was to move that into arch specific code, as it's not 
needed for all archs.

Thanks,
John

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/5] perf metricgroup: Support printing metrics for arm64
  2021-03-06 19:34         ` Jiri Olsa
@ 2021-03-11  8:47           ` John Garry
  -1 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-11  8:47 UTC (permalink / raw)
  To: Jiri Olsa, kjain
  Cc: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, namhyung, irogers,
	linux-kernel, linux-arm-kernel, Linuxarm, Zhangshaokun,
	qiangqing.zhang

On 06/03/2021 19:34, Jiri Olsa wrote:
> On Fri, Mar 05, 2021 at 11:06:58AM +0000, John Garry wrote:
>> Hi Jirka,
>>
>>>> -	struct pmu_events_map *map = perf_pmu__find_map(NULL);
>>>> +	struct pmu_events_map *map = find_cpumap();
>>> so this is just for arm at the moment right?
>>>
>> Yes - but to be more accurate, arm64.
>>
>> At the moment, from the archs which use pmu-events, only arm64 and nds32
>> have versions of get_cpuid_str() which require a non-NULL pmu argument.
>>
>> But then apparently nds32 only supports a single CPU, so this issue of
>> heterogeneous CPUs should not be a concern there:)
>>
>>> could we rather make this arch specific code, so we don't need
>>> to do the scanning on archs where this is not needed?
>>>
>>> like marking perf_pmu__find_map as __weak and add arm specific
>>> version?
>> Well I was thinking that this code should not be in metricgroup.c anyway.
>>
>> So there is code which is common in current perf_pmu__find_map() for all
>> archs.
>>
>> I could factor that out into a common function, below. Just a bit worried
>> about perf_pmu__find_map() and perf_pmu__find_pmu_map() being confused.
> right, so perf_pmu__find_map does not take perf_pmu as argument
> anymore, so the prefix does not fit, how about pmu_events_map__find ?

I just noticed this series:
https://lore.kernel.org/lkml/1612797946-18784-1-git-send-email-kan.liang@linux.intel.com/

Seems that this has metricgroup support for heterogeneous system config, 
while this series is metricgroup support for homogeneous system config 
for arch which supports heterogeneous system config. I need to check 
further for any conflicts.

@Kan Liang, it would be great if you could cc me on that series. I don't 
subscribe to the general list.

Thanks,
John

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

* Re: [PATCH 1/5] perf metricgroup: Support printing metrics for arm64
@ 2021-03-11  8:47           ` John Garry
  0 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-03-11  8:47 UTC (permalink / raw)
  To: Jiri Olsa, kjain
  Cc: will, mathieu.poirier, leo.yan, peterz, mingo, acme,
	mark.rutland, alexander.shishkin, namhyung, irogers,
	linux-kernel, linux-arm-kernel, Linuxarm, Zhangshaokun,
	qiangqing.zhang

On 06/03/2021 19:34, Jiri Olsa wrote:
> On Fri, Mar 05, 2021 at 11:06:58AM +0000, John Garry wrote:
>> Hi Jirka,
>>
>>>> -	struct pmu_events_map *map = perf_pmu__find_map(NULL);
>>>> +	struct pmu_events_map *map = find_cpumap();
>>> so this is just for arm at the moment right?
>>>
>> Yes - but to be more accurate, arm64.
>>
>> At the moment, from the archs which use pmu-events, only arm64 and nds32
>> have versions of get_cpuid_str() which require a non-NULL pmu argument.
>>
>> But then apparently nds32 only supports a single CPU, so this issue of
>> heterogeneous CPUs should not be a concern there:)
>>
>>> could we rather make this arch specific code, so we don't need
>>> to do the scanning on archs where this is not needed?
>>>
>>> like marking perf_pmu__find_map as __weak and add arm specific
>>> version?
>> Well I was thinking that this code should not be in metricgroup.c anyway.
>>
>> So there is code which is common in current perf_pmu__find_map() for all
>> archs.
>>
>> I could factor that out into a common function, below. Just a bit worried
>> about perf_pmu__find_map() and perf_pmu__find_pmu_map() being confused.
> right, so perf_pmu__find_map does not take perf_pmu as argument
> anymore, so the prefix does not fit, how about pmu_events_map__find ?

I just noticed this series:
https://lore.kernel.org/lkml/1612797946-18784-1-git-send-email-kan.liang@linux.intel.com/

Seems that this has metricgroup support for heterogeneous system config, 
while this series is metricgroup support for homogeneous system config 
for arch which supports heterogeneous system config. I need to check 
further for any conflicts.

@Kan Liang, it would be great if you could cc me on that series. I don't 
subscribe to the general list.

Thanks,
John

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-03-11  8:51 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03 15:22 [PATCH 0/5] perf arm64 metricgroup support John Garry
2021-03-03 15:22 ` John Garry
2021-03-03 15:22 ` [PATCH 1/5] perf metricgroup: Support printing metrics for arm64 John Garry
2021-03-03 15:22   ` John Garry
2021-03-04 20:05   ` Jiri Olsa
2021-03-04 20:05     ` Jiri Olsa
2021-03-05 11:06     ` John Garry
2021-03-05 11:06       ` John Garry
2021-03-06 19:34       ` Jiri Olsa
2021-03-06 19:34         ` Jiri Olsa
2021-03-08 16:34         ` John Garry
2021-03-08 16:34           ` John Garry
2021-03-11  8:47         ` John Garry
2021-03-11  8:47           ` John Garry
2021-03-03 15:22 ` [PATCH 2/5] perf metricgroup: Support adding " John Garry
2021-03-03 15:22   ` John Garry
2021-03-03 15:22 ` [PATCH 3/5] perf vendor events arm64: Add Hisi hip08 L1 metrics John Garry
2021-03-03 15:22   ` John Garry
2021-03-03 15:22 ` [PATCH 4/5] perf vendor events arm64: Add Hisi hip08 L2 metrics John Garry
2021-03-03 15:22   ` John Garry
2021-03-03 15:22 ` [PATCH 5/5] perf vendor events arm64: Add Hisi hip08 L3 metrics John Garry
2021-03-03 15:22   ` John Garry

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.