Re: [PATCH v2 1/2] perf callchain: Create an address space per thread

From: Jiri Olsa
Date: Mon Sep 29 2014 - 04:35:23 EST


On Mon, Sep 29, 2014 at 01:58:11PM +0900, Namhyung Kim wrote:
> The unw_addr_space_t in libunwind represents an address space to be
> used for stack unwinding. It doesn't need to be create/destory
> everytime to unwind callchain (as in get_entries) and can have a same
> lifetime as thread (unless exec called).
>
> So move the address space construction/destruction logic to the thread
> lifetime handling functions. This is a preparation to enable caching
> in the unwind library.
>
> Note that it saves unw_addr_space_t object using thread__set_priv().
> It seems currently only used by perf trace and perf kvm stat commands
> which don't use callchain.
>
> Acked-by: Jean Pihet <jean.pihet@xxxxxxxxxx>
> Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
> Cc: Arun Sharma <asharma@xxxxxx>
> Cc: David Ahern <dsahern@xxxxxxxxx>
> Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
> Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
> ---
> tools/perf/util/thread.c | 6 ++++++
> tools/perf/util/unwind-libunwind.c | 30 +++++++++++++++++++++++++-----
> tools/perf/util/unwind.h | 17 +++++++++++++++++
> 3 files changed, 48 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
> index a9df7f2c6dc9..2b7b2d91c016 100644
> --- a/tools/perf/util/thread.c
> +++ b/tools/perf/util/thread.c
> @@ -7,6 +7,7 @@
> #include "util.h"
> #include "debug.h"
> #include "comm.h"
> +#include "unwind.h"
>
> int thread__init_map_groups(struct thread *thread, struct machine *machine)
> {
> @@ -37,6 +38,9 @@ struct thread *thread__new(pid_t pid, pid_t tid)
> thread->cpu = -1;
> INIT_LIST_HEAD(&thread->comm_list);
>
> + if (unwind__prepare_access(thread) < 0)
> + goto err_thread;

So this is something we need to do only for DWARF unwind via libunwind.
Do we want some condition to bypass this in for the rest of the cases?

I think we could check for symbol_conf.use_callchain and for the
PERF_SAMPLE_REGS_USER|PERF_SAMPLE_STACK_USER sample types in evlist,
something like:

bool has_dwarf_data_for_callchains = symbol_conf.use_callchain && evlist_sample_type_has(evlist, PERF_SAMPLE_REGS_USER|PERF_SAMPLE_STACK_USER)

;-)

thanks,
jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/