diff options
| -rw-r--r-- | tools/perf/util/env.c | 18 | ||||
| -rw-r--r-- | tools/perf/util/env.h | 2 | ||||
| -rw-r--r-- | tools/perf/util/machine.c | 9 | ||||
| -rw-r--r-- | tools/perf/util/machine.h | 2 |
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 | ||
| 96 | static 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 | |||
| 109 | const char *perf_env__raw_arch(struct perf_env *env) | ||
| 110 | { | ||
| 111 | return env && !perf_env__read_arch(env) ? env->arch : "unknown"; | ||
| 112 | } | ||
| 113 | |||
| 96 | void cpu_cache_level__free(struct cpu_cache_level *cache) | 114 | void 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); | |||
| 76 | void cpu_cache_level__free(struct cpu_cache_level *cache); | 76 | void cpu_cache_level__free(struct cpu_cache_level *cache); |
| 77 | 77 | ||
| 78 | const char *perf_env__arch(struct perf_env *env); | 78 | const char *perf_env__arch(struct perf_env *env); |
| 79 | const 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 | */ | ||
| 2303 | bool machine__is(struct machine *machine, const char *arch) | ||
| 2304 | { | ||
| 2305 | return machine && !strcmp(perf_env__raw_arch(machine->env), arch); | ||
| 2306 | } | ||
| 2307 | |||
| 2299 | int machine__get_kernel_start(struct machine *machine) | 2308 | int 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 | ||
| 191 | bool machine__is(struct machine *machine, const char *arch); | ||
| 192 | |||
| 191 | struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid); | 193 | struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid); |
| 192 | struct thread *machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid); | 194 | struct thread *machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid); |
| 193 | 195 | ||
