1 // SPDX-License-Identifier: GPL-2.0
3 #include <internal/cpumap.h>
4 #include "../../../util/cpumap.h"
5 #include "../../../util/pmu.h"
9 static struct perf_pmu *pmu__find_core_pmu(void)
11 struct perf_pmu *pmu = NULL;
13 while ((pmu = perf_pmu__scan(pmu))) {
14 if (!is_pmu_core(pmu->name))
18 * The cpumap should cover all CPUs. Otherwise, some CPUs may
19 * not support some events or have different event IDs.
21 if (pmu->cpus->nr != cpu__max_cpu().cpu)
30 const struct pmu_events_table *pmu_events_table__find(void)
32 struct perf_pmu *pmu = pmu__find_core_pmu();
35 return perf_pmu__find_table(pmu);
40 double perf_pmu__cpu_slots_per_cycle(void)
43 unsigned long long slots = 0;
44 struct perf_pmu *pmu = pmu__find_core_pmu();
47 perf_pmu__pathname_scnprintf(path, sizeof(path),
48 pmu->name, "caps/slots");
50 * The value of slots is not greater than 32 bits, but sysfs__read_int
51 * can't read value with 0x prefix, so use sysfs__read_ull instead.
53 sysfs__read_ull(path, &slots);
56 return slots ? (double)slots : NAN;