5 struct perf_env perf_env
;
7 void perf_env__exit(struct perf_env
*env
)
11 zfree(&env
->hostname
);
12 zfree(&env
->os_release
);
15 zfree(&env
->cpu_desc
);
18 zfree(&env
->cmdline_argv
);
19 zfree(&env
->sibling_cores
);
20 zfree(&env
->sibling_threads
);
21 zfree(&env
->numa_nodes
);
22 zfree(&env
->pmu_mappings
);
25 for (i
= 0; i
< env
->caches_cnt
; i
++)
26 cpu_cache_level__free(&env
->caches
[i
]);
30 int perf_env__set_cmdline(struct perf_env
*env
, int argc
, const char *argv
[])
34 /* do not include NULL termination */
35 env
->cmdline_argv
= calloc(argc
, sizeof(char *));
36 if (env
->cmdline_argv
== NULL
)
40 * Must copy argv contents because it gets moved around during option
43 for (i
= 0; i
< argc
; i
++) {
44 env
->cmdline_argv
[i
] = argv
[i
];
45 if (env
->cmdline_argv
[i
] == NULL
)
49 env
->nr_cmdline
= argc
;
53 zfree(&env
->cmdline_argv
);
58 int perf_env__read_cpu_topology_map(struct perf_env
*env
)
65 if (env
->nr_cpus_avail
== 0)
66 env
->nr_cpus_avail
= sysconf(_SC_NPROCESSORS_CONF
);
68 nr_cpus
= env
->nr_cpus_avail
;
72 env
->cpu
= calloc(nr_cpus
, sizeof(env
->cpu
[0]));
76 for (cpu
= 0; cpu
< nr_cpus
; ++cpu
) {
77 env
->cpu
[cpu
].core_id
= cpu_map__get_core_id(cpu
);
78 env
->cpu
[cpu
].socket_id
= cpu_map__get_socket_id(cpu
);
81 env
->nr_cpus_avail
= nr_cpus
;
85 void cpu_cache_level__free(struct cpu_cache_level
*cache
)