1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/types.h>
6 #include <linux/rbtree.h>
12 struct cpu_topology_map
{
19 struct cpu_cache_level
{
33 struct perf_cpu_map
*map
;
49 unsigned int max_branches
;
50 unsigned int br_cntr_nr
;
51 unsigned int br_cntr_width
;
57 typedef const char *(arch_syscalls__strerrno_t
)(int err
);
68 unsigned long long total_mem
;
69 unsigned int msr_pmu_type
;
70 unsigned int max_branches
;
71 unsigned int br_cntr_nr
;
72 unsigned int br_cntr_width
;
78 int nr_sibling_threads
;
85 int nr_pmus_with_caps
;
87 const char **cmdline_argv
;
90 char *sibling_threads
;
93 struct cpu_topology_map
*cpu
;
94 struct cpu_cache_level
*caches
;
101 struct numa_node
*numa_nodes
;
102 struct memory_node
*memory_nodes
;
103 unsigned long long memory_bsize
;
104 struct hybrid_node
*hybrid_nodes
;
105 struct pmu_caps
*pmu_caps
;
106 #ifdef HAVE_LIBBPF_SUPPORT
108 * bpf_info_lock protects bpf rbtrees. This is needed because the
109 * trees are accessed by different threads in perf-top
112 struct rw_semaphore lock
;
113 struct rb_root infos
;
118 #endif // HAVE_LIBBPF_SUPPORT
119 /* same reason as above (for perf-top) */
121 struct rw_semaphore lock
;
125 /* For fast cpu to numa node lookup via perf_env__numa_node */
129 /* For real clock time reference. */
136 * enabled is valid for report mode, and is true if above
137 * values are set, it's set in process_clock_data
141 arch_syscalls__strerrno_t
*arch_strerrno
;
144 enum perf_compress_type
{
150 struct bpf_prog_info_node
;
153 extern struct perf_env perf_env
;
155 void perf_env__exit(struct perf_env
*env
);
157 int perf_env__kernel_is_64_bit(struct perf_env
*env
);
159 int perf_env__set_cmdline(struct perf_env
*env
, int argc
, const char *argv
[]);
161 int perf_env__read_cpuid(struct perf_env
*env
);
162 int perf_env__read_pmu_mappings(struct perf_env
*env
);
163 int perf_env__nr_pmu_mappings(struct perf_env
*env
);
164 const char *perf_env__pmu_mappings(struct perf_env
*env
);
166 int perf_env__read_cpu_topology_map(struct perf_env
*env
);
168 void cpu_cache_level__free(struct cpu_cache_level
*cache
);
170 const char *perf_env__arch(struct perf_env
*env
);
171 const char *perf_env__arch_strerrno(struct perf_env
*env
, int err
);
172 const char *perf_env__cpuid(struct perf_env
*env
);
173 const char *perf_env__raw_arch(struct perf_env
*env
);
174 int perf_env__nr_cpus_avail(struct perf_env
*env
);
176 void perf_env__init(struct perf_env
*env
);
177 bool __perf_env__insert_bpf_prog_info(struct perf_env
*env
,
178 struct bpf_prog_info_node
*info_node
);
179 bool perf_env__insert_bpf_prog_info(struct perf_env
*env
,
180 struct bpf_prog_info_node
*info_node
);
181 struct bpf_prog_info_node
*perf_env__find_bpf_prog_info(struct perf_env
*env
,
183 bool perf_env__insert_btf(struct perf_env
*env
, struct btf_node
*btf_node
);
184 bool __perf_env__insert_btf(struct perf_env
*env
, struct btf_node
*btf_node
);
185 struct btf_node
*perf_env__find_btf(struct perf_env
*env
, __u32 btf_id
);
186 struct btf_node
*__perf_env__find_btf(struct perf_env
*env
, __u32 btf_id
);
188 int perf_env__numa_node(struct perf_env
*env
, struct perf_cpu cpu
);
189 char *perf_env__find_pmu_cap(struct perf_env
*env
, const char *pmu_name
,
192 bool perf_env__has_pmu_mapping(struct perf_env
*env
, const char *pmu_name
);
193 void perf_env__find_br_cntr_info(struct perf_env
*env
,
195 unsigned int *width
);
197 bool x86__is_amd_cpu(void);
198 bool perf_env__is_x86_amd_cpu(struct perf_env
*env
);
200 #endif /* __PERF_ENV_H */