Commit 12279429 authored by Jin Yao's avatar Jin Yao Committed by Arnaldo Carvalho de Melo

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: default avatarJin Yao <yao.jin@linux.intel.com>
Reviewed-by: default avatarJiri 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.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent c5a26ea4
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
#include "util/pfm.h" #include "util/pfm.h"
#include "util/bpf_counter.h" #include "util/bpf_counter.h"
#include "util/iostat.h" #include "util/iostat.h"
#include "util/pmu-hybrid.h"
#include "asm/bug.h" #include "asm/bug.h"
#include <linux/time64.h> #include <linux/time64.h>
...@@ -2402,6 +2403,9 @@ int cmd_stat(int argc, const char **argv) ...@@ -2402,6 +2403,9 @@ int cmd_stat(int argc, const char **argv)
evlist__check_cpu_maps(evsel_list); evlist__check_cpu_maps(evsel_list);
if (perf_pmu__has_hybrid())
stat_config.no_merge = true;
/* /*
* Initialize thread_map with comm names, * Initialize thread_map with comm names,
* so we could print it out on output. * so we could print it out on output.
......
...@@ -116,6 +116,7 @@ struct evsel { ...@@ -116,6 +116,7 @@ struct evsel {
bool merged_stat; bool merged_stat;
bool reset_group; bool reset_group;
bool errored; bool errored;
bool use_config_name;
struct hashmap *per_pkg_mask; struct hashmap *per_pkg_mask;
struct evsel *leader; struct evsel *leader;
struct list_head config_terms; struct list_head config_terms;
......
...@@ -1567,6 +1567,9 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, ...@@ -1567,6 +1567,9 @@ int parse_events_add_pmu(struct parse_events_state *parse_state,
if (!evsel) if (!evsel)
return -ENOMEM; return -ENOMEM;
if (evsel->name)
evsel->use_config_name = true;
evsel->pmu_name = name ? strdup(name) : NULL; evsel->pmu_name = name ? strdup(name) : NULL;
evsel->use_uncore_alias = use_uncore_alias; evsel->use_uncore_alias = use_uncore_alias;
evsel->percore = config_term_percore(&evsel->config_terms); evsel->percore = config_term_percore(&evsel->config_terms);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <api/fs/fs.h> #include <api/fs/fs.h>
#include "util.h" #include "util.h"
#include "iostat.h" #include "iostat.h"
#include "pmu-hybrid.h"
#define CNTR_NOT_SUPPORTED "<not supported>" #define CNTR_NOT_SUPPORTED "<not supported>"
#define CNTR_NOT_COUNTED "<not counted>" #define CNTR_NOT_COUNTED "<not counted>"
...@@ -538,6 +539,7 @@ static void uniquify_event_name(struct evsel *counter) ...@@ -538,6 +539,7 @@ static void uniquify_event_name(struct evsel *counter)
{ {
char *new_name; char *new_name;
char *config; char *config;
int ret = 0;
if (counter->uniquified_name || if (counter->uniquified_name ||
!counter->pmu_name || !strncmp(counter->name, counter->pmu_name, !counter->pmu_name || !strncmp(counter->name, counter->pmu_name,
...@@ -552,8 +554,17 @@ static void uniquify_event_name(struct evsel *counter) ...@@ -552,8 +554,17 @@ static void uniquify_event_name(struct evsel *counter)
counter->name = new_name; counter->name = new_name;
} }
} else { } else {
if (asprintf(&new_name, if (perf_pmu__has_hybrid()) {
"%s [%s]", counter->name, counter->pmu_name) > 0) { if (!counter->use_config_name) {
ret = asprintf(&new_name, "%s/%s/",
counter->pmu_name, counter->name);
}
} else {
ret = asprintf(&new_name, "%s [%s]",
counter->name, counter->pmu_name);
}
if (ret) {
free(counter->name); free(counter->name);
counter->name = new_name; counter->name = new_name;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment