]> Git Repo - linux.git/commitdiff
perf pmu: Remove a hard coded cpu PMU assumption
authorIan Rogers <[email protected]>
Fri, 23 Jun 2023 04:38:43 +0000 (21:38 -0700)
committerNamhyung Kim <[email protected]>
Fri, 23 Jun 2023 05:14:58 +0000 (22:14 -0700)
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]>
tools/perf/util/pmu.c

index 963c12f910c5dceb7ae00c767129353aabb54dd0..64fa568a54267ea409bb97e53fbe2aebc0298cb7 100644 (file)
@@ -551,7 +551,7 @@ static int pmu_alias_terms(struct perf_pmu_alias *alias,
  * Uncore PMUs have a "cpumask" file under sysfs. CPU PMUs (e.g. on arm/arm64)
  * may have a "cpus" file.
  */
-static struct perf_cpu_map *pmu_cpumask(int dirfd, const char *name)
+static struct perf_cpu_map *pmu_cpumask(int dirfd, const char *name, bool is_core)
 {
        struct perf_cpu_map *cpus;
        const char *templates[] = {
@@ -575,7 +575,8 @@ static struct perf_cpu_map *pmu_cpumask(int dirfd, const char *name)
                        return cpus;
        }
 
-       return !strcmp(name, "cpu") ? perf_cpu_map__get(cpu_map__online()) : NULL;
+       /* Nothing found, for core PMUs assume this means all CPUs. */
+       return is_core ? perf_cpu_map__get(cpu_map__online()) : NULL;
 }
 
 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
        if (!pmu)
                return NULL;
 
-       pmu->cpus = pmu_cpumask(dirfd, name);
+       pmu->is_core = is_pmu_core(name);
+       pmu->cpus = pmu_cpumask(dirfd, name, pmu->is_core);
        pmu->name = strdup(name);
        if (!pmu->name)
                goto err;
@@ -903,7 +905,6 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char
        }
 
        pmu->type = type;
-       pmu->is_core = is_pmu_core(name);
        pmu->is_uncore = pmu_is_uncore(dirfd, name);
        if (pmu->is_uncore)
                pmu->id = pmu_id(name);
This page took 0.06307 seconds and 4 git commands to generate.