Skip to content

Commit

Permalink
perf pmu: Save pmu name
Browse files Browse the repository at this point in the history
On hybrid platform, one event is available on one pmu
(such as, available on cpu_core or on cpu_atom).

This patch saves the pmu name to the pmu field of struct perf_pmu_alias.
Then next we can know the pmu which the event can be enabled on.

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>
Link: https://lore.kernel.org/r/20210427070139.25256-5-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Jin Yao authored and Arnaldo Carvalho de Melo committed Apr 29, 2021
1 parent eab3595 commit 32705de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tools/perf/util/pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ void perf_pmu_free_alias(struct perf_pmu_alias *newalias)
zfree(&newalias->str);
zfree(&newalias->metric_expr);
zfree(&newalias->metric_name);
zfree(&newalias->pmu_name);
parse_events_terms__purge(&newalias->terms);
free(newalias);
}
Expand All @@ -297,6 +298,10 @@ static bool perf_pmu_merge_alias(struct perf_pmu_alias *newalias,

list_for_each_entry(a, alist, list) {
if (!strcasecmp(newalias->name, a->name)) {
if (newalias->pmu_name && a->pmu_name &&
!strcasecmp(newalias->pmu_name, a->pmu_name)) {
continue;
}
perf_pmu_update_alias(a, newalias);
perf_pmu_free_alias(newalias);
return true;
Expand All @@ -314,7 +319,8 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
int num;
char newval[256];
char *long_desc = NULL, *topic = NULL, *unit = NULL, *perpkg = NULL,
*metric_expr = NULL, *metric_name = NULL, *deprecated = NULL;
*metric_expr = NULL, *metric_name = NULL, *deprecated = NULL,
*pmu_name = NULL;

if (pe) {
long_desc = (char *)pe->long_desc;
Expand All @@ -324,6 +330,7 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
metric_expr = (char *)pe->metric_expr;
metric_name = (char *)pe->metric_name;
deprecated = (char *)pe->deprecated;
pmu_name = (char *)pe->pmu;
}

alias = malloc(sizeof(*alias));
Expand Down Expand Up @@ -389,6 +396,7 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
}
alias->per_pkg = perpkg && sscanf(perpkg, "%d", &num) == 1 && num == 1;
alias->str = strdup(newval);
alias->pmu_name = pmu_name ? strdup(pmu_name) : NULL;

if (deprecated)
alias->deprecated = true;
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/pmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct perf_pmu_alias {
bool deprecated;
char *metric_expr;
char *metric_name;
char *pmu_name;
};

struct perf_pmu *perf_pmu__find(const char *name);
Expand Down

0 comments on commit 32705de

Please sign in to comment.