0001
0002 #ifndef __PERF_CPUMAP_H
0003 #define __PERF_CPUMAP_H
0004
0005 #include <stdbool.h>
0006 #include <stdio.h>
0007 #include <internal/cpumap.h>
0008 #include <perf/cpumap.h>
0009
0010
0011 struct aggr_cpu_id {
0012
0013 int thread;
0014
0015 int node;
0016
0017
0018
0019
0020 int socket;
0021
0022 int die;
0023
0024 int core;
0025
0026 struct perf_cpu cpu;
0027 };
0028
0029
0030 struct cpu_aggr_map {
0031 refcount_t refcnt;
0032
0033 int nr;
0034
0035 struct aggr_cpu_id map[];
0036 };
0037
0038 struct perf_record_cpu_map_data;
0039
0040 bool perf_record_cpu_map_data__test_bit(int i, const struct perf_record_cpu_map_data *data);
0041
0042 struct perf_cpu_map *perf_cpu_map__empty_new(int nr);
0043
0044 struct perf_cpu_map *cpu_map__new_data(const struct perf_record_cpu_map_data *data);
0045 size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size);
0046 size_t cpu_map__snprint_mask(struct perf_cpu_map *map, char *buf, size_t size);
0047 size_t cpu_map__fprintf(struct perf_cpu_map *map, FILE *fp);
0048 const struct perf_cpu_map *cpu_map__online(void);
0049
0050 int cpu__setup_cpunode_map(void);
0051
0052 int cpu__max_node(void);
0053 struct perf_cpu cpu__max_cpu(void);
0054 struct perf_cpu cpu__max_present_cpu(void);
0055
0056
0057
0058
0059 static inline bool cpu_map__is_dummy(struct perf_cpu_map *cpus)
0060 {
0061 return perf_cpu_map__nr(cpus) == 1 && perf_cpu_map__cpu(cpus, 0).cpu == -1;
0062 }
0063
0064
0065
0066
0067
0068 int cpu__get_node(struct perf_cpu cpu);
0069
0070
0071
0072
0073 int cpu__get_socket_id(struct perf_cpu cpu);
0074
0075
0076
0077
0078 int cpu__get_die_id(struct perf_cpu cpu);
0079
0080
0081
0082
0083 int cpu__get_core_id(struct perf_cpu cpu);
0084
0085
0086
0087
0088
0089 struct cpu_aggr_map *cpu_aggr_map__empty_new(int nr);
0090
0091 typedef struct aggr_cpu_id (*aggr_cpu_id_get_t)(struct perf_cpu cpu, void *data);
0092
0093
0094
0095
0096
0097
0098 struct cpu_aggr_map *cpu_aggr_map__new(const struct perf_cpu_map *cpus,
0099 aggr_cpu_id_get_t get_id,
0100 void *data);
0101
0102 bool aggr_cpu_id__equal(const struct aggr_cpu_id *a, const struct aggr_cpu_id *b);
0103 bool aggr_cpu_id__is_empty(const struct aggr_cpu_id *a);
0104 struct aggr_cpu_id aggr_cpu_id__empty(void);
0105
0106
0107
0108
0109
0110
0111
0112 struct aggr_cpu_id aggr_cpu_id__socket(struct perf_cpu cpu, void *data);
0113
0114
0115
0116
0117
0118 struct aggr_cpu_id aggr_cpu_id__die(struct perf_cpu cpu, void *data);
0119
0120
0121
0122
0123
0124 struct aggr_cpu_id aggr_cpu_id__core(struct perf_cpu cpu, void *data);
0125
0126
0127
0128
0129
0130 struct aggr_cpu_id aggr_cpu_id__cpu(struct perf_cpu cpu, void *data);
0131
0132
0133
0134
0135 struct aggr_cpu_id aggr_cpu_id__node(struct perf_cpu cpu, void *data);
0136
0137 #endif