Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf top: Uniform the event name for the hybrid machine

It's hard to distinguish the default cycles events among hybrid PMUs.
For example,

$ perf top
Available samples
385 cycles:P
903 cycles:P

The other tool, e.g., perf record, uniforms the event name and adds the
hybrid PMU name before opening the event. So the events can be easily
distinguished. Apply the same methodology for the perf top as well.

The evlist__uniquify_name() will be invoked by both record and top.
Move it to util/evlist.c

With the patch:

$ perf top
Available samples
148 cpu_atom/cycles:P/
1K cpu_core/cycles:P/

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Hector Martin <marcan@marcan.st>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20231214144612.1092028-2-kan.liang@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Kan Liang and committed by
Arnaldo Carvalho de Melo
a61f89bf 5fa695e7

+28 -27
+1 -27
tools/perf/builtin-record.c
··· 2237 2237 } 2238 2238 } 2239 2239 2240 - static void record__uniquify_name(struct record *rec) 2241 - { 2242 - struct evsel *pos; 2243 - struct evlist *evlist = rec->evlist; 2244 - char *new_name; 2245 - int ret; 2246 - 2247 - if (perf_pmus__num_core_pmus() == 1) 2248 - return; 2249 - 2250 - evlist__for_each_entry(evlist, pos) { 2251 - if (!evsel__is_hybrid(pos)) 2252 - continue; 2253 - 2254 - if (strchr(pos->name, '/')) 2255 - continue; 2256 - 2257 - ret = asprintf(&new_name, "%s/%s/", 2258 - pos->pmu_name, pos->name); 2259 - if (ret) { 2260 - free(pos->name); 2261 - pos->name = new_name; 2262 - } 2263 - } 2264 - } 2265 - 2266 2240 static int record__terminate_thread(struct record_thread *thread_data) 2267 2241 { 2268 2242 int err; ··· 2470 2496 if (data->is_pipe && rec->evlist->core.nr_entries == 1) 2471 2497 rec->opts.sample_id = true; 2472 2498 2473 - record__uniquify_name(rec); 2499 + evlist__uniquify_name(rec->evlist); 2474 2500 2475 2501 /* Debug message used by test scripts */ 2476 2502 pr_debug3("perf record opening and mmapping events\n");
+1
tools/perf/builtin-top.c
··· 1298 1298 } 1299 1299 } 1300 1300 1301 + evlist__uniquify_name(top->evlist); 1301 1302 ret = perf_top__start_counters(top); 1302 1303 if (ret) 1303 1304 return ret;
+25
tools/perf/util/evlist.c
··· 2518 2518 } 2519 2519 perf_cpu_map__put(user_requested_cpus); 2520 2520 } 2521 + 2522 + void evlist__uniquify_name(struct evlist *evlist) 2523 + { 2524 + struct evsel *pos; 2525 + char *new_name; 2526 + int ret; 2527 + 2528 + if (perf_pmus__num_core_pmus() == 1) 2529 + return; 2530 + 2531 + evlist__for_each_entry(evlist, pos) { 2532 + if (!evsel__is_hybrid(pos)) 2533 + continue; 2534 + 2535 + if (strchr(pos->name, '/')) 2536 + continue; 2537 + 2538 + ret = asprintf(&new_name, "%s/%s/", 2539 + pos->pmu_name, pos->name); 2540 + if (ret) { 2541 + free(pos->name); 2542 + pos->name = new_name; 2543 + } 2544 + } 2545 + }
+1
tools/perf/util/evlist.h
··· 442 442 int evlist__scnprintf_evsels(struct evlist *evlist, size_t size, char *bf); 443 443 void evlist__check_mem_load_aux(struct evlist *evlist); 444 444 void evlist__warn_user_requested_cpus(struct evlist *evlist, const char *cpu_list); 445 + void evlist__uniquify_name(struct evlist *evlist); 445 446 446 447 #endif /* __PERF_EVLIST_H */