Re: [rfc patch] i386: don't save eflags on task switch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Sun, 5 Nov 2006, Andi Kleen wrote:
> 
> > sti is expensive as well; iirc just as expensive on most processors as 
> > popf, 
> 
> On K8 STI is 4 cycles.

Your point being? On K8, popf was 12 cycles according to Zach. The 
conditional branch is going to be almost totally unpredictable, unless you 
inline it everywhere (it will be statically predictable in each individual 
location), but if you inline it, you'll be expanding a two-byte 
instruction sequence to something like 10 bytes with all the tests.

So you get a test, a unpredictable conditional jump, and the sti - and 
you'll end up with the cost being pretty much the same as the popf: only 
bigger and more complex.

That's a win, right?

> 99.9999% of all restore_flags just need STI.

Hell no. If you know it statically, you can already just do the 
"spin_lock_irq()"->"spin_unlock_irq()", and then you have the 
_unconditional_ sti.

The problem with that is that it's now a lot more fragile, ie you must 
know what the calling context was. We do do this, because it _is_ faster 
when it's unconditional, but you're optimizing all the wrong things.

Andi, one single bug is usually worth _months_ of peoples time and effort. 
How many CPU cycles is that? 

You need to learn that "stability and maintainability" is more important 
than trying to get a single cycle or two. Really. I'll do cycle tweaking 
too, but it needs to be something that is really obvious, or really 
important. 

			Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux