Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v6.4-rc1 144 lines 5.2 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef __PERF_CPUMAP_H 3#define __PERF_CPUMAP_H 4 5#include <stdbool.h> 6#include <stdio.h> 7#include <perf/cpumap.h> 8#include <linux/refcount.h> 9 10/** Identify where counts are aggregated, -1 implies not to aggregate. */ 11struct aggr_cpu_id { 12 /** A value in the range 0 to number of threads. */ 13 int thread_idx; 14 /** The numa node X as read from /sys/devices/system/node/nodeX. */ 15 int node; 16 /** 17 * The socket number as read from 18 * /sys/devices/system/cpu/cpuX/topology/physical_package_id. 19 */ 20 int socket; 21 /** The die id as read from /sys/devices/system/cpu/cpuX/topology/die_id. */ 22 int die; 23 /** The core id as read from /sys/devices/system/cpu/cpuX/topology/core_id. */ 24 int core; 25 /** CPU aggregation, note there is one CPU for each SMT thread. */ 26 struct perf_cpu cpu; 27}; 28 29/** A collection of aggr_cpu_id values, the "built" version is sorted and uniqued. */ 30struct cpu_aggr_map { 31 refcount_t refcnt; 32 /** Number of valid entries. */ 33 int nr; 34 /** The entries. */ 35 struct aggr_cpu_id map[]; 36}; 37 38#define cpu_aggr_map__for_each_idx(idx, aggr_map) \ 39 for ((idx) = 0; (idx) < aggr_map->nr; (idx)++) 40 41struct perf_record_cpu_map_data; 42 43bool perf_record_cpu_map_data__test_bit(int i, const struct perf_record_cpu_map_data *data); 44 45struct perf_cpu_map *perf_cpu_map__empty_new(int nr); 46 47struct perf_cpu_map *cpu_map__new_data(const struct perf_record_cpu_map_data *data); 48size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size); 49size_t cpu_map__snprint_mask(struct perf_cpu_map *map, char *buf, size_t size); 50size_t cpu_map__fprintf(struct perf_cpu_map *map, FILE *fp); 51const struct perf_cpu_map *cpu_map__online(void); /* thread unsafe */ 52 53int cpu__setup_cpunode_map(void); 54 55int cpu__max_node(void); 56struct perf_cpu cpu__max_cpu(void); 57struct perf_cpu cpu__max_present_cpu(void); 58 59/** 60 * cpu_map__is_dummy - Events associated with a pid, rather than a CPU, use a single dummy map with an entry of -1. 61 */ 62static inline bool cpu_map__is_dummy(struct perf_cpu_map *cpus) 63{ 64 return perf_cpu_map__nr(cpus) == 1 && perf_cpu_map__cpu(cpus, 0).cpu == -1; 65} 66 67/** 68 * cpu__get_node - Returns the numa node X as read from 69 * /sys/devices/system/node/nodeX for the given CPU. 70 */ 71int cpu__get_node(struct perf_cpu cpu); 72/** 73 * cpu__get_socket_id - Returns the socket number as read from 74 * /sys/devices/system/cpu/cpuX/topology/physical_package_id for the given CPU. 75 */ 76int cpu__get_socket_id(struct perf_cpu cpu); 77/** 78 * cpu__get_die_id - Returns the die id as read from 79 * /sys/devices/system/cpu/cpuX/topology/die_id for the given CPU. 80 */ 81int cpu__get_die_id(struct perf_cpu cpu); 82/** 83 * cpu__get_core_id - Returns the core id as read from 84 * /sys/devices/system/cpu/cpuX/topology/core_id for the given CPU. 85 */ 86int cpu__get_core_id(struct perf_cpu cpu); 87 88/** 89 * cpu_aggr_map__empty_new - Create a cpu_aggr_map of size nr with every entry 90 * being empty. 91 */ 92struct cpu_aggr_map *cpu_aggr_map__empty_new(int nr); 93 94typedef struct aggr_cpu_id (*aggr_cpu_id_get_t)(struct perf_cpu cpu, void *data); 95 96/** 97 * cpu_aggr_map__new - Create a cpu_aggr_map with an aggr_cpu_id for each cpu in 98 * cpus. The aggr_cpu_id is created with 'get_id' that may have a data value 99 * passed to it. The cpu_aggr_map is sorted with duplicate values removed. 100 */ 101struct cpu_aggr_map *cpu_aggr_map__new(const struct perf_cpu_map *cpus, 102 aggr_cpu_id_get_t get_id, 103 void *data, bool needs_sort); 104 105bool aggr_cpu_id__equal(const struct aggr_cpu_id *a, const struct aggr_cpu_id *b); 106bool aggr_cpu_id__is_empty(const struct aggr_cpu_id *a); 107struct aggr_cpu_id aggr_cpu_id__empty(void); 108 109 110/** 111 * aggr_cpu_id__socket - Create an aggr_cpu_id with the socket populated with 112 * the socket for cpu. The function signature is compatible with 113 * aggr_cpu_id_get_t. 114 */ 115struct aggr_cpu_id aggr_cpu_id__socket(struct perf_cpu cpu, void *data); 116/** 117 * aggr_cpu_id__die - Create an aggr_cpu_id with the die and socket populated 118 * with the die and socket for cpu. The function signature is compatible with 119 * aggr_cpu_id_get_t. 120 */ 121struct aggr_cpu_id aggr_cpu_id__die(struct perf_cpu cpu, void *data); 122/** 123 * aggr_cpu_id__core - Create an aggr_cpu_id with the core, die and socket 124 * populated with the core, die and socket for cpu. The function signature is 125 * compatible with aggr_cpu_id_get_t. 126 */ 127struct aggr_cpu_id aggr_cpu_id__core(struct perf_cpu cpu, void *data); 128/** 129 * aggr_cpu_id__core - Create an aggr_cpu_id with the cpu, core, die and socket 130 * populated with the cpu, core, die and socket for cpu. The function signature 131 * is compatible with aggr_cpu_id_get_t. 132 */ 133struct aggr_cpu_id aggr_cpu_id__cpu(struct perf_cpu cpu, void *data); 134/** 135 * aggr_cpu_id__node - Create an aggr_cpu_id with the numa node populated for 136 * cpu. The function signature is compatible with aggr_cpu_id_get_t. 137 */ 138struct aggr_cpu_id aggr_cpu_id__node(struct perf_cpu cpu, void *data); 139/** 140 * aggr_cpu_id__global - Create an aggr_cpu_id for global aggregation. 141 * The function signature is compatible with aggr_cpu_id_get_t. 142 */ 143struct aggr_cpu_id aggr_cpu_id__global(struct perf_cpu cpu, void *data); 144#endif /* __PERF_CPUMAP_H */