lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1627566986-30605-6-git-send-email-john.garry@huawei.com>
Date:   Thu, 29 Jul 2021 21:56:20 +0800
From:   John Garry <john.garry@...wei.com>
To:     <peterz@...radead.org>, <mingo@...hat.com>, <acme@...nel.org>,
        <mark.rutland@....com>, <alexander.shishkin@...ux.intel.com>,
        <jolsa@...hat.com>, <namhyung@...nel.org>
CC:     <yao.jin@...ux.intel.com>, <linux-kernel@...r.kernel.org>,
        <linux-perf-users@...r.kernel.org>, <irogers@...gle.com>,
        <linuxarm@...wei.com>, John Garry <john.garry@...wei.com>
Subject: [PATCH 05/11] perf test: Test pmu-events core aliases separately

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@...wei.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ