From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: "Lénaïc Huard" <lenaic@lhuard.fr.eu.org>
Cc: Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@elte.hu>,
Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
linux-kernel@vger.kernel.org
Subject: Re: Shift by one instruction in the perf annotate output
Date: Fri, 27 Jan 2012 09:15:20 +0100 [thread overview]
Message-ID: <1327652120.2446.123.camel@twins> (raw)
In-Reply-To: <201201270001.27765.lenaic@lhuard.fr.eu.org>
On Fri, 2012-01-27 at 00:01 +0100, Lénaïc Huard wrote:
> Using perf and zooming up to the annotated assembler, I noticed a “shift by
> one” issue between the assembler instructions and the reported consumed cycles
> in the left margin.
> Each time a given instruction is expensive, the high event count appears on
> the line right after.
> In order to validate that feeling, I tried to put an expensive instruction
> (division) inside a block of cheaper instructions (no operation). And here is
> the output of perf annotate:
>
> 0,00 : 40041d: nop
> 0,00 : 40041e: nop
> 5,31 : 40041f: nop
> 0,00 : 400420: divl (%rsp)
> 84,18 : 400423: nop
> 0,00 : 400424: nop
> 0,07 : 400425: nop
>
> I would have expected the 84,18 count to be in front of the “divl” instruction
> and not in front of the “nop” one.
That's how it works on x86 (and a lot of other architectures), the divl
raises the interrupt line but the CPU can only assert the interrupt once
its completed the instruction its working on (sometimes more than one)
and you get a drift between when the interrupt was raised and when it
gets handled, its called skid and is a well known issue.
> I am running Linux and perf 3.2 but I remember that previous versions suffered
> from the same issue.
>
> I don’t know if it could be specific to my cpu:
> processor : 0
> vendor_id : GenuineIntel
> cpu family : 6
> model : 15
> model name : Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz
And sadly its the best you'll get on your machine, most Intel chips
after that (including the core2 shrink, but excluding the latest core i7
SNB) can do better using a feature called PEBS.
next prev parent reply other threads:[~2012-01-27 8:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-26 23:01 Shift by one instruction in the perf annotate output Lénaïc Huard
2012-01-27 6:50 ` Mike Galbraith
2012-01-27 8:15 ` Peter Zijlstra [this message]
2012-01-27 10:27 ` Ingo Molnar
2012-01-27 10:40 ` Peter Zijlstra
2012-01-27 10:44 ` Ingo Molnar
2012-01-27 10:49 ` Peter Zijlstra
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=1327652120.2446.123.camel@twins \
--to=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=lenaic@lhuard.fr.eu.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox