1 // SPDX-License-Identifier: GPL-2.0
3 #include <internal/cpumap.h>
4 #include "../../../util/cpumap.h"
5 #include "../../../util/pmu.h"
6 #include "../../../util/pmus.h"
10 static struct perf_pmu *pmu__find_core_pmu(void)
12 struct perf_pmu *pmu = NULL;
14 while ((pmu = perf_pmus__scan_core(pmu))) {
16 * The cpumap should cover all CPUs. Otherwise, some CPUs may
17 * not support some events or have different event IDs.
19 if (RC_CHK_ACCESS(pmu->cpus)->nr != cpu__max_cpu().cpu)
27 const struct pmu_metrics_table *pmu_metrics_table__find(void)
29 struct perf_pmu *pmu = pmu__find_core_pmu();
32 return perf_pmu__find_metrics_table(pmu);
37 const struct pmu_events_table *pmu_events_table__find(void)
39 struct perf_pmu *pmu = pmu__find_core_pmu();
42 return perf_pmu__find_events_table(pmu);
47 double perf_pmu__cpu_slots_per_cycle(void)
50 unsigned long long slots = 0;
51 struct perf_pmu *pmu = pmu__find_core_pmu();
54 perf_pmu__pathname_scnprintf(path, sizeof(path),
55 pmu->name, "caps/slots");
57 * The value of slots is not greater than 32 bits, but
58 * filename__read_int can't read value with 0x prefix,
59 * so use filename__read_ull instead.
61 filename__read_ull(path, &slots);
64 return slots ? (double)slots : NAN;