linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: kan.liang@linux.intel.com
To: acme@kernel.org, irogers@google.com
Cc: namhyung@kernel.org, mark.rutland@arm.com, maz@kernel.org,
	marcan@marcan.st, linux-kernel@vger.kernel.org,
	linux-perf-users@vger.kernel.org,
	Kan Liang <kan.liang@linux.intel.com>
Subject: [PATCH] perf evlist: Move the modifier after the slash when rename a hybrid event
Date: Fri, 15 Dec 2023 09:54:55 -0800	[thread overview]
Message-ID: <20231215175455.1300261-1-kan.liang@linux.intel.com> (raw)

From: Kan Liang <kan.liang@linux.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@kernel.org>
Closes: https://lore.kernel.org/lkml/ZXxyanyZgWBTOnoK@kernel.org/
Signed-off-by: Kan Liang <kan.liang@linux.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


                 reply	other threads:[~2023-12-15 17:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231215175455.1300261-1-kan.liang@linux.intel.com \
    --to=kan.liang@linux.intel.com \
    --cc=acme@kernel.org \
    --cc=irogers@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=marcan@marcan.st \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).