aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/env.c18
-rw-r--r--tools/perf/util/env.h2
-rw-r--r--tools/perf/util/machine.c9
-rw-r--r--tools/perf/util/machine.h2
4 files changed, 31 insertions, 0 deletions
diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
index 4c842762e3f2..319fb0a0d05e 100644
--- a/tools/perf/util/env.c
+++ b/tools/perf/util/env.c
@@ -93,6 +93,24 @@ int perf_env__read_cpu_topology_map(struct perf_env *env)
93 return 0; 93 return 0;
94} 94}
95 95
96static int perf_env__read_arch(struct perf_env *env)
97{
98 struct utsname uts;
99
100 if (env->arch)
101 return 0;
102
103 if (!uname(&uts))
104 env->arch = strdup(uts.machine);
105
106 return env->arch ? 0 : -ENOMEM;
107}
108
109const char *perf_env__raw_arch(struct perf_env *env)
110{
111 return env && !perf_env__read_arch(env) ? env->arch : "unknown";
112}
113
96void cpu_cache_level__free(struct cpu_cache_level *cache) 114void cpu_cache_level__free(struct cpu_cache_level *cache)
97{ 115{
98 free(cache->type); 116 free(cache->type);
diff --git a/tools/perf/util/env.h b/tools/perf/util/env.h
index c4ef2e523367..62e193948608 100644
--- a/tools/perf/util/env.h
+++ b/tools/perf/util/env.h
@@ -76,4 +76,6 @@ int perf_env__read_cpu_topology_map(struct perf_env *env);
76void cpu_cache_level__free(struct cpu_cache_level *cache); 76void cpu_cache_level__free(struct cpu_cache_level *cache);
77 77
78const char *perf_env__arch(struct perf_env *env); 78const char *perf_env__arch(struct perf_env *env);
79const char *perf_env__raw_arch(struct perf_env *env);
80
79#endif /* __PERF_ENV_H */ 81#endif /* __PERF_ENV_H */
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 7c777cb32806..107bae7676b1 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -2296,6 +2296,15 @@ int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid,
2296 return 0; 2296 return 0;
2297} 2297}
2298 2298
2299/*
2300 * Compares the raw arch string. N.B. see instead perf_env__arch() if a
2301 * normalized arch is needed.
2302 */
2303bool machine__is(struct machine *machine, const char *arch)
2304{
2305 return machine && !strcmp(perf_env__raw_arch(machine->env), arch);
2306}
2307
2299int machine__get_kernel_start(struct machine *machine) 2308int machine__get_kernel_start(struct machine *machine)
2300{ 2309{
2301 struct map *map = machine__kernel_map(machine); 2310 struct map *map = machine__kernel_map(machine);
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index 388fb4741c54..b31d33b5aa2a 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -188,6 +188,8 @@ static inline bool machine__is_host(struct machine *machine)
188 return machine ? machine->pid == HOST_KERNEL_ID : false; 188 return machine ? machine->pid == HOST_KERNEL_ID : false;
189} 189}
190 190
191bool machine__is(struct machine *machine, const char *arch);
192
191struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid); 193struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid);
192struct thread *machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid); 194struct thread *machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid);
193 195