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

perf unwind: Move unwind__prepare_access from thread_new into thread__insert_map

To determine the libunwind methods to use, we should get the
32bit/64bit information from maps of a thread. When a thread is newly
created, the information is not prepared. This patch moves
unwind__prepare_access() into thread__insert_map() so we can get the
information we need from maps. Meanwhile, let thread__insert_map()
return value and show messages on error.

Signed-off-by: He Kuang <hekuang@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1464924803-22214-5-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

He Kuang and committed by
Arnaldo Carvalho de Melo
8132a2a8 f83c0415

+22 -7
+12 -2
tools/perf/util/machine.c
··· 1353 1353 if (map == NULL) 1354 1354 goto out_problem_map; 1355 1355 1356 - thread__insert_map(thread, map); 1356 + ret = thread__insert_map(thread, map); 1357 + if (ret) 1358 + goto out_problem_insert; 1359 + 1357 1360 thread__put(thread); 1358 1361 map__put(map); 1359 1362 return 0; 1360 1363 1364 + out_problem_insert: 1365 + map__put(map); 1361 1366 out_problem_map: 1362 1367 thread__put(thread); 1363 1368 out_problem: ··· 1408 1403 if (map == NULL) 1409 1404 goto out_problem_map; 1410 1405 1411 - thread__insert_map(thread, map); 1406 + ret = thread__insert_map(thread, map); 1407 + if (ret) 1408 + goto out_problem_insert; 1409 + 1412 1410 thread__put(thread); 1413 1411 map__put(map); 1414 1412 return 0; 1415 1413 1414 + out_problem_insert: 1415 + map__put(map); 1416 1416 out_problem_map: 1417 1417 thread__put(thread); 1418 1418 out_problem:
+9 -4
tools/perf/util/thread.c
··· 43 43 thread->cpu = -1; 44 44 INIT_LIST_HEAD(&thread->comm_list); 45 45 46 - if (unwind__prepare_access(thread) < 0) 47 - goto err_thread; 48 - 49 46 comm_str = malloc(32); 50 47 if (!comm_str) 51 48 goto err_thread; ··· 198 201 map_groups__fprintf(thread->mg, fp); 199 202 } 200 203 201 - void thread__insert_map(struct thread *thread, struct map *map) 204 + int thread__insert_map(struct thread *thread, struct map *map) 202 205 { 206 + int ret; 207 + 208 + ret = unwind__prepare_access(thread); 209 + if (ret) 210 + return ret; 211 + 203 212 map_groups__fixup_overlappings(thread->mg, map, stderr); 204 213 map_groups__insert(thread->mg, map); 214 + 215 + return 0; 205 216 } 206 217 207 218 static int thread__clone_map_groups(struct thread *thread,
+1 -1
tools/perf/util/thread.h
··· 76 76 struct comm *thread__comm(const struct thread *thread); 77 77 struct comm *thread__exec_comm(const struct thread *thread); 78 78 const char *thread__comm_str(const struct thread *thread); 79 - void thread__insert_map(struct thread *thread, struct map *map); 79 + int thread__insert_map(struct thread *thread, struct map *map); 80 80 int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp); 81 81 size_t thread__fprintf(struct thread *thread, FILE *fp); 82 82