Skip to content

Commit d06593a

Browse files
captain5050namhyung
authored andcommitted
perf pmu: Remove a hard coded cpu PMU assumption
The property of "cpu" when it has no cpu map is true on S390 with the PMU cpum_cf. Rather than maintain a list of such PMUs, reuse the is_core test result from the caller. Signed-off-by: Ian Rogers <[email protected]> Tested-by: Thomas Richter <[email protected]> Cc: Ravi Bangoria <[email protected]> Cc: James Clark <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Kan Liang <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent d685819 commit d06593a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tools/perf/util/pmu.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ static int pmu_alias_terms(struct perf_pmu_alias *alias,
551551
* Uncore PMUs have a "cpumask" file under sysfs. CPU PMUs (e.g. on arm/arm64)
552552
* may have a "cpus" file.
553553
*/
554-
static struct perf_cpu_map *pmu_cpumask(int dirfd, const char *name)
554+
static struct perf_cpu_map *pmu_cpumask(int dirfd, const char *name, bool is_core)
555555
{
556556
struct perf_cpu_map *cpus;
557557
const char *templates[] = {
@@ -575,7 +575,8 @@ static struct perf_cpu_map *pmu_cpumask(int dirfd, const char *name)
575575
return cpus;
576576
}
577577

578-
return !strcmp(name, "cpu") ? perf_cpu_map__get(cpu_map__online()) : NULL;
578+
/* Nothing found, for core PMUs assume this means all CPUs. */
579+
return is_core ? perf_cpu_map__get(cpu_map__online()) : NULL;
579580
}
580581

581582
static bool pmu_is_uncore(int dirfd, const char *name)
@@ -886,7 +887,8 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char
886887
if (!pmu)
887888
return NULL;
888889

889-
pmu->cpus = pmu_cpumask(dirfd, name);
890+
pmu->is_core = is_pmu_core(name);
891+
pmu->cpus = pmu_cpumask(dirfd, name, pmu->is_core);
890892
pmu->name = strdup(name);
891893
if (!pmu->name)
892894
goto err;
@@ -903,7 +905,6 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char
903905
}
904906

905907
pmu->type = type;
906-
pmu->is_core = is_pmu_core(name);
907908
pmu->is_uncore = pmu_is_uncore(dirfd, name);
908909
if (pmu->is_uncore)
909910
pmu->id = pmu_id(name);

0 commit comments

Comments
 (0)