• Home
  • Raw
  • Download

Lines Matching refs:env

16 void perf_env__insert_bpf_prog_info(struct perf_env *env,  in perf_env__insert_bpf_prog_info()  argument
19 down_write(&env->bpf_progs.lock); in perf_env__insert_bpf_prog_info()
20 __perf_env__insert_bpf_prog_info(env, info_node); in perf_env__insert_bpf_prog_info()
21 up_write(&env->bpf_progs.lock); in perf_env__insert_bpf_prog_info()
24 void __perf_env__insert_bpf_prog_info(struct perf_env *env, struct bpf_prog_info_node *info_node) in __perf_env__insert_bpf_prog_info() argument
31 p = &env->bpf_progs.infos.rb_node; in __perf_env__insert_bpf_prog_info()
47 rb_insert_color(&info_node->rb_node, &env->bpf_progs.infos); in __perf_env__insert_bpf_prog_info()
48 env->bpf_progs.infos_cnt++; in __perf_env__insert_bpf_prog_info()
51 struct bpf_prog_info_node *perf_env__find_bpf_prog_info(struct perf_env *env, in perf_env__find_bpf_prog_info() argument
57 down_read(&env->bpf_progs.lock); in perf_env__find_bpf_prog_info()
58 n = env->bpf_progs.infos.rb_node; in perf_env__find_bpf_prog_info()
72 up_read(&env->bpf_progs.lock); in perf_env__find_bpf_prog_info()
76 bool perf_env__insert_btf(struct perf_env *env, struct btf_node *btf_node) in perf_env__insert_btf() argument
80 down_write(&env->bpf_progs.lock); in perf_env__insert_btf()
81 ret = __perf_env__insert_btf(env, btf_node); in perf_env__insert_btf()
82 up_write(&env->bpf_progs.lock); in perf_env__insert_btf()
86 bool __perf_env__insert_btf(struct perf_env *env, struct btf_node *btf_node) in __perf_env__insert_btf() argument
93 p = &env->bpf_progs.btfs.rb_node; in __perf_env__insert_btf()
109 rb_insert_color(&btf_node->rb_node, &env->bpf_progs.btfs); in __perf_env__insert_btf()
110 env->bpf_progs.btfs_cnt++; in __perf_env__insert_btf()
114 struct btf_node *perf_env__find_btf(struct perf_env *env, __u32 btf_id) in perf_env__find_btf() argument
118 down_read(&env->bpf_progs.lock); in perf_env__find_btf()
119 res = __perf_env__find_btf(env, btf_id); in perf_env__find_btf()
120 up_read(&env->bpf_progs.lock); in perf_env__find_btf()
124 struct btf_node *__perf_env__find_btf(struct perf_env *env, __u32 btf_id) in __perf_env__find_btf() argument
129 n = env->bpf_progs.btfs.rb_node; in __perf_env__find_btf()
144 static void perf_env__purge_bpf(struct perf_env *env) in perf_env__purge_bpf() argument
149 down_write(&env->bpf_progs.lock); in perf_env__purge_bpf()
151 root = &env->bpf_progs.infos; in perf_env__purge_bpf()
163 env->bpf_progs.infos_cnt = 0; in perf_env__purge_bpf()
165 root = &env->bpf_progs.btfs; in perf_env__purge_bpf()
177 env->bpf_progs.btfs_cnt = 0; in perf_env__purge_bpf()
179 up_write(&env->bpf_progs.lock); in perf_env__purge_bpf()
182 void perf_env__exit(struct perf_env *env) in perf_env__exit() argument
186 perf_env__purge_bpf(env); in perf_env__exit()
187 zfree(&env->hostname); in perf_env__exit()
188 zfree(&env->os_release); in perf_env__exit()
189 zfree(&env->version); in perf_env__exit()
190 zfree(&env->arch); in perf_env__exit()
191 zfree(&env->cpu_desc); in perf_env__exit()
192 zfree(&env->cpuid); in perf_env__exit()
193 zfree(&env->cmdline); in perf_env__exit()
194 zfree(&env->cmdline_argv); in perf_env__exit()
195 zfree(&env->sibling_dies); in perf_env__exit()
196 zfree(&env->sibling_cores); in perf_env__exit()
197 zfree(&env->sibling_threads); in perf_env__exit()
198 zfree(&env->pmu_mappings); in perf_env__exit()
199 zfree(&env->cpu); in perf_env__exit()
200 zfree(&env->numa_map); in perf_env__exit()
202 for (i = 0; i < env->nr_numa_nodes; i++) in perf_env__exit()
203 perf_cpu_map__put(env->numa_nodes[i].map); in perf_env__exit()
204 zfree(&env->numa_nodes); in perf_env__exit()
206 for (i = 0; i < env->caches_cnt; i++) in perf_env__exit()
207 cpu_cache_level__free(&env->caches[i]); in perf_env__exit()
208 zfree(&env->caches); in perf_env__exit()
210 for (i = 0; i < env->nr_memory_nodes; i++) in perf_env__exit()
211 zfree(&env->memory_nodes[i].set); in perf_env__exit()
212 zfree(&env->memory_nodes); in perf_env__exit()
215 void perf_env__init(struct perf_env *env) in perf_env__init() argument
217 env->bpf_progs.infos = RB_ROOT; in perf_env__init()
218 env->bpf_progs.btfs = RB_ROOT; in perf_env__init()
219 init_rwsem(&env->bpf_progs.lock); in perf_env__init()
222 int perf_env__set_cmdline(struct perf_env *env, int argc, const char *argv[]) in perf_env__set_cmdline() argument
227 env->cmdline_argv = calloc(argc, sizeof(char *)); in perf_env__set_cmdline()
228 if (env->cmdline_argv == NULL) in perf_env__set_cmdline()
236 env->cmdline_argv[i] = argv[i]; in perf_env__set_cmdline()
237 if (env->cmdline_argv[i] == NULL) in perf_env__set_cmdline()
241 env->nr_cmdline = argc; in perf_env__set_cmdline()
245 zfree(&env->cmdline_argv); in perf_env__set_cmdline()
250 int perf_env__read_cpu_topology_map(struct perf_env *env) in perf_env__read_cpu_topology_map() argument
254 if (env->cpu != NULL) in perf_env__read_cpu_topology_map()
257 if (env->nr_cpus_avail == 0) in perf_env__read_cpu_topology_map()
258 env->nr_cpus_avail = cpu__max_present_cpu(); in perf_env__read_cpu_topology_map()
260 nr_cpus = env->nr_cpus_avail; in perf_env__read_cpu_topology_map()
264 env->cpu = calloc(nr_cpus, sizeof(env->cpu[0])); in perf_env__read_cpu_topology_map()
265 if (env->cpu == NULL) in perf_env__read_cpu_topology_map()
269 env->cpu[cpu].core_id = cpu_map__get_core_id(cpu); in perf_env__read_cpu_topology_map()
270 env->cpu[cpu].socket_id = cpu_map__get_socket_id(cpu); in perf_env__read_cpu_topology_map()
271 env->cpu[cpu].die_id = cpu_map__get_die_id(cpu); in perf_env__read_cpu_topology_map()
274 env->nr_cpus_avail = nr_cpus; in perf_env__read_cpu_topology_map()
278 static int perf_env__read_arch(struct perf_env *env) in perf_env__read_arch() argument
282 if (env->arch) in perf_env__read_arch()
286 env->arch = strdup(uts.machine); in perf_env__read_arch()
288 return env->arch ? 0 : -ENOMEM; in perf_env__read_arch()
291 static int perf_env__read_nr_cpus_avail(struct perf_env *env) in perf_env__read_nr_cpus_avail() argument
293 if (env->nr_cpus_avail == 0) in perf_env__read_nr_cpus_avail()
294 env->nr_cpus_avail = cpu__max_present_cpu(); in perf_env__read_nr_cpus_avail()
296 return env->nr_cpus_avail ? 0 : -ENOENT; in perf_env__read_nr_cpus_avail()
299 const char *perf_env__raw_arch(struct perf_env *env) in perf_env__raw_arch() argument
301 return env && !perf_env__read_arch(env) ? env->arch : "unknown"; in perf_env__raw_arch()
304 int perf_env__nr_cpus_avail(struct perf_env *env) in perf_env__nr_cpus_avail() argument
306 return env && !perf_env__read_nr_cpus_avail(env) ? env->nr_cpus_avail : 0; in perf_env__nr_cpus_avail()
346 const char *perf_env__arch(struct perf_env *env) in perf_env__arch() argument
350 if (!env || !env->arch) { /* Assume local operation */ in perf_env__arch()
356 arch_name = env->arch; in perf_env__arch()
362 int perf_env__numa_node(struct perf_env *env, int cpu) in perf_env__numa_node() argument
364 if (!env->nr_numa_map) { in perf_env__numa_node()
368 for (i = 0; i < env->nr_numa_nodes; i++) { in perf_env__numa_node()
369 nn = &env->numa_nodes[i]; in perf_env__numa_node()
379 env->numa_map = malloc(nr * sizeof(int)); in perf_env__numa_node()
380 if (!env->numa_map) in perf_env__numa_node()
384 env->numa_map[i] = -1; in perf_env__numa_node()
386 env->nr_numa_map = nr; in perf_env__numa_node()
388 for (i = 0; i < env->nr_numa_nodes; i++) { in perf_env__numa_node()
391 nn = &env->numa_nodes[i]; in perf_env__numa_node()
393 env->numa_map[j] = i; in perf_env__numa_node()
397 return cpu >= 0 && cpu < env->nr_numa_map ? env->numa_map[cpu] : -1; in perf_env__numa_node()