mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Andi Kleen <ak@suse.de>
Cc: Benjamin LaHaise <bcrl@kvack.org>,
	Zachary Amsden <zach@vmware.com>,
	Chuck Ebbert <76306.1226@compuserve.com>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [rfc patch] i386: don't save eflags on task switch
Date: Sun, 5 Nov 2006 09:20:12 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0611050914030.25218@g5.osdl.org> (raw)
In-Reply-To: <200611051754.11982.ak@suse.de>



On Sun, 5 Nov 2006, Andi Kleen wrote:
> 
> > - mispredicted branches on a P4 are potentially worse than  
> > the popf cost.
> 
> They are far less than 48 cycles. The P4 is not _that_ bad in this
> area.

You wanna bet? Use the newer P4 cores. A branch mispredict is over 20 
cycles, and I bet the "sti" isn't cheap either.

In other words, I suspect the difference between "popfl" and "conditional 
jump over sti" is basically zero - exactly because the sti isn't exactly a 
no-op.

(Enabling interrupts is actually much more complex than you'd expect. 
Interrupt delivery in a HT core is not simple in itself, and "sti" in many 
ways is actually more complex than "popf", because it has the additional 
"single-cycle interrupt shadow", ie the interrupt isn't actually enabled 
after the sti, it's enabled after the _next_ instruction after the sti. So 
from a uarch standpoint, "popf" is actually somewhat simpler.)

Anyway, what both you and Chuck seem to be missing is that trying to save 
a couple of CPU cycles is NOT WORTH IT, if it makes the code harder and 
more fragile. The "save eflags over context switch" that we do now is 
_obvious_ code. That's worth a lot in itself. And the costs of context 
switching isn't actually a couple of cycles - the real costs are all 
elsewhere.

			Linus

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

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-04  6:56 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 [this message]
2006-11-05  4:17     ` Zachary Amsden
2006-11-05 20:10       ` H. Peter Anvin
  -- 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=Pine.LNX.4.64.0611050914030.25218@g5.osdl.org \
    --to=torvalds@osdl.org \
    --cc=76306.1226@compuserve.com \
    --cc=ak@suse.de \
    --cc=bcrl@kvack.org \
    --cc=linux-kernel@vger.kernel.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 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®