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

perf unwind: Add initialized arg into unwind__prepare_access

Adding initialized arg into unwind__prepare_access to get feedback about
the initialization state.

It's not possible to get it from error code, because we return 0 even in
case we don't recognize dso, which is valid.

The 'initialized' value is used in following patch to speedup
unwind__prepare_access calls logic in fork path.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1467634583-29147-4-git-send-email-jolsa@kernel.org
[ Remove ; after static inline function signatures, fixes build break ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
a2873325 347ca878

+16 -6
+1 -1
tools/perf/util/thread.c
··· 202 202 { 203 203 int ret; 204 204 205 - ret = unwind__prepare_access(thread, map); 205 + ret = unwind__prepare_access(thread, map, NULL); 206 206 if (ret) 207 207 return ret; 208 208
+9 -2
tools/perf/util/unwind-libunwind.c
··· 14 14 thread->unwind_libunwind_ops = ops; 15 15 } 16 16 17 - int unwind__prepare_access(struct thread *thread, struct map *map) 17 + int unwind__prepare_access(struct thread *thread, struct map *map, 18 + bool *initialized) 18 19 { 19 20 const char *arch; 20 21 enum dso_type dso_type; 21 22 struct unwind_libunwind_ops *ops = local_unwind_libunwind_ops; 23 + int err; 22 24 23 25 if (thread->addr_space) { 24 26 pr_debug("unwind: thread map already set, dso=%s\n", 25 27 map->dso->name); 28 + if (initialized) 29 + *initialized = true; 26 30 return 0; 27 31 } 28 32 ··· 55 51 out_register: 56 52 unwind__register_ops(thread, ops); 57 53 58 - return thread->unwind_libunwind_ops->prepare_access(thread); 54 + err = thread->unwind_libunwind_ops->prepare_access(thread); 55 + if (initialized) 56 + *initialized = err ? false : true; 57 + return err; 59 58 } 60 59 61 60 void unwind__flush_access(struct thread *thread)
+6 -3
tools/perf/util/unwind.h
··· 42 42 #endif 43 43 44 44 int LIBUNWIND__ARCH_REG_ID(int regnum); 45 - int unwind__prepare_access(struct thread *thread, struct map *map); 45 + int unwind__prepare_access(struct thread *thread, struct map *map, 46 + bool *initialized); 46 47 void unwind__flush_access(struct thread *thread); 47 48 void unwind__finish_access(struct thread *thread); 48 49 #else 49 50 static inline int unwind__prepare_access(struct thread *thread __maybe_unused, 50 - struct map *map __maybe_unused) 51 + struct map *map __maybe_unused, 52 + bool *initialized __maybe_unused) 51 53 { 52 54 return 0; 53 55 } ··· 69 67 } 70 68 71 69 static inline int unwind__prepare_access(struct thread *thread __maybe_unused, 72 - struct map *map __maybe_unused) 70 + struct map *map __maybe_unused, 71 + bool *initialized __maybe_unused) 73 72 { 74 73 return 0; 75 74 }