All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Stephane Eranian <eranian@google.com>
Cc: Namhyung Kim <namhyung@kernel.org>,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	Arun Sharma <asharma@fb.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@redhat.com>
Subject: Re: [RFC/PATCHSET 00/15] perf report: Add support to accumulate hist periods
Date: Fri, 28 Sep 2012 17:14:18 +0200	[thread overview]
Message-ID: <20120928151407.GA14215@somewhere.redhat.com> (raw)
In-Reply-To: <CABPqkBQbaDdGwyOK-qcheqyTzrr505undnFae8BQGEx+r0hKyg@mail.gmail.com>

On Fri, Sep 28, 2012 at 09:07:57AM +0200, Stephane Eranian wrote:
> On Fri, Sep 28, 2012 at 7:49 AM, Namhyung Kim <namhyung@kernel.org> wrote:
> > Hi Frederic,
> >
> > On Fri, 28 Sep 2012 01:01:48 +0200, Frederic Weisbecker wrote:
> >> When Arun was working on this, I asked him to explore if it could make sense to reuse
> >> the "-b, --branch-stack"  perf report option. Because after all, this feature is doing
> >> about the same than "-b" except it's using callchains instead of full branch tracing.
> >> But callchains are branches. Just a limited subset of all branches taken on excecution.
> >> So you can probably reuse some interface and even ground code there.
> >>
> >> What do you think?
> >
> > Umm.. first of all, I'm not familiar with the branch stack thing.  It's
> > intel-specific, right?
> >
> The kernel API is NOT specific to Intel. It is abstracted to be portable
> across architecture. The implementation only exists on certain Intel
> X86 processors.
> 
> > Also I don't understand what exactly you want here.  What kind of
> > interface did you say?  Can you elaborate it bit more?
> >
> Not clear to me either.
> 
> > And AFAIK branch stack can collect much more branch information than
> > just callstacks.  Can we differentiate which is which easily?  Is there
> > any limitation on using it?  What if callstacks are not sync'ed with
> > branch stacks - is it possible though?
> >
> First of all branch stack is not a branch tracing mechanism. This is a
> branch sampling mechanism. Not all branches are captured. Only the
> last N consecutive branches leading to a PMU interrupt are captured
> in each sample.
> 
> Yes, the branch stack mechanism as it exists on Intel processors
> can capture more then call branches. It is HW based and provides
> a branch type filter. Filtering capability is exposed at the API level
> in a generic fashion. The hw filter is based on opcodes. Call branches
> all cover call, syscall instructions. As such, the branch stack mechanism
> cannot be used to capture callstacks to shared libraries, simply because
> there a a non call instruction in the trampoline. To obtain a better quality
> callstack you have instead to sample return branches. So yes, callstacks
> are not sync'ed with branch stack even if limited to call branches.
> 

You're right. One doesn't simply sample callchains on top of branch tracing. Not easily at least.
But that's not what we want here. We want the other way round: use callchains as branch sampling.
And a callchain _is_ a branch sampling. Just a specialized one.

PERF_SAMPLE_BRANCH_STACK either records only calls, only ret, or everything, or....
You can define the filter with "-j" option. Now callchains can be considered as the result
of a specific "-j" filter option. It's just a high level filtering. ie: not just based on opcode
types but on semantic post-processing. As if we applied a specific filter on a pure branch tracing
that cancelled calls that had matching ret.

But in the end, what we have is just branches. Some branch layout that is biased, that already passed
through a semantic wheel, still it's just _branches_.

Note I'm not arguing about adding a "-j callchain" option, just trying to show you that callchains
are not really different from other filtered source of branch sampling.


> > But I think it'd be good if the branch stack can be changed to call
> > stack in general.  Did you mean this?
> >
> That's not going to happen. The mechanism is much more generic than
> that.
> 
> Quite frankly, I don't understand Frederic's motivation here. The mechanism
> are not quite the same.

So, considering that callchains are just "branches", why can't we use them as
a branch source, just like PERF_SAMPLE_BRANCH_STACK data samples, that we
can reuse in "perf report -b".

Look at commit b50311dc2ac1c04ad19163c2359910b25e16caf6
"perf report: Add support for taken branch sampling". It's doing (except for a few details
like the period weight of branch samples) the same than in Namhyung patch, just with
PERF_SAMPLE_BRANCH_STACK instead of callchains.

I don't understand what justifies this duplication.

  reply	other threads:[~2012-09-28 15:14 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-13  7:19 [RFC/PATCHSET 00/15] perf report: Add support to accumulate hist periods Namhyung Kim
2012-09-13  7:19 ` [PATCH 01/15] perf hists: Add missing period_* fields when collapsing a hist entry Namhyung Kim
2012-09-13  7:19 ` [PATCH 02/15] perf hists: Introduce struct he_stat Namhyung Kim
2012-09-13  7:19 ` [PATCH 03/15] perf hists: Move he->stat.nr_events initialization to a template Namhyung Kim
2012-09-13  7:20 ` [PATCH 04/15] perf hists: Convert hist entry functions to use struct he_stat Namhyung Kim
2012-09-13  7:20 ` [PATCH 05/15] perf hists: Add more helpers for hist entry stat Namhyung Kim
2012-09-13  7:20 ` [PATCH 06/15] perf hists: Add support for accumulated stat of hist entry Namhyung Kim
2012-09-13  7:20 ` [PATCH 07/15] perf hists: Check if accumulated when adding a " Namhyung Kim
2012-09-13  7:20 ` [PATCH 08/15] perf callchain: Add a couple of callchain helpers Namhyung Kim
2012-09-13  7:20 ` [PATCH 09/15] perf hists: Let add_hist_entry to make a hist entry template Namhyung Kim
2012-09-13  7:20 ` [PATCH 10/15] perf hists: Accumulate hist entry stat based on the callchain Namhyung Kim
2012-09-13  7:20 ` [PATCH 11/15] perf hists: Sort hist entries by accumulated period Namhyung Kim
2012-09-13  7:20 ` [PATCH 12/15] perf ui/hist: Add support to accumulated hist stat Namhyung Kim
2012-09-13  7:20 ` [PATCH 13/15] perf ui/browser: " Namhyung Kim
2012-09-13  7:20 ` [PATCH 14/15] perf ui/gtk: " Namhyung Kim
2012-09-13  7:20 ` [PATCH 15/15] perf report: Add --cumulate option Namhyung Kim
2012-09-20 17:33 ` [RFC/PATCHSET 00/15] perf report: Add support to accumulate hist periods Arun Sharma
2012-09-25  4:57 ` Namhyung Kim
2012-09-27 23:01   ` Frederic Weisbecker
2012-09-28  5:49     ` Namhyung Kim
2012-09-28  7:07       ` Stephane Eranian
2012-09-28 15:14         ` Frederic Weisbecker [this message]
2012-09-28 16:36           ` Stephane Eranian
2012-09-28 15:27       ` Frederic Weisbecker
2012-10-29 19:08 ` Peter Zijlstra
2012-10-29 21:36   ` Arun Sharma
2012-10-30  6:59     ` Namhyung Kim
2012-10-30  8:17       ` Peter Zijlstra
2012-10-30  9:01         ` Ingo Molnar
2012-10-31  7:24           ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120928151407.GA14215@somewhere.redhat.com \
    --to=fweisbec@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=asharma@fb.com \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.