Commit 4bf7e81a authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf pmu: Detect ARM and hybrid PMUs with sysfs

is_arm_pmu_core detects a core PMU via the presence of a "cpus" file
rather than a "cpumask" file. This pattern holds for hybrid PMUs so
rename the function and remove redundant perf_pmu__is_hybrid
tests.

Add a new helper is_pmu_hybrid similar to is_pmu_core.
Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ali Saidi <alisaidi@amazon.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kang Minchul <tegongkang@gmail.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Ming Wang <wangming01@loongson.cn>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230527072210.2900565-5-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 916ce34a
......@@ -643,12 +643,14 @@ static char *pmu_id(const char *name)
return str;
}
/*
* PMU CORE devices have different name other than cpu in sysfs on some
* platforms.
* Looking for possible sysfs files to identify the arm core device.
/**
* is_sysfs_pmu_core() - PMU CORE devices have different name other than cpu in
* sysfs on some platforms like ARM or Intel hybrid. Looking for
* possible the cpus file in sysfs files to identify whether this is a
* core device.
* @name: The PMU name such as "cpu_atom".
*/
static int is_arm_pmu_core(const char *name)
static int is_sysfs_pmu_core(const char *name)
{
char path[PATH_MAX];
......@@ -814,7 +816,7 @@ void pmu_add_cpu_aliases_table(struct list_head *head, struct perf_pmu *pmu,
struct pmu_add_cpu_aliases_map_data data = {
.head = head,
.name = pmu->name,
.cpu_name = is_arm_pmu_core(pmu->name) ? pmu->name : "cpu",
.cpu_name = is_sysfs_pmu_core(pmu->name) ? pmu->name : "cpu",
.pmu = pmu,
};
......@@ -1647,22 +1649,27 @@ static int cmp_sevent(const void *a, const void *b)
bool is_pmu_core(const char *name)
{
return !strcmp(name, "cpu") || is_arm_pmu_core(name);
return !strcmp(name, "cpu") || is_sysfs_pmu_core(name);
}
bool is_pmu_hybrid(const char *name)
{
return !strcmp(name, "cpu_atom") || !strcmp(name, "cpu_core");
}
bool perf_pmu__supports_legacy_cache(const struct perf_pmu *pmu)
{
return is_pmu_core(pmu->name) || perf_pmu__is_hybrid(pmu->name);
return is_pmu_core(pmu->name);
}
bool perf_pmu__supports_wildcard_numeric(const struct perf_pmu *pmu)
{
return is_pmu_core(pmu->name) || perf_pmu__is_hybrid(pmu->name);
return is_pmu_core(pmu->name);
}
bool perf_pmu__auto_merge_stats(const struct perf_pmu *pmu)
{
return !perf_pmu__is_hybrid(pmu->name);
return !is_pmu_hybrid(pmu->name);
}
static bool pmu_alias_is_duplicate(struct sevent *alias_a,
......@@ -1716,7 +1723,7 @@ void print_pmu_events(const struct print_callbacks *print_cb, void *print_state)
pmu = NULL;
j = 0;
while ((pmu = perf_pmu__scan(pmu)) != NULL) {
bool is_cpu = is_pmu_core(pmu->name) || perf_pmu__is_hybrid(pmu->name);
bool is_cpu = is_pmu_core(pmu->name);
list_for_each_entry(event, &pmu->aliases, list) {
aliases[j].event = event;
......
......@@ -220,6 +220,7 @@ void perf_pmu__del_formats(struct list_head *formats);
struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu);
bool is_pmu_core(const char *name);
bool is_pmu_hybrid(const char *name);
bool perf_pmu__supports_legacy_cache(const struct perf_pmu *pmu);
bool perf_pmu__supports_wildcard_numeric(const struct perf_pmu *pmu);
bool perf_pmu__auto_merge_stats(const struct perf_pmu *pmu);
......
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