From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Ingo Molnar <mingo@elte.hu>
Cc: Andi Kleen <andi@firstfloor.org>,
Alexander van Heukelum <heukelum@fastmail.fm>,
Cyrill Gorcunov <gorcunov@gmail.com>,
Alexander van Heukelum <heukelum@mailshack.com>,
LKML <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
lguest@ozlabs.org, jeremy@xensource.com,
Steven Rostedt <srostedt@redhat.com>,
Mike Travis <travis@sgi.com>
Subject: Re: [PATCH RFC/RFB] x86_64, i386: interrupt dispatch changes
Date: Fri, 14 Nov 2008 12:11:22 +1100 [thread overview]
Message-ID: <200811141211.23496.nickpiggin@yahoo.com.au> (raw)
In-Reply-To: <20081105102643.GA11383@elte.hu>
Sorry to reply so late on this slightly offtopic rant...
On Wednesday 05 November 2008 21:26, Ingo Molnar wrote:
> * Andi Kleen <andi@firstfloor.org> wrote:
> > On Tue, Nov 04, 2008 at 09:44:00PM +0100, Ingo Molnar wrote:
> > > It's only an issue on ancient CPUs that export all their LOCKed
> > > cycles to the bus. Pentium and older or so. The PPro got it right
> > > already.
> >
> > ??? LOCK slowness is not because of the bus. And I know you know
> > that Ingo, so I don't know why you wrote that bogosity above.
>
> .. of course the historic LOCK slowness was all due to the system bus:
> very old CPUs exported a LOCK signal to the system bus for every
> LOCK-prefix access (implicit and explicit) and that made it _really_
> expensive. (hundreds of cycles)
>
> ... on reasonably modern CPUs the LOCK-ed access has been abstracted
> away to within the CPU, and the cost of LOCK-ed access is rather low
> (think 10-20 cycles - of course only if there's no cache miss cost)
> (That's obviously the case with the GDT, with is both per CPU and well
> cached.)
Locked instruction AFAIR is about 50 cycles on Core2. I think it is
a bit lower on K8. On Nehalem, which has optimisations for these,
I have heard it is still about 20-25 cycles. Although I don't have
one, so I don't actually know.
These (on my Core2) don't seem to pipeline at all with other
instructions either. So on my Core2, a locked instruction is worth
maybe 150-200 regular pipelined, superscalar instructions.
There is another big reason why lock instructions are expensive,
and that is because they have to prevent subsequent loads from
passing any previous stores becoming visible. This in theory could
be somewhat speculated, but no matter what happens, the program
visible state can't be committed until the stores are.
I heard from an Intel hardware engineer that Nehalem has some
really fancy logic in it to make locked instructions "free", that
was nacked from earlier CPUs because it was too costly. So obviously
it is taking a fair whack of transistors or power for them to do it.
And even then it is far from free, but still seems to be one or two
orders of magnitude more expensive than a regular instruction.
> on _really_ modern CPUs LOCK can be as cheap as just a few cycles - so
Oh, maybe I'm mistaken about Nehalem then? How many is "just a few"?
If it is 25 non-pipelined cycles, then that's still 100 instructions
if it is a 4 issue machine.
> low that we can stop bothering about it in the future. There's no
> fundamental physical reason why the LOCK prefix (implicit or explicit)
> should be expensive.
Even if they could make it free on the software side, it is obviously
expensive on the hardware side. Not bothering about it is a copout.
The atomic instruction speedups in Nehalem are cool, but what would
have been even cooler is if Intel had decided *not* to spend resources
making this cheaper because they found Linux has so few locked
instructions :)
Even if somehow the x86 ISA didn't have the implicit memory ordering
requirement in the lock instruction, I think it's obviously a special
case path that doesn't fit in with a load/store uarch (whether they
implement it in uops with ll/sc like thing or whatnot, it's going to
need special logic).
IMO, we shouldn't stop bothering about LOCK prefix in the forseeable
future.
next prev parent reply other threads:[~2008-11-14 1:11 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-04 12:28 Alexander van Heukelum
2008-11-04 12:42 ` Ingo Molnar
2008-11-04 13:29 ` Alexander van Heukelum
2008-11-04 14:00 ` Ingo Molnar
2008-11-04 16:23 ` Alexander van Heukelum
2008-11-04 16:47 ` Cyrill Gorcunov
2008-11-04 16:58 ` Ingo Molnar
2008-11-04 17:13 ` Cyrill Gorcunov
2008-11-04 17:29 ` Alexander van Heukelum
2008-11-06 9:19 ` Ingo Molnar
2008-11-04 20:02 ` Jeremy Fitzhardinge
2008-11-04 20:15 ` H. Peter Anvin
2008-11-04 20:02 ` Jeremy Fitzhardinge
2008-11-04 15:07 ` Cyrill Gorcunov
2008-11-04 15:47 ` Alexander van Heukelum
2008-11-04 16:36 ` Ingo Molnar
2008-11-04 16:45 ` Alexander van Heukelum
2008-11-04 16:54 ` Ingo Molnar
2008-11-04 16:55 ` Ingo Molnar
2008-11-04 16:58 ` Alexander van Heukelum
2008-11-04 17:39 ` Alexander van Heukelum
2008-11-04 17:05 ` Andi Kleen
2008-11-04 18:06 ` Alexander van Heukelum
2008-11-04 18:14 ` H. Peter Anvin
2008-11-04 18:44 ` Alexander van Heukelum
2008-11-04 19:07 ` H. Peter Anvin
2008-11-04 19:33 ` H. Peter Anvin
2008-11-04 20:06 ` Jeremy Fitzhardinge
2008-11-04 20:30 ` Andi Kleen
2008-11-04 20:26 ` H. Peter Anvin
2008-11-04 20:46 ` Andi Kleen
2008-11-04 20:44 ` Ingo Molnar
2008-11-04 21:06 ` Andi Kleen
2008-11-05 0:42 ` Jeremy Fitzhardinge
2008-11-05 0:50 ` H. Peter Anvin
2008-11-06 9:15 ` Ingo Molnar
2008-11-06 9:25 ` H. Peter Anvin
2008-11-06 9:30 ` Ingo Molnar
2008-11-05 10:26 ` Ingo Molnar
2008-11-14 1:11 ` Nick Piggin [this message]
2008-11-14 1:20 ` H. Peter Anvin
2008-11-14 2:12 ` Nick Piggin
2008-11-04 21:29 ` Ingo Molnar
2008-11-04 21:35 ` H. Peter Anvin
2008-11-04 21:52 ` Ingo Molnar
2008-11-05 17:53 ` Cyrill Gorcunov
2008-11-05 18:04 ` H. Peter Anvin
2008-11-05 18:14 ` Cyrill Gorcunov
2008-11-05 18:20 ` H. Peter Anvin
2008-11-05 18:26 ` Cyrill Gorcunov
[not found] ` <1226243805.27361.1283784629@webmail.messagingengine.com>
2008-11-10 1:29 ` H. Peter Anvin
2008-11-26 21:35 ` [Lguest] " Avi Kivity
2008-11-26 21:50 ` Avi Kivity
2008-11-27 0:03 ` H. Peter Anvin
2008-11-27 10:13 ` Avi Kivity
2008-11-27 10:56 ` Andi Kleen
2008-11-27 10:59 ` Avi Kivity
2008-11-28 20:48 ` Alexander van Heukelum
2008-11-29 15:45 ` Alexander van Heukelum
2008-11-29 18:21 ` Avi Kivity
2008-11-29 18:22 ` Avi Kivity
2008-11-29 19:58 ` Ingo Molnar
2008-12-01 4:32 ` Rusty Russell
2008-12-01 8:00 ` Ingo Molnar
2008-12-01 9:24 ` Avi Kivity
2008-12-01 10:32 ` Cyrill Gorcunov
2008-12-01 10:41 ` Avi Kivity
2008-12-01 10:49 ` Ingo Molnar
2008-11-10 8:58 ` Ingo Molnar
2008-11-10 12:44 ` Alexander van Heukelum
2008-11-10 13:07 ` Ingo Molnar
2008-11-10 21:35 ` Alexander van Heukelum
2008-11-10 22:21 ` H. Peter Anvin
2008-11-11 5:00 ` H. Peter Anvin
2008-11-13 22:23 ` Matt Mackall
2008-11-14 1:18 ` H. Peter Anvin
2008-11-14 2:29 ` Matt Mackall
2008-11-14 3:22 ` H. Peter Anvin
2008-11-11 9:54 ` Ingo Molnar
2008-11-10 15:39 ` H. Peter Anvin
2008-11-10 21:44 ` Alexander van Heukelum
2008-11-10 23:34 ` H. Peter Anvin
2008-11-05 18:15 ` Cyrill Gorcunov
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=200811141211.23496.nickpiggin@yahoo.com.au \
--to=nickpiggin@yahoo.com.au \
--cc=andi@firstfloor.org \
--cc=gorcunov@gmail.com \
--cc=heukelum@fastmail.fm \
--cc=heukelum@mailshack.com \
--cc=hpa@zytor.com \
--cc=jeremy@xensource.com \
--cc=lguest@ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=srostedt@redhat.com \
--cc=tglx@linutronix.de \
--cc=travis@sgi.com \
/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
all inboxes | Powered by JetHome®