All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Zachary Amsden <zach@vmware.com>
Cc: Benjamin LaHaise <bcrl@kvack.org>,
	Chuck Ebbert <76306.1226@compuserve.com>,
	Linus Torvalds <torvalds@osdl.org>, Andi Kleen <ak@suse.de>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [rfc patch] i386: don't save eflags on task switch
Date: Sun, 05 Nov 2006 12:10:41 -0800	[thread overview]
Message-ID: <454E4541.7090807@zytor.com> (raw)
In-Reply-To: <454D65E8.3000409@vmware.com>

Zachary Amsden wrote:
> Benjamin LaHaise wrote:
>> On Sat, Nov 04, 2006 at 11:09:42AM -0800, Zachary Amsden wrote:
>>  
>>> Every processor I've ever measured it on, popf is slower.  On P4, for 
>>> example, pushf is 6 cycles, and popf is 54.  On Opteron, it is 2 / 
>>> 12.  On Xeon, it is 7 / 91.
>>
>> pushf has to wait until all flag dependancies can be resolved.  On the 
>> P4 with >100 instructions in flight, that can take a long time.  Popf 
>> on the other hand has no dependancies on outstanding instructions as 
>> it resets the machine state.
> 
> Yes, but as Linus points out popf is most likely microcoded, thus much 
> slower.  Flag dependency is not unique to pushf, many much more common 
> instructions (adc, jcc, sbc, cmovcc, movs, stos, ...) have flag 
> dependencies, which can still be pipeline forwarded.  I think the raw 
> cycle counts speak for themselves, despite the fact that I only measured 
> instruction latency, not throughput.  Using a branch to eliminate a 
> pushf is thus probably not a win in most cases.
> 

The "sane" decomposition of popf into uops something like this:

- Memory read
- Mask bits that are immutable in the current mode
- Trap to microcode on changing any bit that alters the pipeline state

The "trap to microcode" can obviously be arbitrarily expensive.  So when 
timing popf, it's also important to know *which* bits change.

The simplest case, obviously, is when no flags change.  I still *fully* 
expect that to be more painful than pushf ever is.

	-hpa

  reply	other threads:[~2006-11-05 20:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-04  6:56 [rfc patch] i386: don't save eflags on task switch Chuck Ebbert
2006-11-04 19:09 ` Zachary Amsden
2006-11-04 19:35   ` Linus Torvalds
2006-11-05  3:55   ` Benjamin LaHaise
2006-11-05  4:13     ` Linus Torvalds
2006-11-05  5:41       ` Andi Kleen
2006-11-05  8:01         ` Zachary Amsden
2006-11-05 17:01           ` Andi Kleen
2006-11-05 17:26             ` Linus Torvalds
2006-11-05 17:34               ` Arjan van de Ven
2006-11-05 17:51                 ` Linus Torvalds
2006-11-05 22:48                   ` Zachary Amsden
2006-11-05 18:52               ` Andi Kleen
2006-11-05 16:12         ` Linus Torvalds
2006-11-05 16:54           ` Andi Kleen
2006-11-05 17:20             ` Linus Torvalds
2006-11-05  4:17     ` Zachary Amsden
2006-11-05 20:10       ` H. Peter Anvin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-11-04  0:00 Chuck Ebbert
2006-11-04  0:46 ` Linus Torvalds
2006-11-04  1:36   ` Andi Kleen

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=454E4541.7090807@zytor.com \
    --to=hpa@zytor.com \
    --cc=76306.1226@compuserve.com \
    --cc=ak@suse.de \
    --cc=bcrl@kvack.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=zach@vmware.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 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.