Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf env: Move perf_env out of header.h and session.c into separate object

Since it can be used separately from 'perf_session' and 'perf_header',
move it to separate include file and object, next csets will try to move
a perf_env__init() routine.

Tested-by: Wang Nan <wangnan0@huawei.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-ff2rw99tsn670y1b6gxbwdsi@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+59 -51
+1
tools/perf/util/Build
··· 5 5 libperf-y += config.o 6 6 libperf-y += ctype.o 7 7 libperf-y += db-export.o 8 + libperf-y += env.o 8 9 libperf-y += environment.o 9 10 libperf-y += event.o 10 11 libperf-y += evlist.o
+19
tools/perf/util/env.c
··· 1 + #include "env.h" 2 + #include "util.h" 3 + 4 + void perf_env__exit(struct perf_env *env) 5 + { 6 + zfree(&env->hostname); 7 + zfree(&env->os_release); 8 + zfree(&env->version); 9 + zfree(&env->arch); 10 + zfree(&env->cpu_desc); 11 + zfree(&env->cpuid); 12 + zfree(&env->cmdline); 13 + zfree(&env->cmdline_argv); 14 + zfree(&env->sibling_cores); 15 + zfree(&env->sibling_threads); 16 + zfree(&env->numa_nodes); 17 + zfree(&env->pmu_mappings); 18 + zfree(&env->cpu); 19 + }
+37
tools/perf/util/env.h
··· 1 + #ifndef __PERF_ENV_H 2 + #define __PERF_ENV_H 3 + 4 + struct cpu_topology_map { 5 + int socket_id; 6 + int core_id; 7 + }; 8 + 9 + struct perf_env { 10 + char *hostname; 11 + char *os_release; 12 + char *version; 13 + char *arch; 14 + int nr_cpus_online; 15 + int nr_cpus_avail; 16 + char *cpu_desc; 17 + char *cpuid; 18 + unsigned long long total_mem; 19 + 20 + int nr_cmdline; 21 + int nr_sibling_cores; 22 + int nr_sibling_threads; 23 + int nr_numa_nodes; 24 + int nr_pmu_mappings; 25 + int nr_groups; 26 + char *cmdline; 27 + const char **cmdline_argv; 28 + char *sibling_cores; 29 + char *sibling_threads; 30 + char *numa_nodes; 31 + char *pmu_mappings; 32 + struct cpu_topology_map *cpu; 33 + }; 34 + 35 + void perf_env__exit(struct perf_env *env); 36 + 37 + #endif /* __PERF_ENV_H */
+1 -32
tools/perf/util/header.h
··· 7 7 #include <linux/bitmap.h> 8 8 #include <linux/types.h> 9 9 #include "event.h" 10 - 10 + #include "env.h" 11 11 12 12 enum { 13 13 HEADER_RESERVED = 0, /* always cleared */ ··· 65 65 66 66 int perf_file_header__read(struct perf_file_header *header, 67 67 struct perf_header *ph, int fd); 68 - 69 - struct cpu_topology_map { 70 - int socket_id; 71 - int core_id; 72 - }; 73 - 74 - struct perf_env { 75 - char *hostname; 76 - char *os_release; 77 - char *version; 78 - char *arch; 79 - int nr_cpus_online; 80 - int nr_cpus_avail; 81 - char *cpu_desc; 82 - char *cpuid; 83 - unsigned long long total_mem; 84 - 85 - int nr_cmdline; 86 - int nr_sibling_cores; 87 - int nr_sibling_threads; 88 - int nr_numa_nodes; 89 - int nr_pmu_mappings; 90 - int nr_groups; 91 - char *cmdline; 92 - const char **cmdline_argv; 93 - char *sibling_cores; 94 - char *sibling_threads; 95 - char *numa_nodes; 96 - char *pmu_mappings; 97 - struct cpu_topology_map *cpu; 98 - }; 99 68 100 69 struct perf_header { 101 70 enum perf_header_version version;
+1 -19
tools/perf/util/session.c
··· 170 170 machine__delete_threads(&session->machines.host); 171 171 } 172 172 173 - static void perf_session_env__exit(struct perf_env *env) 174 - { 175 - zfree(&env->hostname); 176 - zfree(&env->os_release); 177 - zfree(&env->version); 178 - zfree(&env->arch); 179 - zfree(&env->cpu_desc); 180 - zfree(&env->cpuid); 181 - 182 - zfree(&env->cmdline); 183 - zfree(&env->cmdline_argv); 184 - zfree(&env->sibling_cores); 185 - zfree(&env->sibling_threads); 186 - zfree(&env->numa_nodes); 187 - zfree(&env->pmu_mappings); 188 - zfree(&env->cpu); 189 - } 190 - 191 173 void perf_session__delete(struct perf_session *session) 192 174 { 193 175 auxtrace__free(session); 194 176 auxtrace_index__free(&session->auxtrace_index); 195 177 perf_session__destroy_kernel_maps(session); 196 178 perf_session__delete_threads(session); 197 - perf_session_env__exit(&session->header.env); 179 + perf_env__exit(&session->header.env); 198 180 machines__exit(&session->machines); 199 181 if (session->file) 200 182 perf_data_file__close(session->file);