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>
This commit is contained in:
@@ -5,6 +5,7 @@ libperf-y += build-id.o
|
|||||||
libperf-y += config.o
|
libperf-y += config.o
|
||||||
libperf-y += ctype.o
|
libperf-y += ctype.o
|
||||||
libperf-y += db-export.o
|
libperf-y += db-export.o
|
||||||
|
libperf-y += env.o
|
||||||
libperf-y += environment.o
|
libperf-y += environment.o
|
||||||
libperf-y += event.o
|
libperf-y += event.o
|
||||||
libperf-y += evlist.o
|
libperf-y += evlist.o
|
||||||
|
|||||||
19
tools/perf/util/env.c
Normal file
19
tools/perf/util/env.c
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include "env.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
void perf_env__exit(struct perf_env *env)
|
||||||
|
{
|
||||||
|
zfree(&env->hostname);
|
||||||
|
zfree(&env->os_release);
|
||||||
|
zfree(&env->version);
|
||||||
|
zfree(&env->arch);
|
||||||
|
zfree(&env->cpu_desc);
|
||||||
|
zfree(&env->cpuid);
|
||||||
|
zfree(&env->cmdline);
|
||||||
|
zfree(&env->cmdline_argv);
|
||||||
|
zfree(&env->sibling_cores);
|
||||||
|
zfree(&env->sibling_threads);
|
||||||
|
zfree(&env->numa_nodes);
|
||||||
|
zfree(&env->pmu_mappings);
|
||||||
|
zfree(&env->cpu);
|
||||||
|
}
|
||||||
37
tools/perf/util/env.h
Normal file
37
tools/perf/util/env.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#ifndef __PERF_ENV_H
|
||||||
|
#define __PERF_ENV_H
|
||||||
|
|
||||||
|
struct cpu_topology_map {
|
||||||
|
int socket_id;
|
||||||
|
int core_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct perf_env {
|
||||||
|
char *hostname;
|
||||||
|
char *os_release;
|
||||||
|
char *version;
|
||||||
|
char *arch;
|
||||||
|
int nr_cpus_online;
|
||||||
|
int nr_cpus_avail;
|
||||||
|
char *cpu_desc;
|
||||||
|
char *cpuid;
|
||||||
|
unsigned long long total_mem;
|
||||||
|
|
||||||
|
int nr_cmdline;
|
||||||
|
int nr_sibling_cores;
|
||||||
|
int nr_sibling_threads;
|
||||||
|
int nr_numa_nodes;
|
||||||
|
int nr_pmu_mappings;
|
||||||
|
int nr_groups;
|
||||||
|
char *cmdline;
|
||||||
|
const char **cmdline_argv;
|
||||||
|
char *sibling_cores;
|
||||||
|
char *sibling_threads;
|
||||||
|
char *numa_nodes;
|
||||||
|
char *pmu_mappings;
|
||||||
|
struct cpu_topology_map *cpu;
|
||||||
|
};
|
||||||
|
|
||||||
|
void perf_env__exit(struct perf_env *env);
|
||||||
|
|
||||||
|
#endif /* __PERF_ENV_H */
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
#include <linux/bitmap.h>
|
#include <linux/bitmap.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
|
#include "env.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
HEADER_RESERVED = 0, /* always cleared */
|
HEADER_RESERVED = 0, /* always cleared */
|
||||||
@@ -66,37 +66,6 @@ struct perf_header;
|
|||||||
int perf_file_header__read(struct perf_file_header *header,
|
int perf_file_header__read(struct perf_file_header *header,
|
||||||
struct perf_header *ph, int fd);
|
struct perf_header *ph, int fd);
|
||||||
|
|
||||||
struct cpu_topology_map {
|
|
||||||
int socket_id;
|
|
||||||
int core_id;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct perf_env {
|
|
||||||
char *hostname;
|
|
||||||
char *os_release;
|
|
||||||
char *version;
|
|
||||||
char *arch;
|
|
||||||
int nr_cpus_online;
|
|
||||||
int nr_cpus_avail;
|
|
||||||
char *cpu_desc;
|
|
||||||
char *cpuid;
|
|
||||||
unsigned long long total_mem;
|
|
||||||
|
|
||||||
int nr_cmdline;
|
|
||||||
int nr_sibling_cores;
|
|
||||||
int nr_sibling_threads;
|
|
||||||
int nr_numa_nodes;
|
|
||||||
int nr_pmu_mappings;
|
|
||||||
int nr_groups;
|
|
||||||
char *cmdline;
|
|
||||||
const char **cmdline_argv;
|
|
||||||
char *sibling_cores;
|
|
||||||
char *sibling_threads;
|
|
||||||
char *numa_nodes;
|
|
||||||
char *pmu_mappings;
|
|
||||||
struct cpu_topology_map *cpu;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct perf_header {
|
struct perf_header {
|
||||||
enum perf_header_version version;
|
enum perf_header_version version;
|
||||||
bool needs_swap;
|
bool needs_swap;
|
||||||
|
|||||||
@@ -170,31 +170,13 @@ static void perf_session__delete_threads(struct perf_session *session)
|
|||||||
machine__delete_threads(&session->machines.host);
|
machine__delete_threads(&session->machines.host);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void perf_session_env__exit(struct perf_env *env)
|
|
||||||
{
|
|
||||||
zfree(&env->hostname);
|
|
||||||
zfree(&env->os_release);
|
|
||||||
zfree(&env->version);
|
|
||||||
zfree(&env->arch);
|
|
||||||
zfree(&env->cpu_desc);
|
|
||||||
zfree(&env->cpuid);
|
|
||||||
|
|
||||||
zfree(&env->cmdline);
|
|
||||||
zfree(&env->cmdline_argv);
|
|
||||||
zfree(&env->sibling_cores);
|
|
||||||
zfree(&env->sibling_threads);
|
|
||||||
zfree(&env->numa_nodes);
|
|
||||||
zfree(&env->pmu_mappings);
|
|
||||||
zfree(&env->cpu);
|
|
||||||
}
|
|
||||||
|
|
||||||
void perf_session__delete(struct perf_session *session)
|
void perf_session__delete(struct perf_session *session)
|
||||||
{
|
{
|
||||||
auxtrace__free(session);
|
auxtrace__free(session);
|
||||||
auxtrace_index__free(&session->auxtrace_index);
|
auxtrace_index__free(&session->auxtrace_index);
|
||||||
perf_session__destroy_kernel_maps(session);
|
perf_session__destroy_kernel_maps(session);
|
||||||
perf_session__delete_threads(session);
|
perf_session__delete_threads(session);
|
||||||
perf_session_env__exit(&session->header.env);
|
perf_env__exit(&session->header.env);
|
||||||
machines__exit(&session->machines);
|
machines__exit(&session->machines);
|
||||||
if (session->file)
|
if (session->file)
|
||||||
perf_data_file__close(session->file);
|
perf_data_file__close(session->file);
|
||||||
|
|||||||
Reference in New Issue
Block a user