Skip to content

Commit

Permalink
perf tools: Add dedicated unwind addr_space member into thread struct
Browse files Browse the repository at this point in the history
Milian reported issue with thread::priv, which was double booked by perf
trace and DWARF unwind code. So using those together is impossible at
the moment.

Moving DWARF unwind private data into separate variable so perf trace
can keep using thread::priv.

Reported-and-Tested-by: Milian Wolff <milian.wolff@kdab.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andreas Hollmann <hollmann@in.tum.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1460013073-18444-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed Apr 8, 2016
1 parent 7d6a7e7 commit e583d70
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
6 changes: 6 additions & 0 deletions tools/perf/util/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include "symbol.h"
#include <strlist.h>
#include <intlist.h>
#ifdef HAVE_LIBUNWIND_SUPPORT
#include <libunwind.h>
#endif

struct thread_stack;

Expand All @@ -32,6 +35,9 @@ struct thread {

void *priv;
struct thread_stack *ts;
#ifdef HAVE_LIBUNWIND_SUPPORT
unw_addr_space_t addr_space;
#endif
};

struct machine;
Expand Down
25 changes: 9 additions & 16 deletions tools/perf/util/unwind-libunwind.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "symbol.h"
#include "util.h"
#include "debug.h"
#include "asm/bug.h"

extern int
UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
Expand Down Expand Up @@ -580,43 +581,33 @@ static unw_accessors_t accessors = {

int unwind__prepare_access(struct thread *thread)
{
unw_addr_space_t addr_space;

if (callchain_param.record_mode != CALLCHAIN_DWARF)
return 0;

addr_space = unw_create_addr_space(&accessors, 0);
if (!addr_space) {
thread->addr_space = unw_create_addr_space(&accessors, 0);
if (!thread->addr_space) {
pr_err("unwind: Can't create unwind address space.\n");
return -ENOMEM;
}

unw_set_caching_policy(addr_space, UNW_CACHE_GLOBAL);
thread__set_priv(thread, addr_space);

unw_set_caching_policy(thread->addr_space, UNW_CACHE_GLOBAL);
return 0;
}

void unwind__flush_access(struct thread *thread)
{
unw_addr_space_t addr_space;

if (callchain_param.record_mode != CALLCHAIN_DWARF)
return;

addr_space = thread__priv(thread);
unw_flush_cache(addr_space, 0, 0);
unw_flush_cache(thread->addr_space, 0, 0);
}

void unwind__finish_access(struct thread *thread)
{
unw_addr_space_t addr_space;

if (callchain_param.record_mode != CALLCHAIN_DWARF)
return;

addr_space = thread__priv(thread);
unw_destroy_addr_space(addr_space);
unw_destroy_addr_space(thread->addr_space);
}

static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
Expand All @@ -639,7 +630,9 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
* unwind itself.
*/
if (max_stack - 1 > 0) {
addr_space = thread__priv(ui->thread);
WARN_ONCE(!ui->thread, "WARNING: ui->thread is NULL");
addr_space = ui->thread->addr_space;

if (addr_space == NULL)
return -1;

Expand Down

0 comments on commit e583d70

Please sign in to comment.