All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] perf test: Improve pmu-events support
@ 2021-07-29 13:56 John Garry
  2021-07-29 13:56 ` [PATCH 01/11] perf test: Factor out pmu-events event comparison John Garry
                   ` (10 more replies)
  0 siblings, 11 replies; 22+ messages in thread
From: John Garry @ 2021-07-29 13:56 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm, John Garry

Recently it has been shown that the pmu-events tests do not always catch
broken uncore PMU alias support.

The main problem is that the alias matching only tests uncore PMUs which
are present in the host system, so pretty useless.

This series improves that by using fake uncore PMUs, and verifying aliases
generated for those PMUs match known expected values.

This means that even if one arch does not have PMUs which support some
special aliasing, like multiple tokens, we can still have a fake uncore
PMU test on that arch.

Support is also added to test system PMUs alias matching.

Based on 5.14-rc1 + "perf pmu: Fix alias matching".

John Garry (11):
  perf test: Factor out pmu-events event comparison
  perf jevents: Relocate test events to cpu folder
  perf test: Declare pmu-events test events separately
  perf test: Factor out pmu-events alias comparison
  perf test: Test pmu-events core aliases separately
  perf pmu: Check .is_uncore field in pmu_add_cpu_aliases_map()
  perf test: Re-add pmu-event uncore PMU alias test
  perf test: Add more pmu-events uncore aliases
  perf pmu: Make pmu_add_sys_aliases() public
  perf jevents: Print SoC name per system event table
  perf test: Add pmu-events sys event support

 .../{test_cpu => test_soc/cpu}/branch.json    |   0
 .../{test_cpu => test_soc/cpu}/cache.json     |   0
 .../{test_cpu => test_soc/cpu}/other.json     |   0
 .../{test_cpu => test_soc/cpu}/uncore.json    |  23 +-
 .../arch/test/test_soc/sys/uncore.json        |   9 +
 tools/perf/pmu-events/jevents.c               |   5 +-
 tools/perf/pmu-events/pmu-events.h            |   1 +
 tools/perf/tests/pmu-events.c                 | 699 +++++++++++++-----
 tools/perf/util/pmu.c                         |   5 +-
 tools/perf/util/pmu.h                         |   1 +
 10 files changed, 533 insertions(+), 210 deletions(-)
 rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/branch.json (100%)
 rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/cache.json (100%)
 rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/other.json (100%)
 rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/uncore.json (51%)
 create mode 100644 tools/perf/pmu-events/arch/test/test_soc/sys/uncore.json

-- 
2.26.2


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

* [PATCH 01/11] perf test: Factor out pmu-events event comparison
  2021-07-29 13:56 [PATCH 00/11] perf test: Improve pmu-events support John Garry
@ 2021-07-29 13:56 ` John Garry
  2021-07-29 13:56 ` [PATCH 02/11] perf jevents: Relocate test events to cpu folder John Garry
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-07-29 13:56 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm, John Garry

Factor out event comparison which will be used in multiple places.

Also test "pmu" and "compat" fields.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 tools/perf/tests/pmu-events.c | 119 +++++++++++++++++++---------------
 1 file changed, 66 insertions(+), 53 deletions(-)

diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index b8aff8fb50d8..c064f08c63c9 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -161,6 +161,71 @@ static struct pmu_events_map *__test_pmu_get_events_map(void)
 	return NULL;
 }
 
+static int compare_pmu_events(struct pmu_event *e1, const struct pmu_event *e2)
+{
+	if (!is_same(e1->desc, e2->desc)) {
+		pr_debug2("testing event e1 %s: mismatched desc, %s vs %s\n",
+			  e1->name, e1->desc, e2->desc);
+		return -1;
+	}
+
+	if (!is_same(e1->topic, e2->topic)) {
+		pr_debug2("testing event e1 %s: mismatched topic, %s vs %s\n",
+			  e1->name, e1->topic, e2->topic);
+		return -1;
+	}
+
+	if (!is_same(e1->long_desc, e2->long_desc)) {
+		pr_debug2("testing event e1 %s: mismatched long_desc, %s vs %s\n",
+			  e1->name, e1->long_desc, e2->long_desc);
+		return -1;
+	}
+
+	if (!is_same(e1->unit, e2->unit)) {
+		pr_debug2("testing event e1 %s: mismatched unit, %s vs %s\n",
+			  e1->name, e1->unit, e2->unit);
+		return -1;
+	}
+
+	if (!is_same(e1->perpkg, e2->perpkg)) {
+		pr_debug2("testing event e1 %s: mismatched perpkg, %s vs %s\n",
+			  e1->name, e1->perpkg, e2->perpkg);
+		return -1;
+	}
+
+	if (!is_same(e1->metric_expr, e2->metric_expr)) {
+		pr_debug2("testing event e1 %s: mismatched metric_expr, %s vs %s\n",
+			  e1->name, e1->metric_expr, e2->metric_expr);
+		return -1;
+	}
+
+	if (!is_same(e1->metric_name, e2->metric_name)) {
+		pr_debug2("testing event e1 %s: mismatched metric_name, %s vs %s\n",
+			  e1->name,	e1->metric_name, e2->metric_name);
+		return -1;
+	}
+
+	if (!is_same(e1->deprecated, e2->deprecated)) {
+		pr_debug2("testing event e1 %s: mismatched deprecated, %s vs %s\n",
+			  e1->name, e1->deprecated, e2->deprecated);
+		return -1;
+	}
+
+	if (!is_same(e1->pmu, e2->pmu)) {
+		pr_debug2("testing event e1 %s: mismatched pmu string, %s vs %s\n",
+			  e1->name, e1->pmu, e2->pmu);
+		return -1;
+	}
+
+	if (!is_same(e1->compat, e2->compat)) {
+		pr_debug2("testing event e1 %s: mismatched compat string, %s vs %s\n",
+			  e1->name, e1->compat, e2->compat);
+		return -1;
+	}
+
+	return 0;
+}
+
 /* Verify generated events from pmu-events.c is as expected */
 static int test_pmu_event_table(void)
 {
@@ -193,60 +258,8 @@ static int test_pmu_event_table(void)
 			found = true;
 			map_events++;
 
-			if (!is_same(table->desc, te->desc)) {
-				pr_debug2("testing event table %s: mismatched desc, %s vs %s\n",
-					  table->name, table->desc, te->desc);
-				return -1;
-			}
-
-			if (!is_same(table->topic, te->topic)) {
-				pr_debug2("testing event table %s: mismatched topic, %s vs %s\n",
-					  table->name, table->topic,
-					  te->topic);
-				return -1;
-			}
-
-			if (!is_same(table->long_desc, te->long_desc)) {
-				pr_debug2("testing event table %s: mismatched long_desc, %s vs %s\n",
-					  table->name, table->long_desc,
-					  te->long_desc);
-				return -1;
-			}
-
-			if (!is_same(table->unit, te->unit)) {
-				pr_debug2("testing event table %s: mismatched unit, %s vs %s\n",
-					  table->name, table->unit,
-					  te->unit);
-				return -1;
-			}
-
-			if (!is_same(table->perpkg, te->perpkg)) {
-				pr_debug2("testing event table %s: mismatched perpkg, %s vs %s\n",
-					  table->name, table->perpkg,
-					  te->perpkg);
-				return -1;
-			}
-
-			if (!is_same(table->metric_expr, te->metric_expr)) {
-				pr_debug2("testing event table %s: mismatched metric_expr, %s vs %s\n",
-					  table->name, table->metric_expr,
-					  te->metric_expr);
+			if (compare_pmu_events(table, te))
 				return -1;
-			}
-
-			if (!is_same(table->metric_name, te->metric_name)) {
-				pr_debug2("testing event table %s: mismatched metric_name, %s vs %s\n",
-					  table->name,  table->metric_name,
-					  te->metric_name);
-				return -1;
-			}
-
-			if (!is_same(table->deprecated, te->deprecated)) {
-				pr_debug2("testing event table %s: mismatched deprecated, %s vs %s\n",
-					  table->name, table->deprecated,
-					  te->deprecated);
-				return -1;
-			}
 
 			pr_debug("testing event table %s: pass\n", table->name);
 		}
-- 
2.26.2


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

* [PATCH 02/11] perf jevents: Relocate test events to cpu folder
  2021-07-29 13:56 [PATCH 00/11] perf test: Improve pmu-events support John Garry
  2021-07-29 13:56 ` [PATCH 01/11] perf test: Factor out pmu-events event comparison John Garry
@ 2021-07-29 13:56 ` John Garry
  2021-08-02 14:54   ` Arnaldo Carvalho de Melo
  2021-07-29 13:56 ` [PATCH 03/11] perf test: Declare pmu-events test events separately John Garry
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 22+ messages in thread
From: John Garry @ 2021-07-29 13:56 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm, John Garry

In future to add support for sys events, relocate the core and uncore
events to a cpu folder.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 .../pmu-events/arch/test/{test_cpu => test_soc/cpu}/branch.json | 0
 .../pmu-events/arch/test/{test_cpu => test_soc/cpu}/cache.json  | 0
 .../pmu-events/arch/test/{test_cpu => test_soc/cpu}/other.json  | 0
 .../pmu-events/arch/test/{test_cpu => test_soc/cpu}/uncore.json | 0
 tools/perf/pmu-events/jevents.c                                 | 2 +-
 5 files changed, 1 insertion(+), 1 deletion(-)
 rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/branch.json (100%)
 rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/cache.json (100%)
 rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/other.json (100%)
 rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/uncore.json (100%)

diff --git a/tools/perf/pmu-events/arch/test/test_cpu/branch.json b/tools/perf/pmu-events/arch/test/test_soc/cpu/branch.json
similarity index 100%
rename from tools/perf/pmu-events/arch/test/test_cpu/branch.json
rename to tools/perf/pmu-events/arch/test/test_soc/cpu/branch.json
diff --git a/tools/perf/pmu-events/arch/test/test_cpu/cache.json b/tools/perf/pmu-events/arch/test/test_soc/cpu/cache.json
similarity index 100%
rename from tools/perf/pmu-events/arch/test/test_cpu/cache.json
rename to tools/perf/pmu-events/arch/test/test_soc/cpu/cache.json
diff --git a/tools/perf/pmu-events/arch/test/test_cpu/other.json b/tools/perf/pmu-events/arch/test/test_soc/cpu/other.json
similarity index 100%
rename from tools/perf/pmu-events/arch/test/test_cpu/other.json
rename to tools/perf/pmu-events/arch/test/test_soc/cpu/other.json
diff --git a/tools/perf/pmu-events/arch/test/test_cpu/uncore.json b/tools/perf/pmu-events/arch/test/test_soc/cpu/uncore.json
similarity index 100%
rename from tools/perf/pmu-events/arch/test/test_cpu/uncore.json
rename to tools/perf/pmu-events/arch/test/test_soc/cpu/uncore.json
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index 9604446f8360..405bdd36b9b9 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -814,7 +814,7 @@ static void print_mapping_test_table(FILE *outfp)
 	fprintf(outfp, "\t.cpuid = \"testcpu\",\n");
 	fprintf(outfp, "\t.version = \"v1\",\n");
 	fprintf(outfp, "\t.type = \"core\",\n");
-	fprintf(outfp, "\t.table = pme_test_cpu,\n");
+	fprintf(outfp, "\t.table = pme_test_soc_cpu,\n");
 	fprintf(outfp, "},\n");
 }
 
-- 
2.26.2


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

* [PATCH 03/11] perf test: Declare pmu-events test events separately
  2021-07-29 13:56 [PATCH 00/11] perf test: Improve pmu-events support John Garry
  2021-07-29 13:56 ` [PATCH 01/11] perf test: Factor out pmu-events event comparison John Garry
  2021-07-29 13:56 ` [PATCH 02/11] perf jevents: Relocate test events to cpu folder John Garry
@ 2021-07-29 13:56 ` John Garry
  2021-07-29 13:56 ` [PATCH 04/11] perf test: Factor out pmu-events alias comparison John Garry
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-07-29 13:56 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm, John Garry

Currently all test events are put into arrays of test events.

Create pointer arrays of test events instead, so the test events may be
referenced later for tighter alias verification.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 tools/perf/tests/pmu-events.c | 244 ++++++++++++++++++----------------
 1 file changed, 126 insertions(+), 118 deletions(-)

diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index c064f08c63c9..0837f2c9d882 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -30,108 +30,114 @@ struct perf_pmu_test_event {
 	const char *alias_long_desc;
 };
 
-static struct perf_pmu_test_event test_cpu_events[] = {
-	{
-		.event = {
-			.name = "bp_l1_btb_correct",
-			.event = "event=0x8a",
-			.desc = "L1 BTB Correction",
-			.topic = "branch",
-		},
-		.alias_str = "event=0x8a",
-		.alias_long_desc = "L1 BTB Correction",
-	},
-	{
-		.event = {
-			.name = "bp_l2_btb_correct",
-			.event = "event=0x8b",
-			.desc = "L2 BTB Correction",
-			.topic = "branch",
-		},
-		.alias_str = "event=0x8b",
-		.alias_long_desc = "L2 BTB Correction",
+static const struct perf_pmu_test_event bp_l1_btb_correct = {
+	.event = {
+		.name = "bp_l1_btb_correct",
+		.event = "event=0x8a",
+		.desc = "L1 BTB Correction",
+		.topic = "branch",
 	},
-	{
-		.event = {
-			.name = "segment_reg_loads.any",
-			.event = "umask=0x80,period=200000,event=0x6",
-			.desc = "Number of segment register loads",
-			.topic = "other",
-		},
-		.alias_str = "umask=0x80,(null)=0x30d40,event=0x6",
-		.alias_long_desc = "Number of segment register loads",
+	.alias_str = "event=0x8a",
+	.alias_long_desc = "L1 BTB Correction",
+};
+
+static const struct perf_pmu_test_event bp_l2_btb_correct = {
+	.event = {
+		.name = "bp_l2_btb_correct",
+		.event = "event=0x8b",
+		.desc = "L2 BTB Correction",
+		.topic = "branch",
 	},
-	{
-		.event = {
-			.name = "dispatch_blocked.any",
-			.event = "umask=0x20,period=200000,event=0x9",
-			.desc = "Memory cluster signals to block micro-op dispatch for any reason",
-			.topic = "other",
-		},
-		.alias_str = "umask=0x20,(null)=0x30d40,event=0x9",
-		.alias_long_desc = "Memory cluster signals to block micro-op dispatch for any reason",
+	.alias_str = "event=0x8b",
+	.alias_long_desc = "L2 BTB Correction",
+};
+
+static const struct perf_pmu_test_event segment_reg_loads_any = {
+	.event = {
+		.name = "segment_reg_loads.any",
+		.event = "umask=0x80,period=200000,event=0x6",
+		.desc = "Number of segment register loads",
+		.topic = "other",
 	},
-	{
-		.event = {
-			.name = "eist_trans",
-			.event = "umask=0x0,period=200000,event=0x3a",
-			.desc = "Number of Enhanced Intel SpeedStep(R) Technology (EIST) transitions",
-			.topic = "other",
-		},
-		.alias_str = "umask=0,(null)=0x30d40,event=0x3a",
-		.alias_long_desc = "Number of Enhanced Intel SpeedStep(R) Technology (EIST) transitions",
+	.alias_str = "umask=0x80,(null)=0x30d40,event=0x6",
+	.alias_long_desc = "Number of segment register loads",
+};
+
+static const struct perf_pmu_test_event dispatch_blocked_any = {
+	.event = {
+		.name = "dispatch_blocked.any",
+		.event = "umask=0x20,period=200000,event=0x9",
+		.desc = "Memory cluster signals to block micro-op dispatch for any reason",
+		.topic = "other",
 	},
-	{
-		.event = {
-			.name = "l3_cache_rd",
-			.event = "event=0x40",
-			.desc = "L3 cache access, read",
-			.long_desc = "Attributable Level 3 cache access, read",
-			.topic = "cache",
-		},
-		.alias_str = "event=0x40",
-		.alias_long_desc = "Attributable Level 3 cache access, read",
+	.alias_str = "umask=0x20,(null)=0x30d40,event=0x9",
+	.alias_long_desc = "Memory cluster signals to block micro-op dispatch for any reason",
+};
+
+static const struct perf_pmu_test_event eist_trans = {
+	.event = {
+		.name = "eist_trans",
+		.event = "umask=0x0,period=200000,event=0x3a",
+		.desc = "Number of Enhanced Intel SpeedStep(R) Technology (EIST) transitions",
+		.topic = "other",
 	},
-	{ /* sentinel */
-		.event = {
-			.name = NULL,
-		},
+	.alias_str = "umask=0,(null)=0x30d40,event=0x3a",
+	.alias_long_desc = "Number of Enhanced Intel SpeedStep(R) Technology (EIST) transitions",
+};
+
+static const struct perf_pmu_test_event l3_cache_rd = {
+	.event = {
+		.name = "l3_cache_rd",
+		.event = "event=0x40",
+		.desc = "L3 cache access, read",
+		.long_desc = "Attributable Level 3 cache access, read",
+		.topic = "cache",
 	},
+	.alias_str = "event=0x40",
+	.alias_long_desc = "Attributable Level 3 cache access, read",
 };
 
-static struct perf_pmu_test_event test_uncore_events[] = {
-	{
-		.event = {
-			.name = "uncore_hisi_ddrc.flux_wcmd",
-			.event = "event=0x2",
-			.desc = "DDRC write commands. Unit: hisi_sccl,ddrc ",
-			.topic = "uncore",
-			.long_desc = "DDRC write commands",
-			.pmu = "hisi_sccl,ddrc",
-		},
-		.alias_str = "event=0x2",
-		.alias_long_desc = "DDRC write commands",
+static const struct perf_pmu_test_event *core_events[] = {
+	&bp_l1_btb_correct,
+	&bp_l2_btb_correct,
+	&segment_reg_loads_any,
+	&dispatch_blocked_any,
+	&eist_trans,
+	&l3_cache_rd,
+	NULL
+};
+
+static const struct perf_pmu_test_event uncore_hisi_ddrc_flux_wcmd = {
+	.event = {
+		.name = "uncore_hisi_ddrc.flux_wcmd",
+		.event = "event=0x2",
+		.desc = "DDRC write commands. Unit: hisi_sccl,ddrc ",
+		.topic = "uncore",
+		.long_desc = "DDRC write commands",
+		.pmu = "hisi_sccl,ddrc",
 	},
-	{
-		.event = {
-			.name = "unc_cbo_xsnp_response.miss_eviction",
-			.event = "umask=0x81,event=0x22",
-			.desc = "Unit: uncore_cbox A cross-core snoop resulted from L3 Eviction which misses in some processor core",
-			.topic = "uncore",
-			.long_desc = "A cross-core snoop resulted from L3 Eviction which misses in some processor core",
-			.pmu = "uncore_cbox",
-		},
-		.alias_str = "umask=0x81,event=0x22",
-		.alias_long_desc = "A cross-core snoop resulted from L3 Eviction which misses in some processor core",
+	.alias_str = "event=0x2",
+	.alias_long_desc = "DDRC write commands",
+};
+
+static const struct perf_pmu_test_event unc_cbo_xsnp_response_miss_eviction = {
+	.event = {
+		.name = "unc_cbo_xsnp_response.miss_eviction",
+		.event = "umask=0x81,event=0x22",
+		.desc = "Unit: uncore_cbox A cross-core snoop resulted from L3 Eviction which misses in some processor core",
+		.topic = "uncore",
+		.long_desc = "A cross-core snoop resulted from L3 Eviction which misses in some processor core",
+		.pmu = "uncore_cbox",
 	},
-	{ /* sentinel */
-		.event = {
-			.name = NULL,
-		},
-	}
+	.alias_str = "umask=0x81,event=0x22",
+	.alias_long_desc = "A cross-core snoop resulted from L3 Eviction which misses in some processor core",
 };
 
-const int total_test_events_size = ARRAY_SIZE(test_uncore_events);
+static const struct perf_pmu_test_event *uncore_events[] = {
+	&uncore_hisi_ddrc_flux_wcmd,
+	&unc_cbo_xsnp_response_miss_eviction,
+	NULL
+};
 
 static bool is_same(const char *reference, const char *test)
 {
@@ -226,7 +232,7 @@ static int compare_pmu_events(struct pmu_event *e1, const struct pmu_event *e2)
 	return 0;
 }
 
-/* Verify generated events from pmu-events.c is as expected */
+/* Verify generated events from pmu-events.c are as expected */
 static int test_pmu_event_table(void)
 {
 	struct pmu_events_map *map = __test_pmu_get_events_map();
@@ -234,31 +240,31 @@ static int test_pmu_event_table(void)
 	int map_events = 0, expected_events;
 
 	/* ignore 2x sentinels */
-	expected_events = ARRAY_SIZE(test_cpu_events) +
-			  ARRAY_SIZE(test_uncore_events) - 2;
+	expected_events = ARRAY_SIZE(core_events) +
+			  ARRAY_SIZE(uncore_events) - 2;
 
 	if (!map)
 		return -1;
 
 	for (table = map->table; table->name; table++) {
-		struct perf_pmu_test_event *test;
-		struct pmu_event *te;
+		struct perf_pmu_test_event const **test_event_table;
 		bool found = false;
 
 		if (table->pmu)
-			test = &test_uncore_events[0];
+			test_event_table = &uncore_events[0];
 		else
-			test = &test_cpu_events[0];
+			test_event_table = &core_events[0];
 
-		te = &test->event;
+		for (; *test_event_table; test_event_table++) {
+			struct perf_pmu_test_event const *test_event = *test_event_table;
+			struct pmu_event const *event = &test_event->event;
 
-		for (; te->name; test++, te = &test->event) {
-			if (strcmp(table->name, te->name))
+			if (strcmp(table->name, event->name))
 				continue;
 			found = true;
 			map_events++;
 
-			if (compare_pmu_events(table, te))
+			if (compare_pmu_events(table, event))
 				return -1;
 
 			pr_debug("testing event table %s: pass\n", table->name);
@@ -294,8 +300,7 @@ static struct perf_pmu_alias *find_alias(const char *test_event, struct list_hea
 /* Verify aliases are as expected */
 static int __test__pmu_event_aliases(char *pmu_name, int *count)
 {
-	struct perf_pmu_test_event *test;
-	struct pmu_event *te;
+	struct perf_pmu_test_event const **test_event_table;
 	struct perf_pmu *pmu;
 	LIST_HEAD(aliases);
 	int res = 0;
@@ -307,10 +312,10 @@ static int __test__pmu_event_aliases(char *pmu_name, int *count)
 		return -1;
 
 	if (is_pmu_core(pmu_name)) {
-		test = &test_cpu_events[0];
+		test_event_table = &core_events[0];
 		use_uncore_table = false;
 	} else {
-		test = &test_uncore_events[0];
+		test_event_table = &uncore_events[0];
 		use_uncore_table = true;
 	}
 
@@ -322,50 +327,53 @@ static int __test__pmu_event_aliases(char *pmu_name, int *count)
 
 	pmu_add_cpu_aliases_map(&aliases, pmu, map);
 
-	for (te = &test->event; te->name; test++, te = &test->event) {
-		struct perf_pmu_alias *alias = find_alias(te->name, &aliases);
+	for (; *test_event_table; test_event_table++) {
+		struct perf_pmu_test_event const *test_event = *test_event_table;
+		struct pmu_event const *event = &test_event->event;
+
+		struct perf_pmu_alias *alias = find_alias(event->name, &aliases);
 
 		if (!alias) {
 			bool uncore_match = pmu_uncore_alias_match(pmu_name,
-								   te->pmu);
+								   event->pmu);
 
 			if (use_uncore_table && !uncore_match) {
 				pr_debug3("testing aliases PMU %s: skip matching alias %s\n",
-					  pmu_name, te->name);
+					  pmu_name, event->name);
 				continue;
 			}
 
 			pr_debug2("testing aliases PMU %s: no alias, alias_table->name=%s\n",
-				  pmu_name, te->name);
+				  pmu_name, event->name);
 			res = -1;
 			break;
 		}
 
-		if (!is_same(alias->desc, te->desc)) {
+		if (!is_same(alias->desc, event->desc)) {
 			pr_debug2("testing aliases PMU %s: mismatched desc, %s vs %s\n",
-				  pmu_name, alias->desc, te->desc);
+				  pmu_name, alias->desc, event->desc);
 			res = -1;
 			break;
 		}
 
-		if (!is_same(alias->long_desc, test->alias_long_desc)) {
+		if (!is_same(alias->long_desc, test_event->alias_long_desc)) {
 			pr_debug2("testing aliases PMU %s: mismatched long_desc, %s vs %s\n",
 				  pmu_name, alias->long_desc,
-				  test->alias_long_desc);
+				  test_event->alias_long_desc);
 			res = -1;
 			break;
 		}
 
-		if (!is_same(alias->str, test->alias_str)) {
+		if (!is_same(alias->str, test_event->alias_str)) {
 			pr_debug2("testing aliases PMU %s: mismatched str, %s vs %s\n",
-				  pmu_name, alias->str, test->alias_str);
+				  pmu_name, alias->str, test_event->alias_str);
 			res = -1;
 			break;
 		}
 
-		if (!is_same(alias->topic, te->topic)) {
+		if (!is_same(alias->topic, event->topic)) {
 			pr_debug2("testing aliases PMU %s: mismatched topic, %s vs %s\n",
-				  pmu_name, alias->topic, te->topic);
+				  pmu_name, alias->topic, event->topic);
 			res = -1;
 			break;
 		}
-- 
2.26.2


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

* [PATCH 04/11] perf test: Factor out pmu-events alias comparison
  2021-07-29 13:56 [PATCH 00/11] perf test: Improve pmu-events support John Garry
                   ` (2 preceding siblings ...)
  2021-07-29 13:56 ` [PATCH 03/11] perf test: Declare pmu-events test events separately John Garry
@ 2021-07-29 13:56 ` John Garry
  2021-07-29 13:56 ` [PATCH 05/11] perf test: Test pmu-events core aliases separately John Garry
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-07-29 13:56 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm, John Garry

Factor out alias test which will be used in multiple places.

Also test missing fields.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 tools/perf/tests/pmu-events.c | 80 ++++++++++++++++++++++++-----------
 1 file changed, 55 insertions(+), 25 deletions(-)

diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index 0837f2c9d882..8fb5df6ee500 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -232,6 +232,60 @@ static int compare_pmu_events(struct pmu_event *e1, const struct pmu_event *e2)
 	return 0;
 }
 
+static int compare_alias_to_test_event(struct perf_pmu_alias *alias,
+				struct perf_pmu_test_event const *test_event,
+				char const *pmu_name)
+{
+	struct pmu_event const *event = &test_event->event;
+
+	/* An alias was found, ensure everything is in order */
+	if (!is_same(alias->name, event->name)) {
+		pr_debug("testing aliases PMU %s: mismatched name, %s vs %s\n",
+			  pmu_name, alias->name, event->name);
+		return -1;
+	}
+
+	if (!is_same(alias->desc, event->desc)) {
+		pr_debug("testing aliases PMU %s: mismatched desc, %s vs %s\n",
+			  pmu_name, alias->desc, event->desc);
+		return -1;
+	}
+
+	if (!is_same(alias->long_desc, test_event->alias_long_desc)) {
+		pr_debug("testing aliases PMU %s: mismatched long_desc, %s vs %s\n",
+			  pmu_name, alias->long_desc,
+			  test_event->alias_long_desc);
+		return -1;
+	}
+
+	if (!is_same(alias->topic, event->topic)) {
+		pr_debug("testing aliases PMU %s: mismatched topic, %s vs %s\n",
+			  pmu_name, alias->topic, event->topic);
+		return -1;
+	}
+
+	if (!is_same(alias->str, test_event->alias_str)) {
+		pr_debug("testing aliases PMU %s: mismatched str, %s vs %s\n",
+			  pmu_name, alias->str, test_event->alias_str);
+		return -1;
+	}
+
+	if (!is_same(alias->long_desc, test_event->alias_long_desc)) {
+		pr_debug("testing aliases PMU %s: mismatched long desc, %s vs %s\n",
+			  pmu_name, alias->str, test_event->alias_long_desc);
+		return -1;
+	}
+
+
+	if (!is_same(alias->pmu_name, test_event->event.pmu)) {
+		pr_debug("testing aliases PMU %s: mismatched pmu_name, %s vs %s\n",
+			  pmu_name, alias->pmu_name, test_event->event.pmu);
+		return -1;
+	}
+
+	return 0;
+}
+
 /* Verify generated events from pmu-events.c are as expected */
 static int test_pmu_event_table(void)
 {
@@ -349,31 +403,7 @@ static int __test__pmu_event_aliases(char *pmu_name, int *count)
 			break;
 		}
 
-		if (!is_same(alias->desc, event->desc)) {
-			pr_debug2("testing aliases PMU %s: mismatched desc, %s vs %s\n",
-				  pmu_name, alias->desc, event->desc);
-			res = -1;
-			break;
-		}
-
-		if (!is_same(alias->long_desc, test_event->alias_long_desc)) {
-			pr_debug2("testing aliases PMU %s: mismatched long_desc, %s vs %s\n",
-				  pmu_name, alias->long_desc,
-				  test_event->alias_long_desc);
-			res = -1;
-			break;
-		}
-
-		if (!is_same(alias->str, test_event->alias_str)) {
-			pr_debug2("testing aliases PMU %s: mismatched str, %s vs %s\n",
-				  pmu_name, alias->str, test_event->alias_str);
-			res = -1;
-			break;
-		}
-
-		if (!is_same(alias->topic, event->topic)) {
-			pr_debug2("testing aliases PMU %s: mismatched topic, %s vs %s\n",
-				  pmu_name, alias->topic, event->topic);
+		if (compare_alias_to_test_event(alias, test_event, pmu_name)) {
 			res = -1;
 			break;
 		}
-- 
2.26.2


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

* [PATCH 05/11] perf test: Test pmu-events core aliases separately
  2021-07-29 13:56 [PATCH 00/11] perf test: Improve pmu-events support John Garry
                   ` (3 preceding siblings ...)
  2021-07-29 13:56 ` [PATCH 04/11] perf test: Factor out pmu-events alias comparison John Garry
@ 2021-07-29 13:56 ` John Garry
  2021-07-29 13:56 ` [PATCH 06/11] perf pmu: Check .is_uncore field in pmu_add_cpu_aliases_map() John Garry
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-07-29 13:56 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm, John Garry

The current method to test uncore event aliasing is limited, as it relies
on the uncore PMU being present in the host system to test.

As such, breakages of uncore PMU aliases goes unnoticed. To make this more
robust, a new method of testing uncore PMUs with fake PMUs will be used in
future. This will be separate to testing core PMU aliases.

So make the current test function core PMU only. Uncore PMU alias support
will be re-added later.

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

diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index 8fb5df6ee500..9537bbdd09f0 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -352,26 +352,19 @@ static struct perf_pmu_alias *find_alias(const char *test_event, struct list_hea
 }
 
 /* Verify aliases are as expected */
-static int __test__pmu_event_aliases(char *pmu_name, int *count)
+static int __test_core_pmu_event_aliases(char *pmu_name, int *count)
 {
 	struct perf_pmu_test_event const **test_event_table;
 	struct perf_pmu *pmu;
 	LIST_HEAD(aliases);
 	int res = 0;
-	bool use_uncore_table;
 	struct pmu_events_map *map = __test_pmu_get_events_map();
 	struct perf_pmu_alias *a, *tmp;
 
 	if (!map)
 		return -1;
 
-	if (is_pmu_core(pmu_name)) {
-		test_event_table = &core_events[0];
-		use_uncore_table = false;
-	} else {
-		test_event_table = &uncore_events[0];
-		use_uncore_table = true;
-	}
+	test_event_table = &core_events[0];
 
 	pmu = zalloc(sizeof(*pmu));
 	if (!pmu)
@@ -384,20 +377,10 @@ static int __test__pmu_event_aliases(char *pmu_name, int *count)
 	for (; *test_event_table; test_event_table++) {
 		struct perf_pmu_test_event const *test_event = *test_event_table;
 		struct pmu_event const *event = &test_event->event;
-
 		struct perf_pmu_alias *alias = find_alias(event->name, &aliases);
 
 		if (!alias) {
-			bool uncore_match = pmu_uncore_alias_match(pmu_name,
-								   event->pmu);
-
-			if (use_uncore_table && !uncore_match) {
-				pr_debug3("testing aliases PMU %s: skip matching alias %s\n",
-					  pmu_name, event->name);
-				continue;
-			}
-
-			pr_debug2("testing aliases PMU %s: no alias, alias_table->name=%s\n",
+			pr_debug("testing aliases core PMU %s: no alias, alias_table->name=%s\n",
 				  pmu_name, event->name);
 			res = -1;
 			break;
@@ -409,7 +392,7 @@ static int __test__pmu_event_aliases(char *pmu_name, int *count)
 		}
 
 		(*count)++;
-		pr_debug2("testing aliases PMU %s: matched event %s\n",
+		pr_debug2("testing aliases core PMU %s: matched event %s\n",
 			  pmu_name, alias->name);
 	}
 
@@ -421,7 +404,6 @@ static int __test__pmu_event_aliases(char *pmu_name, int *count)
 	return res;
 }
 
-
 /* Test that aliases generated are as expected */
 static int test_aliases(void)
 {
@@ -430,21 +412,26 @@ static int test_aliases(void)
 	while ((pmu = perf_pmu__scan(pmu)) != NULL) {
 		int count = 0;
 
+		if (!is_pmu_core(pmu->name))
+			continue;
+
 		if (list_empty(&pmu->format)) {
-			pr_debug2("skipping testing PMU %s\n", pmu->name);
+			pr_debug2("skipping testing core PMU %s\n", pmu->name);
 			continue;
 		}
 
-		if (__test__pmu_event_aliases(pmu->name, &count)) {
-			pr_debug("testing PMU %s aliases: failed\n", pmu->name);
+		if (__test_core_pmu_event_aliases(pmu->name, &count)) {
+			pr_debug("testing core PMU %s aliases: failed\n", pmu->name);
 			return -1;
 		}
 
-		if (count == 0)
-			pr_debug3("testing PMU %s aliases: no events to match\n",
+		if (count == 0) {
+			pr_debug("testing core PMU %s aliases: no events to match\n",
 				  pmu->name);
-		else
-			pr_debug("testing PMU %s aliases: pass\n", pmu->name);
+			return -1;
+		}
+
+		pr_debug("testing core PMU %s aliases: pass\n", pmu->name);
 	}
 
 	return 0;
-- 
2.26.2


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

* [PATCH 06/11] perf pmu: Check .is_uncore field in pmu_add_cpu_aliases_map()
  2021-07-29 13:56 [PATCH 00/11] perf test: Improve pmu-events support John Garry
                   ` (4 preceding siblings ...)
  2021-07-29 13:56 ` [PATCH 05/11] perf test: Test pmu-events core aliases separately John Garry
@ 2021-07-29 13:56 ` John Garry
  2021-07-29 13:56 ` [PATCH 07/11] perf test: Re-add pmu-event uncore PMU alias test John Garry
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-07-29 13:56 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm, John Garry

Calling pmu_is_uncore() for fake PMUs does not work, as it checks sysfs
for the PMU details (which won't exist).

Check .is_uncore field instead, which makes sense anyway.

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

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 538b8fa8a710..238792197006 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -843,8 +843,7 @@ void pmu_add_cpu_aliases_map(struct list_head *head, struct perf_pmu *pmu,
 			break;
 		}
 
-		if (pmu_is_uncore(name) &&
-		    pmu_uncore_alias_match(pname, name))
+		if (pmu->is_uncore && pmu_uncore_alias_match(pname, name))
 			goto new_alias;
 
 		if (strcmp(pname, name))
-- 
2.26.2


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

* [PATCH 07/11] perf test: Re-add pmu-event uncore PMU alias test
  2021-07-29 13:56 [PATCH 00/11] perf test: Improve pmu-events support John Garry
                   ` (5 preceding siblings ...)
  2021-07-29 13:56 ` [PATCH 06/11] perf pmu: Check .is_uncore field in pmu_add_cpu_aliases_map() John Garry
@ 2021-07-29 13:56 ` John Garry
  2021-07-29 13:56 ` [PATCH 08/11] perf test: Add more pmu-events uncore aliases John Garry
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-07-29 13:56 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm, John Garry

Add support to match aliases for uncore PMUs.

Since we cannot rely on the PMUs being present on the host system, use
fake PMUs.

The following conditions in the test are ensures:
- Expected count of aliases created
- All aliases can be matched to an expected alias in
  perf_pmu_test_pmu.aliases

This will catch the condition fixed in commit c47a5599eda3 ("perf tools:
Fix pattern matching for same substring in different PMU type"), where
excess events were created for a PMU. It will also fix the scenario
inadvertently broken there, where no aliases were created for aliases with
multiple tokens.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 tools/perf/tests/pmu-events.c | 110 ++++++++++++++++++++++++++++++++++
 1 file changed, 110 insertions(+)

diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index 9537bbdd09f0..74c7dfe0a97f 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -28,6 +28,14 @@ struct perf_pmu_test_event {
 	 * be set in the alias.
 	 */
 	const char *alias_long_desc;
+
+	/* PMU which we should match against */
+	const char *matching_pmu;
+};
+
+struct perf_pmu_test_pmu {
+	struct perf_pmu pmu;
+	struct perf_pmu_test_event const *aliases[10];
 };
 
 static const struct perf_pmu_test_event bp_l1_btb_correct = {
@@ -118,6 +126,7 @@ static const struct perf_pmu_test_event uncore_hisi_ddrc_flux_wcmd = {
 	},
 	.alias_str = "event=0x2",
 	.alias_long_desc = "DDRC write commands",
+	.matching_pmu = "hisi_sccl1_ddrc2",
 };
 
 static const struct perf_pmu_test_event unc_cbo_xsnp_response_miss_eviction = {
@@ -131,6 +140,7 @@ static const struct perf_pmu_test_event unc_cbo_xsnp_response_miss_eviction = {
 	},
 	.alias_str = "umask=0x81,event=0x22",
 	.alias_long_desc = "A cross-core snoop resulted from L3 Eviction which misses in some processor core",
+	.matching_pmu = "uncore_cbox_0",
 };
 
 static const struct perf_pmu_test_event *uncore_events[] = {
@@ -404,10 +414,103 @@ static int __test_core_pmu_event_aliases(char *pmu_name, int *count)
 	return res;
 }
 
+static int __test_uncore_pmu_event_aliases(struct perf_pmu_test_pmu *test_pmu)
+{
+	int alias_count = 0, to_match_count = 0, matched_count = 0;
+	struct perf_pmu_test_event const **table;
+	struct perf_pmu *pmu = &test_pmu->pmu;
+	const char *pmu_name = pmu->name;
+	struct perf_pmu_alias *a, *tmp, *alias;
+	struct pmu_events_map *map;
+	LIST_HEAD(aliases);
+	int res = 0;
+
+	map = __test_pmu_get_events_map();
+	if (!map)
+		return -1;
+	pmu_add_cpu_aliases_map(&aliases, pmu, map);
+
+	/* Count how many aliases we generated */
+	list_for_each_entry(alias, &aliases, list)
+		alias_count++;
+
+	/* Count how many aliases we expect from the known table */
+	for (table = &test_pmu->aliases[0]; *table; table++)
+		to_match_count++;
+
+	if (alias_count != to_match_count) {
+		pr_debug("testing aliases uncore PMU %s: mismatch expected aliases (%d) vs found (%d)\n",
+			 pmu_name, to_match_count, alias_count);
+		res = -1;
+		goto out;
+	}
+
+	list_for_each_entry(alias, &aliases, list) {
+		bool matched = false;
+
+		for (table = &test_pmu->aliases[0]; *table; table++) {
+			struct perf_pmu_test_event const *test_event = *table;
+			struct pmu_event const *event = &test_event->event;
+
+			if (!strcmp(event->name, alias->name)) {
+				if (compare_alias_to_test_event(alias,
+							test_event,
+							pmu_name)) {
+					continue;
+				}
+				matched = true;
+				matched_count++;
+			}
+		}
+
+		if (matched == false) {
+			pr_debug("testing aliases uncore PMU %s: could not match alias %s\n",
+				 pmu_name, alias->name);
+			res = -1;
+			goto out;
+		}
+	}
+
+	if (alias_count != matched_count) {
+		pr_debug("testing aliases uncore PMU %s: mismatch found aliases (%d) vs matched (%d)\n",
+			 pmu_name, matched_count, alias_count);
+		res = -1;
+	}
+
+out:
+	list_for_each_entry_safe(a, tmp, &aliases, list) {
+		list_del(&a->list);
+		perf_pmu_free_alias(a);
+	}
+	return res;
+}
+
+static struct perf_pmu_test_pmu test_pmus[] = {
+	{
+		.pmu = {
+			.name = (char *)"hisi_sccl1_ddrc2",
+			.is_uncore = 1,
+		},
+		.aliases = {
+			&uncore_hisi_ddrc_flux_wcmd,
+		},
+	},
+	{
+		.pmu = {
+			.name = (char *)"uncore_cbox_0",
+			.is_uncore = 1,
+		},
+		.aliases = {
+			&unc_cbo_xsnp_response_miss_eviction,
+		},
+	},
+};
+
 /* Test that aliases generated are as expected */
 static int test_aliases(void)
 {
 	struct perf_pmu *pmu = NULL;
+	unsigned long i;
 
 	while ((pmu = perf_pmu__scan(pmu)) != NULL) {
 		int count = 0;
@@ -434,6 +537,13 @@ static int test_aliases(void)
 		pr_debug("testing core PMU %s aliases: pass\n", pmu->name);
 	}
 
+	for (i = 0; i < ARRAY_SIZE(test_pmus); i++) {
+		int res = __test_uncore_pmu_event_aliases(&test_pmus[i]);
+
+		if (res)
+			return res;
+	}
+
 	return 0;
 }
 
-- 
2.26.2


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

* [PATCH 08/11] perf test: Add more pmu-events uncore aliases
  2021-07-29 13:56 [PATCH 00/11] perf test: Improve pmu-events support John Garry
                   ` (6 preceding siblings ...)
  2021-07-29 13:56 ` [PATCH 07/11] perf test: Re-add pmu-event uncore PMU alias test John Garry
@ 2021-07-29 13:56 ` John Garry
  2021-07-29 13:56 ` [PATCH 09/11] perf pmu: Make pmu_add_sys_aliases() public John Garry
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-07-29 13:56 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm, John Garry

Add more events to cover the scenarios fixed and also inadvertently broken
by commit c47a5599eda3 ("perf tools: Fix pattern matching for same
substring in different PMU type").

Signed-off-by: John Garry <john.garry@huawei.com>
---
 .../arch/test/test_soc/cpu/uncore.json        | 23 +++++-
 tools/perf/tests/pmu-events.c                 | 72 +++++++++++++++++++
 2 files changed, 94 insertions(+), 1 deletion(-)

diff --git a/tools/perf/pmu-events/arch/test/test_soc/cpu/uncore.json b/tools/perf/pmu-events/arch/test/test_soc/cpu/uncore.json
index d0a890cc814d..788766f45dbc 100644
--- a/tools/perf/pmu-events/arch/test/test_soc/cpu/uncore.json
+++ b/tools/perf/pmu-events/arch/test/test_soc/cpu/uncore.json
@@ -17,5 +17,26 @@
 	    "CounterMask": "0",
 	    "Invert": "0",
 	    "EdgeDetect": "0"
-  }
+  },
+  {
+	    "EventCode": "0x7",
+	    "EventName": "uncore_hisi_l3c.rd_hit_cpipe",
+	    "BriefDescription": "Total read hits",
+	    "PublicDescription": "Total read hits",
+	    "Unit": "hisi_sccl,l3c"
+  },
+  {
+	    "EventCode": "0x12",
+	    "EventName": "uncore_imc_free_running.cache_miss",
+	    "BriefDescription": "Total cache misses",
+	    "PublicDescription": "Total cache misses",
+	    "Unit": "imc_free_running"
+  },
+  {
+	    "EventCode": "0x34",
+	    "EventName": "uncore_imc.cache_hits",
+	    "BriefDescription": "Total cache hits",
+	    "PublicDescription": "Total cache hits",
+	    "Unit": "imc"
+  },
 ]
diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index 74c7dfe0a97f..0fcdeeda00ec 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -143,9 +143,54 @@ static const struct perf_pmu_test_event unc_cbo_xsnp_response_miss_eviction = {
 	.matching_pmu = "uncore_cbox_0",
 };
 
+static const struct perf_pmu_test_event uncore_hisi_l3c_rd_hit_cpipe = {
+	.event = {
+		.name = "uncore_hisi_l3c.rd_hit_cpipe",
+		.event = "event=0x2",
+		.desc = "Total read hits. Unit: hisi_sccl,l3c ",
+		.topic = "uncore",
+		.long_desc = "Total read hits",
+		.pmu = "hisi_sccl,l3c",
+	},
+	.alias_str = "event=0x7",
+	.alias_long_desc = "Total read hits",
+	.matching_pmu = "hisi_sccl3_l3c7",
+};
+
+static const struct perf_pmu_test_event uncore_imc_free_running_cache_miss = {
+	.event = {
+		.name = "uncore_imc_free_running.cache_miss",
+		.event = "event=0x12",
+		.desc = "Total cache misses. Unit: uncore_imc_free_running ",
+		.topic = "uncore",
+		.long_desc = "Total cache misses",
+		.pmu = "uncore_imc_free_running",
+	},
+	.alias_str = "event=0x12",
+	.alias_long_desc = "Total cache misses",
+	.matching_pmu = "uncore_imc_free_running_0",
+};
+
+static const struct perf_pmu_test_event uncore_imc_cache_hits = {
+	.event = {
+		.name = "uncore_imc.cache_hits",
+		.event = "event=0x34",
+		.desc = "Total cache hits. Unit: uncore_imc ",
+		.topic = "uncore",
+		.long_desc = "Total cache hits",
+		.pmu = "uncore_imc",
+	},
+	.alias_str = "event=0x34",
+	.alias_long_desc = "Total cache hits",
+	.matching_pmu = "uncore_imc_0",
+};
+
 static const struct perf_pmu_test_event *uncore_events[] = {
 	&uncore_hisi_ddrc_flux_wcmd,
 	&unc_cbo_xsnp_response_miss_eviction,
+	&uncore_hisi_l3c_rd_hit_cpipe,
+	&uncore_imc_free_running_cache_miss,
+	&uncore_imc_cache_hits,
 	NULL
 };
 
@@ -504,6 +549,33 @@ static struct perf_pmu_test_pmu test_pmus[] = {
 			&unc_cbo_xsnp_response_miss_eviction,
 		},
 	},
+	{
+		.pmu = {
+			.name = (char *)"hisi_sccl3_l3c7",
+			.is_uncore = 1,
+		},
+		.aliases = {
+			&uncore_hisi_l3c_rd_hit_cpipe,
+		},
+	},
+	{
+		.pmu = {
+			.name = (char *)"uncore_imc_free_running_0",
+			.is_uncore = 1,
+		},
+		.aliases = {
+			&uncore_imc_free_running_cache_miss,
+		},
+	},
+	{
+		.pmu = {
+			.name = (char *)"uncore_imc_0",
+			.is_uncore = 1,
+		},
+		.aliases = {
+			&uncore_imc_cache_hits,
+		},
+	},
 };
 
 /* Test that aliases generated are as expected */
-- 
2.26.2


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

* [PATCH 09/11] perf pmu: Make pmu_add_sys_aliases() public
  2021-07-29 13:56 [PATCH 00/11] perf test: Improve pmu-events support John Garry
                   ` (7 preceding siblings ...)
  2021-07-29 13:56 ` [PATCH 08/11] perf test: Add more pmu-events uncore aliases John Garry
@ 2021-07-29 13:56 ` John Garry
  2021-07-29 13:56 ` [PATCH 10/11] perf jevents: Print SoC name per system event table John Garry
  2021-07-29 13:56 ` [PATCH 11/11] perf test: Add pmu-events sys event support John Garry
  10 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-07-29 13:56 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm, John Garry

Function pmu_add_sys_aliases() will be required for the PMU events test
for system events aliases, so make it public.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 tools/perf/util/pmu.c | 2 +-
 tools/perf/util/pmu.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 238792197006..534b91ccb2a2 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -926,7 +926,7 @@ static int pmu_add_sys_aliases_iter_fn(struct pmu_event *pe, void *data)
 	return 0;
 }
 
-static void pmu_add_sys_aliases(struct list_head *head, struct perf_pmu *pmu)
+void pmu_add_sys_aliases(struct list_head *head, struct perf_pmu *pmu)
 {
 	struct pmu_sys_event_iter_data idata = {
 		.head = head,
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 926da483a141..033e8211c025 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -81,6 +81,7 @@ struct perf_pmu_alias {
 
 struct perf_pmu *perf_pmu__find(const char *name);
 struct perf_pmu *perf_pmu__find_by_type(unsigned int type);
+void pmu_add_sys_aliases(struct list_head *head, struct perf_pmu *pmu);
 int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
 		     struct list_head *head_terms,
 		     struct parse_events_error *error);
-- 
2.26.2


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

* [PATCH 10/11] perf jevents: Print SoC name per system event table
  2021-07-29 13:56 [PATCH 00/11] perf test: Improve pmu-events support John Garry
                   ` (8 preceding siblings ...)
  2021-07-29 13:56 ` [PATCH 09/11] perf pmu: Make pmu_add_sys_aliases() public John Garry
@ 2021-07-29 13:56 ` John Garry
  2021-07-29 13:56 ` [PATCH 11/11] perf test: Add pmu-events sys event support John Garry
  10 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-07-29 13:56 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm, John Garry

Print the SoC name per system event table, which will allow the test SoC be
identified by the pmu-events test.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 tools/perf/pmu-events/jevents.c    | 3 ++-
 tools/perf/pmu-events/pmu-events.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index 405bdd36b9b9..6731b3cf0c2f 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -836,7 +836,8 @@ static int process_system_event_tables(FILE *outfp)
 	print_system_event_mapping_table_prefix(outfp);
 
 	list_for_each_entry(sys_event_table, &sys_event_tables, list) {
-		fprintf(outfp, "\n\t{\n\t\t.table = %s,\n\t},",
+		fprintf(outfp, "\n\t{\n\t\t.table = %s,\n\t\t.name = \"%s\",\n\t},",
+			sys_event_table->soc_id,
 			sys_event_table->soc_id);
 	}
 
diff --git a/tools/perf/pmu-events/pmu-events.h b/tools/perf/pmu-events/pmu-events.h
index d1172f6aebf1..5c2bf7275c1c 100644
--- a/tools/perf/pmu-events/pmu-events.h
+++ b/tools/perf/pmu-events/pmu-events.h
@@ -45,6 +45,7 @@ struct pmu_events_map {
 };
 
 struct pmu_sys_events {
+	const char *name;
 	struct pmu_event *table;
 };
 
-- 
2.26.2


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

* [PATCH 11/11] perf test: Add pmu-events sys event support
  2021-07-29 13:56 [PATCH 00/11] perf test: Improve pmu-events support John Garry
                   ` (9 preceding siblings ...)
  2021-07-29 13:56 ` [PATCH 10/11] perf jevents: Print SoC name per system event table John Garry
@ 2021-07-29 13:56 ` John Garry
  10 siblings, 0 replies; 22+ messages in thread
From: John Garry @ 2021-07-29 13:56 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm, John Garry

Add support for system events, along with core and uncore events.

Support for a sample PMU is also added.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 .../arch/test/test_soc/sys/uncore.json        |  9 +++
 tools/perf/tests/pmu-events.c                 | 77 ++++++++++++++++++-
 2 files changed, 83 insertions(+), 3 deletions(-)
 create mode 100644 tools/perf/pmu-events/arch/test/test_soc/sys/uncore.json

diff --git a/tools/perf/pmu-events/arch/test/test_soc/sys/uncore.json b/tools/perf/pmu-events/arch/test/test_soc/sys/uncore.json
new file mode 100644
index 000000000000..0f681a6e10ea
--- /dev/null
+++ b/tools/perf/pmu-events/arch/test/test_soc/sys/uncore.json
@@ -0,0 +1,9 @@
+[
+  {
+           "BriefDescription": "ddr write-cycles event",
+           "EventCode": "0x2b",
+           "EventName": "sys_ddr_pmu.write_cycles",
+           "Unit": "sys_ddr_pmu",
+           "Compat": "v8"
+   },
+]
diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index 0fcdeeda00ec..43743cf719ef 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -194,6 +194,25 @@ static const struct perf_pmu_test_event *uncore_events[] = {
 	NULL
 };
 
+static const struct perf_pmu_test_event sys_ddr_pmu_write_cycles = {
+	.event = {
+		.name = "sys_ddr_pmu.write_cycles",
+		.event = "event=0x2b",
+		.desc = "ddr write-cycles event. Unit: uncore_sys_ddr_pmu ",
+		.topic = "uncore",
+		.pmu = "uncore_sys_ddr_pmu",
+		.compat = "v8",
+	},
+	.alias_str = "event=0x2b",
+	.alias_long_desc = "ddr write-cycles event. Unit: uncore_sys_ddr_pmu ",
+	.matching_pmu = "uncore_sys_ddr_pmu",
+};
+
+static const struct perf_pmu_test_event *sys_events[] = {
+	&sys_ddr_pmu_write_cycles,
+	NULL
+};
+
 static bool is_same(const char *reference, const char *test)
 {
 	if (!reference && !test)
@@ -222,6 +241,18 @@ static struct pmu_events_map *__test_pmu_get_events_map(void)
 	return NULL;
 }
 
+static struct pmu_event *__test_pmu_get_sys_events_table(void)
+{
+	struct pmu_sys_events *tables = &pmu_sys_event_tables[0];
+
+	for ( ; tables->name; tables++) {
+		if (!strcmp("pme_test_soc_sys", tables->name))
+			return tables->table;
+	}
+
+	return NULL;
+}
+
 static int compare_pmu_events(struct pmu_event *e1, const struct pmu_event *e2)
 {
 	if (!is_same(e1->desc, e2->desc)) {
@@ -344,15 +375,17 @@ static int compare_alias_to_test_event(struct perf_pmu_alias *alias,
 /* Verify generated events from pmu-events.c are as expected */
 static int test_pmu_event_table(void)
 {
+	struct pmu_event *sys_event_tables = __test_pmu_get_sys_events_table();
 	struct pmu_events_map *map = __test_pmu_get_events_map();
 	struct pmu_event *table;
 	int map_events = 0, expected_events;
 
-	/* ignore 2x sentinels */
+	/* ignore 3x sentinels */
 	expected_events = ARRAY_SIZE(core_events) +
-			  ARRAY_SIZE(uncore_events) - 2;
+			  ARRAY_SIZE(uncore_events) +
+			  ARRAY_SIZE(sys_events) - 3;
 
-	if (!map)
+	if (!map || !sys_event_tables)
 		return -1;
 
 	for (table = map->table; table->name; table++) {
@@ -386,6 +419,33 @@ static int test_pmu_event_table(void)
 		}
 	}
 
+	for (table = sys_event_tables; table->name; table++) {
+		struct perf_pmu_test_event const **test_event_table;
+		bool found = false;
+
+		test_event_table = &sys_events[0];
+
+		for (; *test_event_table; test_event_table++) {
+			struct perf_pmu_test_event const *test_event = *test_event_table;
+			struct pmu_event const *event = &test_event->event;
+
+			if (strcmp(table->name, event->name))
+				continue;
+			found = true;
+			map_events++;
+
+			if (compare_pmu_events(table, event))
+				return -1;
+
+			pr_debug("testing sys event table %s: pass\n", table->name);
+		}
+		if (!found) {
+			pr_debug("testing event table: could not find event %s\n",
+				   table->name);
+			return -1;
+		}
+	}
+
 	if (map_events != expected_events) {
 		pr_err("testing event table: found %d, but expected %d\n",
 		       map_events, expected_events);
@@ -474,6 +534,7 @@ static int __test_uncore_pmu_event_aliases(struct perf_pmu_test_pmu *test_pmu)
 	if (!map)
 		return -1;
 	pmu_add_cpu_aliases_map(&aliases, pmu, map);
+	pmu_add_sys_aliases(&aliases, pmu);
 
 	/* Count how many aliases we generated */
 	list_for_each_entry(alias, &aliases, list)
@@ -576,6 +637,16 @@ static struct perf_pmu_test_pmu test_pmus[] = {
 			&uncore_imc_cache_hits,
 		},
 	},
+	{
+		.pmu = {
+			.name = (char *)"uncore_sys_ddr_pmu0",
+			.is_uncore = 1,
+			.id = (char *)"v8",
+		},
+		.aliases = {
+			&sys_ddr_pmu_write_cycles,
+		},
+	},
 };
 
 /* Test that aliases generated are as expected */
-- 
2.26.2


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

* Re: [PATCH 02/11] perf jevents: Relocate test events to cpu folder
  2021-07-29 13:56 ` [PATCH 02/11] perf jevents: Relocate test events to cpu folder John Garry
@ 2021-08-02 14:54   ` Arnaldo Carvalho de Melo
  2021-08-02 15:02     ` John Garry
  2021-08-03  8:19     ` John Garry
  0 siblings, 2 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-08-02 14:54 UTC (permalink / raw)
  To: John Garry
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm

Em Thu, Jul 29, 2021 at 09:56:17PM +0800, John Garry escreveu:
> In future to add support for sys events, relocate the core and uncore
> events to a cpu folder.
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
>  .../pmu-events/arch/test/{test_cpu => test_soc/cpu}/branch.json | 0
>  .../pmu-events/arch/test/{test_cpu => test_soc/cpu}/cache.json  | 0
>  .../pmu-events/arch/test/{test_cpu => test_soc/cpu}/other.json  | 0
>  .../pmu-events/arch/test/{test_cpu => test_soc/cpu}/uncore.json | 0
>  tools/perf/pmu-events/jevents.c                                 | 2 +-
>  5 files changed, 1 insertion(+), 1 deletion(-)
>  rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/branch.json (100%)
>  rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/cache.json (100%)
>  rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/other.json (100%)
>  rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/uncore.json (100%)
> 
> diff --git a/tools/perf/pmu-events/arch/test/test_cpu/branch.json b/tools/perf/pmu-events/arch/test/test_soc/cpu/branch.json
> similarity index 100%
> rename from tools/perf/pmu-events/arch/test/test_cpu/branch.json
> rename to tools/perf/pmu-events/arch/test/test_soc/cpu/branch.json
> diff --git a/tools/perf/pmu-events/arch/test/test_cpu/cache.json b/tools/perf/pmu-events/arch/test/test_soc/cpu/cache.json
> similarity index 100%
> rename from tools/perf/pmu-events/arch/test/test_cpu/cache.json
> rename to tools/perf/pmu-events/arch/test/test_soc/cpu/cache.json
> diff --git a/tools/perf/pmu-events/arch/test/test_cpu/other.json b/tools/perf/pmu-events/arch/test/test_soc/cpu/other.json
> similarity index 100%
> rename from tools/perf/pmu-events/arch/test/test_cpu/other.json
> rename to tools/perf/pmu-events/arch/test/test_soc/cpu/other.json
> diff --git a/tools/perf/pmu-events/arch/test/test_cpu/uncore.json b/tools/perf/pmu-events/arch/test/test_soc/cpu/uncore.json
> similarity index 100%
> rename from tools/perf/pmu-events/arch/test/test_cpu/uncore.json
> rename to tools/perf/pmu-events/arch/test/test_soc/cpu/uncore.json
> diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
> index 9604446f8360..405bdd36b9b9 100644
> --- a/tools/perf/pmu-events/jevents.c
> +++ b/tools/perf/pmu-events/jevents.c
> @@ -814,7 +814,7 @@ static void print_mapping_test_table(FILE *outfp)
>  	fprintf(outfp, "\t.cpuid = \"testcpu\",\n");
>  	fprintf(outfp, "\t.version = \"v1\",\n");
>  	fprintf(outfp, "\t.type = \"core\",\n");
> -	fprintf(outfp, "\t.table = pme_test_cpu,\n");
> +	fprintf(outfp, "\t.table = pme_test_soc_cpu,\n");

Humm, is this already generated by some script? I.e. this
'pme_test_soc_cpu' table? Or does this works only when applying the full
patchset?

- Arnaldo

>  	fprintf(outfp, "},\n");
>  }
>  
> -- 
> 2.26.2
> 

-- 

- Arnaldo

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

* Re: [PATCH 02/11] perf jevents: Relocate test events to cpu folder
  2021-08-02 14:54   ` Arnaldo Carvalho de Melo
@ 2021-08-02 15:02     ` John Garry
  2021-08-03  8:19     ` John Garry
  1 sibling, 0 replies; 22+ messages in thread
From: John Garry @ 2021-08-02 15:02 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm

On 02/08/2021 15:54, Arnaldo Carvalho de Melo wrote:
> Em Thu, Jul 29, 2021 at 09:56:17PM +0800, John Garry escreveu:
>> In future to add support for sys events, relocate the core and uncore
>> events to a cpu folder.
>>
>> Signed-off-by: John Garry<john.garry@huawei.com>
>> ---
>>   .../pmu-events/arch/test/{test_cpu => test_soc/cpu}/branch.json | 0
>>   .../pmu-events/arch/test/{test_cpu => test_soc/cpu}/cache.json  | 0
>>   .../pmu-events/arch/test/{test_cpu => test_soc/cpu}/other.json  | 0
>>   .../pmu-events/arch/test/{test_cpu => test_soc/cpu}/uncore.json | 0
>>   tools/perf/pmu-events/jevents.c                                 | 2 +-
>>   5 files changed, 1 insertion(+), 1 deletion(-)
>>   rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/branch.json (100%)
>>   rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/cache.json (100%)
>>   rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/other.json (100%)
>>   rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/uncore.json (100%)
>>
>> diff --git a/tools/perf/pmu-events/arch/test/test_cpu/branch.json b/tools/perf/pmu-events/arch/test/test_soc/cpu/branch.json
>> similarity index 100%
>> rename from tools/perf/pmu-events/arch/test/test_cpu/branch.json
>> rename to tools/perf/pmu-events/arch/test/test_soc/cpu/branch.json
>> diff --git a/tools/perf/pmu-events/arch/test/test_cpu/cache.json b/tools/perf/pmu-events/arch/test/test_soc/cpu/cache.json
>> similarity index 100%
>> rename from tools/perf/pmu-events/arch/test/test_cpu/cache.json
>> rename to tools/perf/pmu-events/arch/test/test_soc/cpu/cache.json
>> diff --git a/tools/perf/pmu-events/arch/test/test_cpu/other.json b/tools/perf/pmu-events/arch/test/test_soc/cpu/other.json
>> similarity index 100%
>> rename from tools/perf/pmu-events/arch/test/test_cpu/other.json
>> rename to tools/perf/pmu-events/arch/test/test_soc/cpu/other.json
>> diff --git a/tools/perf/pmu-events/arch/test/test_cpu/uncore.json b/tools/perf/pmu-events/arch/test/test_soc/cpu/uncore.json
>> similarity index 100%
>> rename from tools/perf/pmu-events/arch/test/test_cpu/uncore.json
>> rename to tools/perf/pmu-events/arch/test/test_soc/cpu/uncore.json
>> diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
>> index 9604446f8360..405bdd36b9b9 100644
>> --- a/tools/perf/pmu-events/jevents.c
>> +++ b/tools/perf/pmu-events/jevents.c
>> @@ -814,7 +814,7 @@ static void print_mapping_test_table(FILE *outfp)
>>   	fprintf(outfp, "\t.cpuid = \"testcpu\",\n");
>>   	fprintf(outfp, "\t.version = \"v1\",\n");
>>   	fprintf(outfp, "\t.type = \"core\",\n");
>> -	fprintf(outfp, "\t.table = pme_test_cpu,\n");
>> +	fprintf(outfp, "\t.table = pme_test_soc_cpu,\n");
> Humm, is this already generated by some script? I.e. this
> 'pme_test_soc_cpu' table? Or does this works only when applying the full
> patchset?

Hi Arnaldo,

This file jevents.c generates a table in tools/perf/pmu-events/pmu-events.c

Are you having some issue in applying and building this?

I ask as I think that there is some pre-existing dependency issue which 
I mean to fix, i.e. so please try a clean build.

Thanks,
John

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

* Re: [PATCH 02/11] perf jevents: Relocate test events to cpu folder
  2021-08-02 14:54   ` Arnaldo Carvalho de Melo
  2021-08-02 15:02     ` John Garry
@ 2021-08-03  8:19     ` John Garry
  2021-08-09 15:46       ` John Garry
  1 sibling, 1 reply; 22+ messages in thread
From: John Garry @ 2021-08-03  8:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm

On 02/08/2021 15:54, Arnaldo Carvalho de Melo wrote:
> Em Thu, Jul 29, 2021 at 09:56:17PM +0800, John Garry escreveu:
>> In future to add support for sys events, relocate the core and uncore
>> events to a cpu folder.
>>
>> Signed-off-by: John Garry<john.garry@huawei.com>
>> ---
>>   .../pmu-events/arch/test/{test_cpu => test_soc/cpu}/branch.json | 0
>>   .../pmu-events/arch/test/{test_cpu => test_soc/cpu}/cache.json  | 0
>>   .../pmu-events/arch/test/{test_cpu => test_soc/cpu}/other.json  | 0
>>   .../pmu-events/arch/test/{test_cpu => test_soc/cpu}/uncore.json | 0
>>   tools/perf/pmu-events/jevents.c                                 | 2 +-
>>   5 files changed, 1 insertion(+), 1 deletion(-)
>>   rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/branch.json (100%)
>>   rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/cache.json (100%)
>>   rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/other.json (100%)
>>   rename tools/perf/pmu-events/arch/test/{test_cpu => test_soc/cpu}/uncore.json (100%)
>>
>> diff --git a/tools/perf/pmu-events/arch/test/test_cpu/branch.json b/tools/perf/pmu-events/arch/test/test_soc/cpu/branch.json
>> similarity index 100%
>> rename from tools/perf/pmu-events/arch/test/test_cpu/branch.json
>> rename to tools/perf/pmu-events/arch/test/test_soc/cpu/branch.json
>> diff --git a/tools/perf/pmu-events/arch/test/test_cpu/cache.json b/tools/perf/pmu-events/arch/test/test_soc/cpu/cache.json
>> similarity index 100%
>> rename from tools/perf/pmu-events/arch/test/test_cpu/cache.json
>> rename to tools/perf/pmu-events/arch/test/test_soc/cpu/cache.json
>> diff --git a/tools/perf/pmu-events/arch/test/test_cpu/other.json b/tools/perf/pmu-events/arch/test/test_soc/cpu/other.json
>> similarity index 100%
>> rename from tools/perf/pmu-events/arch/test/test_cpu/other.json
>> rename to tools/perf/pmu-events/arch/test/test_soc/cpu/other.json
>> diff --git a/tools/perf/pmu-events/arch/test/test_cpu/uncore.json b/tools/perf/pmu-events/arch/test/test_soc/cpu/uncore.json
>> similarity index 100%
>> rename from tools/perf/pmu-events/arch/test/test_cpu/uncore.json
>> rename to tools/perf/pmu-events/arch/test/test_soc/cpu/uncore.json
>> diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
>> index 9604446f8360..405bdd36b9b9 100644
>> --- a/tools/perf/pmu-events/jevents.c
>> +++ b/tools/perf/pmu-events/jevents.c
>> @@ -814,7 +814,7 @@ static void print_mapping_test_table(FILE *outfp)
>>   	fprintf(outfp, "\t.cpuid = \"testcpu\",\n");
>>   	fprintf(outfp, "\t.version = \"v1\",\n");
>>   	fprintf(outfp, "\t.type = \"core\",\n");
>> -	fprintf(outfp, "\t.table = pme_test_cpu,\n");
>> +	fprintf(outfp, "\t.table = pme_test_soc_cpu,\n");
> Humm, is this already generated by some script? I.e. this
> 'pme_test_soc_cpu' table? Or does this works only when applying the full
> patchset?

So I think we need something like this:

----->8--------

 From a08df563665e9ec088b1af86ceed058497e112a4 Mon Sep 17 00:00:00 2001
From: John Garry <john.garry@huawei.com>
Date: Tue, 3 Aug 2021 08:44:09 +0100
Subject: [PATCH] perf jevents: Make build dependency on test JSONs

Currently all JSONs and the mapfile for an arch are dependencies for
building pmu-events.c

The test JSONs are missing as a dependency, so add them.

Signed-off-by: John Garry <john.garry@huawei.com>

diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
index 215ba30b8534..a055dee6a46a 100644
--- a/tools/perf/pmu-events/Build
+++ b/tools/perf/pmu-events/Build
@@ -6,10 +6,13 @@ pmu-events-y	+= pmu-events.o
  JDIR		=  pmu-events/arch/$(SRCARCH)
  JSON		=  $(shell [ -d $(JDIR) ] &&				\
  			find $(JDIR) -name '*.json' -o -name 'mapfile.csv')
+JDIR_TEST	=  pmu-events/arch/test
+JSON_TEST	=  $(shell [ -d $(JDIR_TEST) ] &&			\
+			find $(JDIR_TEST) -name '*.json')

  #
  # Locate/process JSON files in pmu-events/arch/
  # directory and create tables in pmu-events.c.
  #
-$(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JEVENTS)
+$(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JSON_TEST) $(JEVENTS)
  	$(Q)$(call echo-cmd,gen)$(JEVENTS) $(SRCARCH) pmu-events/arch 
$(OUTPUT)pmu-events/pmu-events.c $(V)


-----8<-----

Thanks,
john

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

* Re: [PATCH 02/11] perf jevents: Relocate test events to cpu folder
  2021-08-03  8:19     ` John Garry
@ 2021-08-09 15:46       ` John Garry
  2021-08-10 14:01         ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 22+ messages in thread
From: John Garry @ 2021-08-09 15:46 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm

On 03/08/2021 09:19, John Garry wrote:
> So I think we need something like this:
> 
> ----->8--------
> 
>  From a08df563665e9ec088b1af86ceed058497e112a4 Mon Sep 17 00:00:00 2001
> From: John Garry <john.garry@huawei.com>
> Date: Tue, 3 Aug 2021 08:44:09 +0100
> Subject: [PATCH] perf jevents: Make build dependency on test JSONs
> 
> Currently all JSONs and the mapfile for an arch are dependencies for
> building pmu-events.c
> 
> The test JSONs are missing as a dependency, so add them.
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> 
> diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
> index 215ba30b8534..a055dee6a46a 100644
> --- a/tools/perf/pmu-events/Build
> +++ b/tools/perf/pmu-events/Build
> @@ -6,10 +6,13 @@ pmu-events-y    += pmu-events.o
>   JDIR        =  pmu-events/arch/$(SRCARCH)
>   JSON        =  $(shell [ -d $(JDIR) ] &&                \
>               find $(JDIR) -name '*.json' -o -name 'mapfile.csv')
> +JDIR_TEST    =  pmu-events/arch/test
> +JSON_TEST    =  $(shell [ -d $(JDIR_TEST) ] &&            \
> +            find $(JDIR_TEST) -name '*.json')
> 
>   #
>   # Locate/process JSON files in pmu-events/arch/
>   # directory and create tables in pmu-events.c.
>   #
> -$(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JEVENTS)
> +$(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JSON_TEST) $(JEVENTS)
>       $(Q)$(call echo-cmd,gen)$(JEVENTS) $(SRCARCH) pmu-events/arch 
> $(OUTPUT)pmu-events/pmu-events.c $(V)
> 
> 
> -----8<-----

Hi Arnaldo,

Shall I send this as a formal patch?

Thanks!

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

* Re: [PATCH 02/11] perf jevents: Relocate test events to cpu folder
  2021-08-09 15:46       ` John Garry
@ 2021-08-10 14:01         ` Arnaldo Carvalho de Melo
  2021-08-10 14:23           ` John Garry
  0 siblings, 1 reply; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-08-10 14:01 UTC (permalink / raw)
  To: John Garry
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm

Em Mon, Aug 09, 2021 at 04:46:04PM +0100, John Garry escreveu:
> On 03/08/2021 09:19, John Garry wrote:
> > So I think we need something like this:
> > 
> > ----->8--------
> > 
> >  From a08df563665e9ec088b1af86ceed058497e112a4 Mon Sep 17 00:00:00 2001
> > From: John Garry <john.garry@huawei.com>
> > Date: Tue, 3 Aug 2021 08:44:09 +0100
> > Subject: [PATCH] perf jevents: Make build dependency on test JSONs
> > 
> > Currently all JSONs and the mapfile for an arch are dependencies for
> > building pmu-events.c
> > 
> > The test JSONs are missing as a dependency, so add them.
> > 
> > Signed-off-by: John Garry <john.garry@huawei.com>
> > 
> > diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
> > index 215ba30b8534..a055dee6a46a 100644
> > --- a/tools/perf/pmu-events/Build
> > +++ b/tools/perf/pmu-events/Build
> > @@ -6,10 +6,13 @@ pmu-events-y    += pmu-events.o
> >   JDIR        =  pmu-events/arch/$(SRCARCH)
> >   JSON        =  $(shell [ -d $(JDIR) ] &&                \
> >               find $(JDIR) -name '*.json' -o -name 'mapfile.csv')
> > +JDIR_TEST    =  pmu-events/arch/test
> > +JSON_TEST    =  $(shell [ -d $(JDIR_TEST) ] &&            \
> > +            find $(JDIR_TEST) -name '*.json')
> > 
> >   #
> >   # Locate/process JSON files in pmu-events/arch/
> >   # directory and create tables in pmu-events.c.
> >   #
> > -$(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JEVENTS)
> > +$(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JSON_TEST) $(JEVENTS)
> >       $(Q)$(call echo-cmd,gen)$(JEVENTS) $(SRCARCH) pmu-events/arch
> > $(OUTPUT)pmu-events/pmu-events.c $(V)
> > 
> > 
> > -----8<-----
> 
> Hi Arnaldo,
> 
> Shall I send this as a formal patch?

The question is when should I apply this patch? After this series? After
the patch I commented about, before?

- Arnaldo

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

* Re: [PATCH 02/11] perf jevents: Relocate test events to cpu folder
  2021-08-10 14:01         ` Arnaldo Carvalho de Melo
@ 2021-08-10 14:23           ` John Garry
  2021-08-10 14:34             ` Arnaldo Carvalho de Melo
  2021-08-10 17:58             ` Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 22+ messages in thread
From: John Garry @ 2021-08-10 14:23 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm

On 10/08/2021 15:01, Arnaldo Carvalho de Melo wrote:
>> Shall I send this as a formal patch?
> The question is when should I apply this patch? After this series? After
> the patch I commented about, before?
> 

Hi Arnaldo,

I think that you can apply it before the series. This is a pre-existing 
issue that there was no dependency checking on the test events folder 
for rebuilding pmu-event.c .

Thanks


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

* Re: [PATCH 02/11] perf jevents: Relocate test events to cpu folder
  2021-08-10 14:23           ` John Garry
@ 2021-08-10 14:34             ` Arnaldo Carvalho de Melo
  2021-08-10 17:58             ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-08-10 14:34 UTC (permalink / raw)
  To: John Garry
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm

Em Tue, Aug 10, 2021 at 03:23:07PM +0100, John Garry escreveu:
> On 10/08/2021 15:01, Arnaldo Carvalho de Melo wrote:
> > > Shall I send this as a formal patch?
> > The question is when should I apply this patch? After this series? After
> > the patch I commented about, before?
> > 
> 
> Hi Arnaldo,
> 
> I think that you can apply it before the series. This is a pre-existing
> issue that there was no dependency checking on the test events folder for
> rebuilding pmu-event.c .

Ok, will do so, thanks for clarifying.

- Arnaldo

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

* Re: [PATCH 02/11] perf jevents: Relocate test events to cpu folder
  2021-08-10 14:23           ` John Garry
  2021-08-10 14:34             ` Arnaldo Carvalho de Melo
@ 2021-08-10 17:58             ` Arnaldo Carvalho de Melo
  2021-08-11  7:59               ` John Garry
  1 sibling, 1 reply; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-08-10 17:58 UTC (permalink / raw)
  To: John Garry
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm

Em Tue, Aug 10, 2021 at 03:23:07PM +0100, John Garry escreveu:
> On 10/08/2021 15:01, Arnaldo Carvalho de Melo wrote:
> > > Shall I send this as a formal patch?
> > The question is when should I apply this patch? After this series? After
> > the patch I commented about, before?
> > 
> 
> Hi Arnaldo,
> 
> I think that you can apply it before the series. This is a pre-existing
> issue that there was no dependency checking on the test events folder for
> rebuilding pmu-event.c .

Its all now in tmp.perf/core, will move to perf/core as soon as my test
suite finishes.

- Arnaldo

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

* Re: [PATCH 02/11] perf jevents: Relocate test events to cpu folder
  2021-08-10 17:58             ` Arnaldo Carvalho de Melo
@ 2021-08-11  7:59               ` John Garry
  2021-08-11 18:38                 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 22+ messages in thread
From: John Garry @ 2021-08-11  7:59 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm

On 10/08/2021 18:58, Arnaldo Carvalho de Melo wrote:
>> I think that you can apply it before the series. This is a pre-existing
>> issue that there was no dependency checking on the test events folder for
>> rebuilding pmu-event.c .
> Its all now in tmp.perf/core, will move to perf/core as soon as my test
> suite finishes.

Excellent, thanks!

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

* Re: [PATCH 02/11] perf jevents: Relocate test events to cpu folder
  2021-08-11  7:59               ` John Garry
@ 2021-08-11 18:38                 ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 22+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-08-11 18:38 UTC (permalink / raw)
  To: John Garry
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, namhyung,
	yao.jin, linux-kernel, linux-perf-users, irogers, linuxarm

Em Wed, Aug 11, 2021 at 08:59:24AM +0100, John Garry escreveu:
> On 10/08/2021 18:58, Arnaldo Carvalho de Melo wrote:
> > > I think that you can apply it before the series. This is a pre-existing
> > > issue that there was no dependency checking on the test events folder for
> > > rebuilding pmu-event.c .
> > Its all now in tmp.perf/core, will move to perf/core as soon as my test
> > suite finishes.
> 
> Excellent, thanks!


Passed, its in perf/core.

- Arnaldo

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

end of thread, other threads:[~2021-08-11 18:38 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-29 13:56 [PATCH 00/11] perf test: Improve pmu-events support John Garry
2021-07-29 13:56 ` [PATCH 01/11] perf test: Factor out pmu-events event comparison John Garry
2021-07-29 13:56 ` [PATCH 02/11] perf jevents: Relocate test events to cpu folder John Garry
2021-08-02 14:54   ` Arnaldo Carvalho de Melo
2021-08-02 15:02     ` John Garry
2021-08-03  8:19     ` John Garry
2021-08-09 15:46       ` John Garry
2021-08-10 14:01         ` Arnaldo Carvalho de Melo
2021-08-10 14:23           ` John Garry
2021-08-10 14:34             ` Arnaldo Carvalho de Melo
2021-08-10 17:58             ` Arnaldo Carvalho de Melo
2021-08-11  7:59               ` John Garry
2021-08-11 18:38                 ` Arnaldo Carvalho de Melo
2021-07-29 13:56 ` [PATCH 03/11] perf test: Declare pmu-events test events separately John Garry
2021-07-29 13:56 ` [PATCH 04/11] perf test: Factor out pmu-events alias comparison John Garry
2021-07-29 13:56 ` [PATCH 05/11] perf test: Test pmu-events core aliases separately John Garry
2021-07-29 13:56 ` [PATCH 06/11] perf pmu: Check .is_uncore field in pmu_add_cpu_aliases_map() John Garry
2021-07-29 13:56 ` [PATCH 07/11] perf test: Re-add pmu-event uncore PMU alias test John Garry
2021-07-29 13:56 ` [PATCH 08/11] perf test: Add more pmu-events uncore aliases John Garry
2021-07-29 13:56 ` [PATCH 09/11] perf pmu: Make pmu_add_sys_aliases() public John Garry
2021-07-29 13:56 ` [PATCH 10/11] perf jevents: Print SoC name per system event table John Garry
2021-07-29 13:56 ` [PATCH 11/11] perf test: Add pmu-events sys event support 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.