public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Zachary Amsden <zamsden@redhat.com>,
	linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org, Avi Kivity <avi@redhat.com>
Subject: Re: [PATCH] x86 rwsem optimization extreme
Date: Wed, 17 Feb 2010 17:59:38 -0800	[thread overview]
Message-ID: <4B7C9F0A.1080708@zytor.com> (raw)
In-Reply-To: <alpine.LFD.2.00.1002171743200.4141@localhost.localdomain>

On 02/17/2010 05:53 PM, Linus Torvalds wrote:
>>
>> FWIW, I don't know of any microarchitecture where adc is slower than
>> add, *as long as* the setup time for the CF flag is already used up.
> 
> Oh, I think there are lots.
> 
> Look at just about any x86 latency/throughput table, and you'll see:
> 
>  - adc latencies are typically much higher than a single cycle
> 
>    But you are right that this is likel not an issue on any out-of-order 
>    chip, since the 'stc' will schedule perfectly.
> 

STC actually tends to schedule poorly, since it has a partial register
stall.  In-order or out-of-order doesn't really matter, though; what
matters is that the scoreboarding used for the flags has to settle, or
you will take a huge hit.

>  - but adc _throughput_ is also typically much higher, which indicates 
>    that even if you do flag renaming, the 'adc' quite likely only 
>    schedules in a single ALU unit.
> 
> For example, on a Pentium, adc/sbb can only go in the U pipe, and I think 
> the same is true of 'stc'. Now, nobody likely cares about Pentiums any 
> more, but the point is, 'adc' does often have constraints that a regular 
> 'add' does not, and there's an example of a 'stc+adc' pair would at the 
> very least have to be scheduled with an instruction in between.

No doubt.  I doubt it much matters in this context, but either way I
think the patch is probably a bad idea... much for the same as my incl
hack was - since the code isn't actually inline, saving a handful bytes
is not the right tradeoff.

	-hpa


  reply	other threads:[~2010-02-18  2:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-17 21:58 [PATCH] x86 rwsem optimization extreme Zachary Amsden
2010-02-17 22:10 ` Linus Torvalds
2010-02-17 22:29   ` H. Peter Anvin
2010-02-17 23:29   ` H. Peter Anvin
2010-02-18  1:03     ` Zachary Amsden
2010-02-18  1:53     ` Linus Torvalds
2010-02-18  1:59       ` H. Peter Anvin [this message]
2010-02-18  4:25         ` Zachary Amsden
2010-02-18  8:12           ` Andi Kleen
2010-02-18  8:24             ` Zachary Amsden
2010-02-18  9:29               ` Andi Kleen
2010-02-18 10:55               ` Ingo Molnar

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=4B7C9F0A.1080708@zytor.com \
    --to=hpa@zytor.com \
    --cc=avi@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    --cc=zamsden@redhat.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