[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20141117155425.GA31042@krava.brq.redhat.com>
Date: Mon, 17 Nov 2014 16:54:25 +0100
From: Jiri Olsa <jolsa@...hat.com>
To: kan.liang@...el.com
Cc: acme@...nel.org, a.p.zijlstra@...llo.nl, eranian@...gle.com,
linux-kernel@...r.kernel.org, mingo@...hat.com, paulus@...ba.org,
ak@...ux.intel.com
Subject: Re: [PATCH V3 3/3] perf tools: Construct LBR call chain
On Fri, Nov 14, 2014 at 08:44:12AM -0500, kan.liang@...el.com wrote:
SNIP
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index f4478ce..335c3a9 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -557,15 +557,63 @@ int perf_session_queue_event(struct perf_session *s, union perf_event *event,
> return 0;
> }
>
> -static void callchain__printf(struct perf_sample *sample)
> +static void callchain__printf(struct perf_evsel *evsel,
> + struct perf_sample *sample)
> {
> unsigned int i;
> + struct ip_callchain *callchain = sample->callchain;
> + bool lbr = has_branch_callstack(evsel);
>
> - printf("... chain: nr:%" PRIu64 "\n", sample->callchain->nr);
> + if (lbr) {
> + struct branch_stack *lbr_stack = sample->branch_stack;
> + u64 kernel_callchain_nr = callchain->nr;
>
> - for (i = 0; i < sample->callchain->nr; i++)
> + for (i = 0; i < kernel_callchain_nr; i++) {
> + if (callchain->ips[i] == PERF_CONTEXT_USER)
> + break;
> + }
> +
> + if ((i != kernel_callchain_nr) && lbr_stack->nr) {
> + u64 total_nr;
> + /*
> + * LBR callstack can only get user call chain,
> + * i is kernel call chain number,
> + * 1 is PERF_CONTEXT_USER.
> + *
> + * The user call chain is stored in LBR registers.
> + * LBR are pair registers. The caller is stored
> + * in "from" register, while the callee is stored
> + * in "to" register.
> + * For example, there is a call stack
> + * "A"->"B"->"C"->"D".
> + * The LBR registers will recorde like
> + * "C"->"D", "B"->"C", "A"->"B".
> + * So only the first "to" register and all "from"
> + * registers are needed to construct the whole stack.
> + */
Andi is using some sanity checks:
http://marc.info/?l=linux-kernel&m=141584447819894&w=2
I guess this could be applied in here, once his patch gets in.
jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists