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
);
59 arch_syscalls__strerrno_t
*arch_syscalls__strerrno_function(const char *arch
);
70 unsigned long long total_mem
;
71 unsigned int msr_pmu_type
;
72 unsigned int max_branches
;
73 unsigned int br_cntr_nr
;
74 unsigned int br_cntr_width
;
80 int nr_sibling_threads
;
87 int nr_pmus_with_caps
;
89 const char **cmdline_argv
;
92 char *sibling_threads
;
95 struct cpu_topology_map
*cpu
;
96 struct cpu_cache_level
*caches
;
103 struct numa_node
*numa_nodes
;
104 struct memory_node
*memory_nodes
;
105 unsigned long long memory_bsize
;
106 struct hybrid_node
*hybrid_nodes
;
107 struct pmu_caps
*pmu_caps
;
108 #ifdef HAVE_LIBBPF_SUPPORT
110 * bpf_info_lock protects bpf rbtrees. This is needed because the
111 * trees are accessed by different threads in perf-top
114 struct rw_semaphore lock
;
115 struct rb_root infos
;
120 #endif // HAVE_LIBBPF_SUPPORT
121 /* same reason as above (for perf-top) */
123 struct rw_semaphore lock
;
127 /* For fast cpu to numa node lookup via perf_env__numa_node */
131 /* For real clock time reference. */
138 * enabled is valid for report mode, and is true if above
139 * values are set, it's set in process_clock_data
143 arch_syscalls__strerrno_t
*arch_strerrno
;
146 enum perf_compress_type
{
152 struct bpf_prog_info_node
;
155 extern struct perf_env perf_env
;
157 void perf_env__exit(struct perf_env
*env
);
159 int perf_env__kernel_is_64_bit(struct perf_env
*env
);
161 int perf_env__set_cmdline(struct perf_env
*env
, int argc
, const char *argv
[]);
163 int perf_env__read_cpuid(struct perf_env
*env
);
164 int perf_env__read_pmu_mappings(struct perf_env
*env
);
165 int perf_env__nr_pmu_mappings(struct perf_env
*env
);
166 const char *perf_env__pmu_mappings(struct perf_env
*env
);
168 int perf_env__read_cpu_topology_map(struct perf_env
*env
);
170 void cpu_cache_level__free(struct cpu_cache_level
*cache
);
172 const char *perf_env__arch(struct perf_env
*env
);
173 const char *perf_env__arch_strerrno(struct perf_env
*env
, int err
);
174 const char *perf_env__cpuid(struct perf_env
*env
);
175 const char *perf_env__raw_arch(struct perf_env
*env
);
176 int perf_env__nr_cpus_avail(struct perf_env
*env
);
178 void perf_env__init(struct perf_env
*env
);
179 void __perf_env__insert_bpf_prog_info(struct perf_env
*env
,
180 struct bpf_prog_info_node
*info_node
);
181 void perf_env__insert_bpf_prog_info(struct perf_env
*env
,
182 struct bpf_prog_info_node
*info_node
);
183 struct bpf_prog_info_node
*perf_env__find_bpf_prog_info(struct perf_env
*env
,
185 bool perf_env__insert_btf(struct perf_env
*env
, struct btf_node
*btf_node
);
186 bool __perf_env__insert_btf(struct perf_env
*env
, struct btf_node
*btf_node
);
187 struct btf_node
*perf_env__find_btf(struct perf_env
*env
, __u32 btf_id
);
188 struct btf_node
*__perf_env__find_btf(struct perf_env
*env
, __u32 btf_id
);
190 int perf_env__numa_node(struct perf_env
*env
, struct perf_cpu cpu
);
191 char *perf_env__find_pmu_cap(struct perf_env
*env
, const char *pmu_name
,
194 bool perf_env__has_pmu_mapping(struct perf_env
*env
, const char *pmu_name
);
195 void perf_env__find_br_cntr_info(struct perf_env
*env
,
197 unsigned int *width
);
199 bool x86__is_amd_cpu(void);
200 bool perf_env__is_x86_amd_cpu(struct perf_env
*env
);
202 #endif /* __PERF_ENV_H */