1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LIBPERF_INTERNAL_CPUMAP_H
3 #define __LIBPERF_INTERNAL_CPUMAP_H
4 
5 #include <linux/refcount.h>
6 #include <perf/cpumap.h>
7 
8 /**
9  * A sized, reference counted, sorted array of integers representing CPU
10  * numbers. This is commonly used to capture which CPUs a PMU is associated
11  * with. The indices into the cpumap are frequently used as they avoid having
12  * gaps if CPU numbers were used. For events associated with a pid, rather than
13  * a CPU, a single dummy map with an entry of -1 is used.
14  */
15 struct perf_cpu_map {
16 	refcount_t	refcnt;
17 	/** Length of the map array. */
18 	int		nr;
19 	/** The CPU values. */
20 	struct perf_cpu	map[];
21 };
22 
23 #ifndef MAX_NR_CPUS
24 #define MAX_NR_CPUS	2048
25 #endif
26 
27 int perf_cpu_map__idx(const struct perf_cpu_map *cpus, struct perf_cpu cpu);
28 bool perf_cpu_map__is_subset(const struct perf_cpu_map *a, const struct perf_cpu_map *b);
29 
30 #endif /* __LIBPERF_INTERNAL_CPUMAP_H */
31