perf unwind: Fix libunwind when tid != pid
Commite5adfc3e7e
("perf map: Synthesize maps only for thread group leader") changed the recording side so that we no longer get mmap events for threads other than the thread group leader (when synthesising these events for threads which exist before perf is started). When a file recorded after this change is loaded, the lack of mmap records mean that unwinding is not set up for any other threads. This can be seen in a simple record/report scenario: perf record --call-graph=dwarf -t $TID perf report If $TID is a process ID then the report will show call graphs, but if $TID is a secondary thread the output is as if --call-graph=none was specified. Following the rationale in that commit, move the libunwind fields into struct map_groups and update the libunwind functions to take this instead of the struct thread. This is only required for unwind__finish_access which must now be called from map_groups__delete and the others are changed for symmetry. Note that unwind__get_entries keeps the thread argument since it is required for symbol lookup and the libdw unwind provider uses the thread ID. Signed-off-by: John Keeping <john@metanate.com> Reviewed-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Fixes:e5adfc3e7e
("perf map: Synthesize maps only for thread group leader") Link: http://lkml.kernel.org/r/20190815100146.28842-2-john@metanate.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
ab6cd0e527
commit
e8ba2906f6
@@ -616,26 +616,26 @@ static unw_accessors_t accessors = {
|
||||
.get_proc_name = get_proc_name,
|
||||
};
|
||||
|
||||
static int _unwind__prepare_access(struct thread *thread)
|
||||
static int _unwind__prepare_access(struct map_groups *mg)
|
||||
{
|
||||
thread->addr_space = unw_create_addr_space(&accessors, 0);
|
||||
if (!thread->addr_space) {
|
||||
mg->addr_space = unw_create_addr_space(&accessors, 0);
|
||||
if (!mg->addr_space) {
|
||||
pr_err("unwind: Can't create unwind address space.\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
unw_set_caching_policy(thread->addr_space, UNW_CACHE_GLOBAL);
|
||||
unw_set_caching_policy(mg->addr_space, UNW_CACHE_GLOBAL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _unwind__flush_access(struct thread *thread)
|
||||
static void _unwind__flush_access(struct map_groups *mg)
|
||||
{
|
||||
unw_flush_cache(thread->addr_space, 0, 0);
|
||||
unw_flush_cache(mg->addr_space, 0, 0);
|
||||
}
|
||||
|
||||
static void _unwind__finish_access(struct thread *thread)
|
||||
static void _unwind__finish_access(struct map_groups *mg)
|
||||
{
|
||||
unw_destroy_addr_space(thread->addr_space);
|
||||
unw_destroy_addr_space(mg->addr_space);
|
||||
}
|
||||
|
||||
static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
|
||||
@@ -660,7 +660,7 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
|
||||
*/
|
||||
if (max_stack - 1 > 0) {
|
||||
WARN_ONCE(!ui->thread, "WARNING: ui->thread is NULL");
|
||||
addr_space = ui->thread->addr_space;
|
||||
addr_space = ui->thread->mg->addr_space;
|
||||
|
||||
if (addr_space == NULL)
|
||||
return -1;
|
||||
|
Reference in New Issue
Block a user