[PATCH 1/1] perf evlist: Move event attributes to after the / when uniquefying using the PMU name

From: Arnaldo Carvalho de Melo
Date: Fri Dec 15 2023 - 13:23:30 EST


Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/util/evlist.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 6f0892803c2249af..3a9505c99490b372 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -2522,7 +2522,7 @@ void evlist__warn_user_requested_cpus(struct evlist *evlist, const char *cpu_lis
void evlist__uniquify_name(struct evlist *evlist)
{
struct evsel *pos;
- char *new_name;
+ char *new_name, *attributes;
int ret;

if (perf_pmus__num_core_pmus() == 1)
@@ -2535,8 +2535,16 @@ void evlist__uniquify_name(struct evlist *evlist)
if (strchr(pos->name, '/'))
continue;

- ret = asprintf(&new_name, "%s/%s/",
- pos->pmu_name, pos->name);
+ attributes = strchr(pos->name, ':');
+ if (attributes)
+ *attributes = '\0';
+
+ ret = asprintf(&new_name, "%s/%s/%s",
+ pos->pmu_name, pos->name, attributes ? attributes + 1 : "");
+
+ if (attributes)
+ *attributes = ':';
+
if (ret) {
free(pos->name);
pos->name = new_name;
--
2.43.0