39 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2#ifndef __LIBPERF_INTERNAL_CPUMAP_H3#define __LIBPERF_INTERNAL_CPUMAP_H4 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 CPU11 * numbers. This is commonly used to capture which CPUs a PMU is associated12 * with. The indices into the cpumap are frequently used as they avoid having13 * gaps if CPU numbers were used. For events associated with a pid, rather than14 * a CPU, a single dummy map with an entry of -1 is used.15 */16DECLARE_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#ifndef MAX_NR_CPUS25#define MAX_NR_CPUS 204826#endif27 28struct perf_cpu_map *perf_cpu_map__alloc(int nr_cpus);29int perf_cpu_map__idx(const struct perf_cpu_map *cpus, struct perf_cpu cpu);30bool perf_cpu_map__is_subset(const struct perf_cpu_map *a, const struct perf_cpu_map *b);31 32void perf_cpu_map__set_nr(struct perf_cpu_map *map, int nr_cpus);33 34static inline refcount_t *perf_cpu_map__refcnt(struct perf_cpu_map *map)35{36 return &RC_CHK_ACCESS(map)->refcnt;37}38#endif /* __LIBPERF_INTERNAL_CPUMAP_H */39