| 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 |
#include <internal/rc_check.h> |
| 8 |
|
| 9 |
/** |
| 10 |
* A sized, reference counted, sorted array of integers representing CPU |
| 11 |
* numbers. This is commonly used to capture which CPUs a PMU is associated |
| 12 |
* with. The indices into the cpumap are frequently used as they avoid having |
| 13 |
* gaps if CPU numbers were used. For events associated with a pid, rather than |
| 14 |
* a CPU, a single dummy map with an entry of -1 is used. |
| 15 |
*/ |
| 16 |
DECLARE_RC_STRUCT(perf_cpu_map) { |
| 17 |
refcount_t refcnt; |
| 18 |
/** Length of the map array. */ |
| 19 |
int nr; |
| 20 |
/** The CPU values. */ |
| 21 |
struct perf_cpu map[]; |
| 22 |
}; |
| 23 |
|
| 24 |
struct perf_cpu_map *perf_cpu_map__alloc(int nr_cpus); |
| 25 |
int perf_cpu_map__idx(const struct perf_cpu_map *cpus, struct perf_cpu cpu); |
| 26 |
bool perf_cpu_map__is_subset(const struct perf_cpu_map *a, const struct perf_cpu_map *b); |
| 27 |
|
| 28 |
void perf_cpu_map__set_nr(struct perf_cpu_map *map, int nr_cpus); |
| 29 |
|
| 30 |
static inline refcount_t *perf_cpu_map__refcnt(struct perf_cpu_map *map) |
| 31 |
{ |
| 32 |
return &RC_CHK_ACCESS(map)->refcnt; |
| 33 |
} |
| 34 |
#endif /* __LIBPERF_INTERNAL_CPUMAP_H */ |