0001
0002 #ifndef __PERF_ENV_H
0003 #define __PERF_ENV_H
0004
0005 #include <linux/types.h>
0006 #include <linux/rbtree.h>
0007 #include "cpumap.h"
0008 #include "rwsem.h"
0009
0010 struct perf_cpu_map;
0011
0012 struct cpu_topology_map {
0013 int socket_id;
0014 int die_id;
0015 int core_id;
0016 };
0017
0018 struct cpu_cache_level {
0019 u32 level;
0020 u32 line_size;
0021 u32 sets;
0022 u32 ways;
0023 char *type;
0024 char *size;
0025 char *map;
0026 };
0027
0028 struct numa_node {
0029 u32 node;
0030 u64 mem_total;
0031 u64 mem_free;
0032 struct perf_cpu_map *map;
0033 };
0034
0035 struct memory_node {
0036 u64 node;
0037 u64 size;
0038 unsigned long *set;
0039 };
0040
0041 struct hybrid_node {
0042 char *pmu_name;
0043 char *cpus;
0044 };
0045
0046 struct pmu_caps {
0047 int nr_caps;
0048 unsigned int max_branches;
0049 char **caps;
0050 char *pmu_name;
0051 };
0052
0053 struct perf_env {
0054 char *hostname;
0055 char *os_release;
0056 char *version;
0057 char *arch;
0058 int nr_cpus_online;
0059 int nr_cpus_avail;
0060 char *cpu_desc;
0061 char *cpuid;
0062 unsigned long long total_mem;
0063 unsigned int msr_pmu_type;
0064 unsigned int max_branches;
0065 int kernel_is_64_bit;
0066
0067 int nr_cmdline;
0068 int nr_sibling_cores;
0069 int nr_sibling_dies;
0070 int nr_sibling_threads;
0071 int nr_numa_nodes;
0072 int nr_memory_nodes;
0073 int nr_pmu_mappings;
0074 int nr_groups;
0075 int nr_cpu_pmu_caps;
0076 int nr_hybrid_nodes;
0077 int nr_pmus_with_caps;
0078 char *cmdline;
0079 const char **cmdline_argv;
0080 char *sibling_cores;
0081 char *sibling_dies;
0082 char *sibling_threads;
0083 char *pmu_mappings;
0084 char **cpu_pmu_caps;
0085 struct cpu_topology_map *cpu;
0086 struct cpu_cache_level *caches;
0087 int caches_cnt;
0088 u32 comp_ratio;
0089 u32 comp_ver;
0090 u32 comp_type;
0091 u32 comp_level;
0092 u32 comp_mmap_len;
0093 struct numa_node *numa_nodes;
0094 struct memory_node *memory_nodes;
0095 unsigned long long memory_bsize;
0096 struct hybrid_node *hybrid_nodes;
0097 struct pmu_caps *pmu_caps;
0098 #ifdef HAVE_LIBBPF_SUPPORT
0099
0100
0101
0102
0103 struct {
0104 struct rw_semaphore lock;
0105 struct rb_root infos;
0106 u32 infos_cnt;
0107 struct rb_root btfs;
0108 u32 btfs_cnt;
0109 } bpf_progs;
0110 #endif
0111
0112 struct {
0113 struct rw_semaphore lock;
0114 struct rb_root tree;
0115 } cgroups;
0116
0117
0118 int *numa_map;
0119 int nr_numa_map;
0120
0121
0122 struct {
0123 u64 tod_ns;
0124 u64 clockid_ns;
0125 u64 clockid_res_ns;
0126 int clockid;
0127
0128
0129
0130
0131 bool enabled;
0132 } clock;
0133 };
0134
0135 enum perf_compress_type {
0136 PERF_COMP_NONE = 0,
0137 PERF_COMP_ZSTD,
0138 PERF_COMP_MAX
0139 };
0140
0141 struct bpf_prog_info_node;
0142 struct btf_node;
0143
0144 extern struct perf_env perf_env;
0145
0146 void perf_env__exit(struct perf_env *env);
0147
0148 int perf_env__kernel_is_64_bit(struct perf_env *env);
0149
0150 int perf_env__set_cmdline(struct perf_env *env, int argc, const char *argv[]);
0151
0152 int perf_env__read_cpuid(struct perf_env *env);
0153 int perf_env__read_pmu_mappings(struct perf_env *env);
0154 int perf_env__nr_pmu_mappings(struct perf_env *env);
0155 const char *perf_env__pmu_mappings(struct perf_env *env);
0156
0157 int perf_env__read_cpu_topology_map(struct perf_env *env);
0158
0159 void cpu_cache_level__free(struct cpu_cache_level *cache);
0160
0161 const char *perf_env__arch(struct perf_env *env);
0162 const char *perf_env__cpuid(struct perf_env *env);
0163 const char *perf_env__raw_arch(struct perf_env *env);
0164 int perf_env__nr_cpus_avail(struct perf_env *env);
0165
0166 void perf_env__init(struct perf_env *env);
0167 void perf_env__insert_bpf_prog_info(struct perf_env *env,
0168 struct bpf_prog_info_node *info_node);
0169 struct bpf_prog_info_node *perf_env__find_bpf_prog_info(struct perf_env *env,
0170 __u32 prog_id);
0171 bool perf_env__insert_btf(struct perf_env *env, struct btf_node *btf_node);
0172 struct btf_node *perf_env__find_btf(struct perf_env *env, __u32 btf_id);
0173
0174 int perf_env__numa_node(struct perf_env *env, struct perf_cpu cpu);
0175 char *perf_env__find_pmu_cap(struct perf_env *env, const char *pmu_name,
0176 const char *cap);
0177 #endif