Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <irogers@google.com>
Tested-by: Thomas Richter <tmricht@linux.ibm.com>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: James Clark <james.clark@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: linux-kernel@vger.kernel.org
Cc: linux-perf-users@vger.kernel.org
Link: https://lore.kernel.org/r/20230623043843.4080180-2-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
d06593aa d685819b

+5 -4
+5 -4
tools/perf/util/pmu.c
··· 551 551 * Uncore PMUs have a "cpumask" file under sysfs. CPU PMUs (e.g. on arm/arm64) 552 552 * may have a "cpus" file. 553 553 */ 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) 555 555 { 556 556 struct perf_cpu_map *cpus; 557 557 const char *templates[] = { ··· 575 575 return cpus; 576 576 } 577 577 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; 579 580 } 580 581 581 582 static bool pmu_is_uncore(int dirfd, const char *name) ··· 887 886 if (!pmu) 888 887 return NULL; 889 888 890 - pmu->cpus = pmu_cpumask(dirfd, name); 889 + pmu->is_core = is_pmu_core(name); 890 + pmu->cpus = pmu_cpumask(dirfd, name, pmu->is_core); 891 891 pmu->name = strdup(name); 892 892 if (!pmu->name) 893 893 goto err; ··· 905 903 } 906 904 907 905 pmu->type = type; 908 - pmu->is_core = is_pmu_core(name); 909 906 pmu->is_uncore = pmu_is_uncore(dirfd, name); 910 907 if (pmu->is_uncore) 911 908 pmu->id = pmu_id(name);