Skip to content

Commit 1227942

Browse files
Jin Yaoacmel
authored andcommitted
perf stat: Uniquify hybrid event name
It would be useful to let user know the pmu which the event belongs to. perf-stat has supported '--no-merge' option and it can print the pmu name after the event name, such as: "cycles [cpu_core]" Now this option is enabled by default for hybrid platform but change the format to: "cpu_core/cycles/" If user configs the name, we still use the user specified name. Signed-off-by: Jin Yao <yao.jin@linux.intel.com> Reviewed-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Kan Liang <kan.liang@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> ink: https://lore.kernel.org/r/20210427070139.25256-8-yao.jin@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent c5a26ea commit 1227942

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

tools/perf/builtin-stat.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#include "util/pfm.h"
7070
#include "util/bpf_counter.h"
7171
#include "util/iostat.h"
72+
#include "util/pmu-hybrid.h"
7273
#include "asm/bug.h"
7374

7475
#include <linux/time64.h>
@@ -2402,6 +2403,9 @@ int cmd_stat(int argc, const char **argv)
24022403

24032404
evlist__check_cpu_maps(evsel_list);
24042405

2406+
if (perf_pmu__has_hybrid())
2407+
stat_config.no_merge = true;
2408+
24052409
/*
24062410
* Initialize thread_map with comm names,
24072411
* so we could print it out on output.

tools/perf/util/evsel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ struct evsel {
116116
bool merged_stat;
117117
bool reset_group;
118118
bool errored;
119+
bool use_config_name;
119120
struct hashmap *per_pkg_mask;
120121
struct evsel *leader;
121122
struct list_head config_terms;

tools/perf/util/parse-events.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,6 +1567,9 @@ int parse_events_add_pmu(struct parse_events_state *parse_state,
15671567
if (!evsel)
15681568
return -ENOMEM;
15691569

1570+
if (evsel->name)
1571+
evsel->use_config_name = true;
1572+
15701573
evsel->pmu_name = name ? strdup(name) : NULL;
15711574
evsel->use_uncore_alias = use_uncore_alias;
15721575
evsel->percore = config_term_percore(&evsel->config_terms);

tools/perf/util/stat-display.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <api/fs/fs.h>
1919
#include "util.h"
2020
#include "iostat.h"
21+
#include "pmu-hybrid.h"
2122

2223
#define CNTR_NOT_SUPPORTED "<not supported>"
2324
#define CNTR_NOT_COUNTED "<not counted>"
@@ -538,6 +539,7 @@ static void uniquify_event_name(struct evsel *counter)
538539
{
539540
char *new_name;
540541
char *config;
542+
int ret = 0;
541543

542544
if (counter->uniquified_name ||
543545
!counter->pmu_name || !strncmp(counter->name, counter->pmu_name,
@@ -552,8 +554,17 @@ static void uniquify_event_name(struct evsel *counter)
552554
counter->name = new_name;
553555
}
554556
} else {
555-
if (asprintf(&new_name,
556-
"%s [%s]", counter->name, counter->pmu_name) > 0) {
557+
if (perf_pmu__has_hybrid()) {
558+
if (!counter->use_config_name) {
559+
ret = asprintf(&new_name, "%s/%s/",
560+
counter->pmu_name, counter->name);
561+
}
562+
} else {
563+
ret = asprintf(&new_name, "%s [%s]",
564+
counter->name, counter->pmu_name);
565+
}
566+
567+
if (ret) {
557568
free(counter->name);
558569
counter->name = new_name;
559570
}

0 commit comments

Comments
 (0)