Messages in this thread Patch in this message | | | From | kan.liang@linux ... | Subject | [PATCH] perf evlist: Move the modifier after the slash when rename a hybrid event | Date | Fri, 15 Dec 2023 09:54:55 -0800 |
| |
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
| |