Skip to content

Commit 105e5b4

Browse files
James-A-Clarknamhyung
authored andcommitted
perf pmus: Simplify perf_pmus__find_core_pmu()
Currently the while loop always either exits on the first iteration with a core PMU, or exits with NULL on heterogeneous systems or when not all CPUs are online. Both of the latter behaviors are undesirable for platforms other than Arm so simplify it to always return the first core PMU, or NULL if none exist. This behavior was depended on by the Arm version of pmu_metrics_table__find(), so the logic has been moved there instead. Signed-off-by: James Clark <[email protected]> Suggested-by: Ian Rogers <[email protected]> Reviewed-by: Ian Rogers <[email protected]> Reviewed-by: John Garry <[email protected]> Cc: Ravi Bangoria <[email protected]> Cc: Eduard Zingerman <[email protected]> Cc: Will Deacon <[email protected]> Cc: Leo Yan <[email protected]> Cc: Mike Leach <[email protected]> Cc: Jing Zhang <[email protected]> Cc: Haixin Yu <[email protected]> Cc: Kan Liang <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 3d0f5f4 commit 105e5b4

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

tools/perf/arch/arm64/util/pmu.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@
1010

1111
const struct pmu_metrics_table *pmu_metrics_table__find(void)
1212
{
13-
struct perf_pmu *pmu = perf_pmus__find_core_pmu();
13+
struct perf_pmu *pmu;
14+
15+
/* Metrics aren't currently supported on heterogeneous Arm systems */
16+
if (perf_pmus__num_core_pmus() > 1)
17+
return NULL;
1418

19+
/* Doesn't matter which one here because they'll all be the same */
20+
pmu = perf_pmus__find_core_pmu();
1521
if (pmu)
1622
return perf_pmu__find_metrics_table(pmu);
1723

tools/perf/util/pmus.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -596,17 +596,5 @@ struct perf_pmu *evsel__find_pmu(const struct evsel *evsel)
596596

597597
struct perf_pmu *perf_pmus__find_core_pmu(void)
598598
{
599-
struct perf_pmu *pmu = NULL;
600-
601-
while ((pmu = perf_pmus__scan_core(pmu))) {
602-
/*
603-
* The cpumap should cover all CPUs. Otherwise, some CPUs may
604-
* not support some events or have different event IDs.
605-
*/
606-
if (RC_CHK_ACCESS(pmu->cpus)->nr != cpu__max_cpu().cpu)
607-
return NULL;
608-
609-
return pmu;
610-
}
611-
return NULL;
599+
return perf_pmus__scan_core(NULL);
612600
}

0 commit comments

Comments
 (0)