public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>,
	Stephane Eranian <eranian@google.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Subject: Re: git bisect and perf
Date: Tue, 05 Jun 2012 19:35:12 +0200	[thread overview]
Message-ID: <1338917712.2749.24.camel@twins> (raw)
In-Reply-To: <4FCE3DE3.9060805@gmail.com>

On Tue, 2012-06-05 at 11:12 -0600, David Ahern wrote:
> On 6/5/12 10:05 AM, Peter Zijlstra wrote:
> > On Tue, 2012-06-05 at 18:00 +0200, Peter Zijlstra wrote:
> >> On Tue, 2012-06-05 at 09:29 -0600, David Ahern wrote:
> >>> I am trying find out when (ie. which commit) the pebs feature
> >>> actually
> >>> started working on a westmere system
> >>
> >> What do you mean with working? The whole cycles:pp thing is magic and
> >> unrelated to 'regular' PEBS stuff.
> 
> :p requires PEBS?

On Intel it does.. On AMD you want IBS for that.

Note that on Intel there's a difference between :p and :pp.

>From perf_event_attr:

        /*
         * precise_ip:
         *
         *  0 - SAMPLE_IP can have arbitrary skid
         *  1 - SAMPLE_IP must have constant skid
         *  2 - SAMPLE_IP requested to have 0 skid
         *  3 - SAMPLE_IP must have 0 skid
         *
         *  See also PERF_RECORD_MISC_EXACT_IP
         */
        precise_ip     :  2, /* skid constraint       */

So 0 being the default (no :p) we use the regular PMI and provide the IP
from the spot that served the exception. This can be a few instructions
_after_ the instruction that triggered the event overflow.

1 (:p) means constant skid, for Intel this maps to regular PEBS and
returns the IP as provided by the PEBS record. This is one instruction
after the instruction that caused the event overflow (because the PEBS
hardware assist triggers when we're executing the instruction that
triggered it, it needs to have already fetched the instruction and
incremented the IP etc..).

2 (:pp) requests 0 skid, since PEBS provides IP + 1 instruction, we need
to rewind the instruction stream. In order to do this we use the LBR in
conjunction with a FREEZE_LBR_ON_PMI feature from DEBUG_CTL and limit
the PEBS buffer to a single entry. So when we get the PEBS buffer full
PMI, we read the LBR, find the start of the most recent basic block (to
address of the last branch) and decode the instruction stream until we
find the current IP. Then we know the IP that caused it is the previous
one. Tada!

We set the PERF_RECORD_MISC_EXACT_IP bit when the rewind worked and we
can guarantee 0 skid (+- hardware bugs, of which there are a few).

3 (:ppp) would require 0 skid, but since the unwind using LBR isn't a
guaranteed thing we don't implement this for Intel (or anybody else for
that matter afaik).


Now not all events the Intel PMU can do are PEBS capable; in fact most
aren't. So the whole cycles thing is about mapping the regular cycles
event to something that is PEBS capable.



  reply	other threads:[~2012-06-05 17:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-05 15:29 git bisect and perf David Ahern
2012-06-05 15:51 ` Roland Dreier
2012-06-05 16:56   ` David Ahern
2012-06-05 16:00 ` Peter Zijlstra
2012-06-05 16:05   ` Peter Zijlstra
2012-06-05 17:12     ` David Ahern
2012-06-05 17:35       ` Peter Zijlstra [this message]
2012-06-05 23:48         ` David Ahern
2012-06-06 11:46           ` Stephane Eranian
2012-06-05 19:04       ` Stephane Eranian
2012-06-05 19:08         ` David Ahern

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=1338917712.2749.24.camel@twins \
    --to=peterz@infradead.org \
    --cc=acme@ghostprotocols.net \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox