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>] [day] [month] [year] [list]
Message-Id: <20231215175455.1300261-1-kan.liang@linux.intel.com>
Date: Fri, 15 Dec 2023 09:54:55 -0800
From: kan.liang@...ux.intel.com
To: acme@...nel.org,
	irogers@...gle.com
Cc: namhyung@...nel.org,
	mark.rutland@....com,
	maz@...nel.org,
	marcan@...can.st,
	linux-kernel@...r.kernel.org,
	linux-perf-users@...r.kernel.org,
	Kan Liang <kan.liang@...ux.intel.com>
Subject: [PATCH] perf evlist: Move the modifier after the slash when rename a hybrid event

From: Kan Liang <kan.liang@...ux.intel.com>

The event name shown in the perf top is wrong on a hybrid machine.
 $perf top
 1K cpu_atom/cycles:P/
 11K cpu_core/cycles:P/

If using it on the command line:

 $perf top -e cpu_atom/cycles:P/
 event syntax error: 'cpu_atom/cycles:P/'
                              \___ Bad event or PMU

The evlist__uniquify_name() changes a hybrid event name to "//" style.
When using the "//" style, the event modifiers must be appended after
the last "/".

Split the old name into event and modifier. Apply the correct format for
the "//" style.

The patch fixes the same issue on the perf record as well.

Reported-by: Arnaldo Carvalho de Melo <acme@...nel.org>
Closes: https://lore.kernel.org/lkml/ZXxyanyZgWBTOnoK@kernel.org/
Signed-off-by: Kan Liang <kan.liang@...ux.intel.com>
---
 tools/perf/util/evlist.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 6f0892803c22..83f4e3ec62d0 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -2521,8 +2521,8 @@ void evlist__warn_user_requested_cpus(struct evlist *evlist, const char *cpu_lis
 
 void evlist__uniquify_name(struct evlist *evlist)
 {
+	char *new_name, *old_name, *modifier, *tmp;
 	struct evsel *pos;
-	char *new_name;
 	int ret;
 
 	if (perf_pmus__num_core_pmus() == 1)
@@ -2535,8 +2535,13 @@ void evlist__uniquify_name(struct evlist *evlist)
 		if (strchr(pos->name, '/'))
 			continue;
 
-		ret = asprintf(&new_name, "%s/%s/",
-			       pos->pmu_name, pos->name);
+		/* The event modifiers must be appended after "/" */
+		old_name = strtok_r(pos->name, ":", &tmp);
+		if (!old_name)
+			continue;
+		modifier = strtok_r(NULL, ":", &tmp);
+		ret = asprintf(&new_name, "%s/%s/%s",
+			       pos->pmu_name, old_name, !modifier ? "" : modifier);
 		if (ret) {
 			free(pos->name);
 			pos->name = new_name;
-- 
2.35.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ