xref: /linux/tools/perf/arch/arm64/util/pmu.c (revision e3b2949e3fa2fd8c19cd5fbb0424d38f70a70e9c)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <internal/cpumap.h>
4 #include "../../../util/cpumap.h"
5 #include "../../../util/header.h"
6 #include "../../../util/pmu.h"
7 #include "../../../util/pmus.h"
8 #include "../../../util/tool_pmu.h"
9 #include <api/fs/fs.h>
10 #include <math.h>
11 
12 const struct pmu_metrics_table *pmu_metrics_table__find(void)
13 {
14 	struct perf_pmu *pmu;
15 
16 	/* Metrics aren't currently supported on heterogeneous Arm systems */
17 	if (perf_pmus__num_core_pmus() > 1)
18 		return NULL;
19 
20 	/* Doesn't matter which one here because they'll all be the same */
21 	pmu = perf_pmus__find_core_pmu();
22 	if (pmu)
23 		return perf_pmu__find_metrics_table(pmu);
24 
25 	return NULL;
26 }
27 
28 u64 tool_pmu__cpu_slots_per_cycle(void)
29 {
30 	char path[PATH_MAX];
31 	unsigned long long slots = 0;
32 	struct perf_pmu *pmu = perf_pmus__find_core_pmu();
33 
34 	if (pmu) {
35 		perf_pmu__pathname_scnprintf(path, sizeof(path),
36 					     pmu->name, "caps/slots");
37 		/*
38 		 * The value of slots is not greater than 32 bits, but
39 		 * filename__read_int can't read value with 0x prefix,
40 		 * so use filename__read_ull instead.
41 		 */
42 		filename__read_ull(path, &slots);
43 	}
44 
45 	return slots;
46 }
47