kernelnewbies.org :-
http://kernelnewbies.org/FAQ/LikelyUnlikely
-Manoj
On 11/26/06, Manoj Awasthi <lkml.manoj@xxxxxxxxx> wrote:
Thanks guys. I am getting it and need to brush up branching/pipelining :).
-ManojOn 11/24/06, Stavros Passas < stabat@xxxxxxxxxx> wrote:On Fri, 2006-11-24 at 17:49 +0100, Fernando Apesteguía wrote:
> On 11/24/06, Manoj Awasthi <lkml.manoj@xxxxxxxxx> wrote:
> > Hi,
> >
> > Can someone please tell me the cases in which we can use likely() and
> > unlikely() macros ?
>
> In cases when you are really really sure, that the value of a
> comparison is going to be/is not going to be, equal to the value that
> you are comparing with.
>
> > I think this optimization is at the cost of the correctness of code
> > handling.
>
> Why? AFAIK, it only changes the order of the instructions to avoid
> pipeline emptying.
It depends from processor's architecture which is the change.
If specific instructions for likely/unlikely branches are existed,
compiler use them, if branch instruction have a hint bit,
compiler set it, otherwise most likely path is placed first (actually on
the correct place) to avoid stalls.
Of course, on x86 we haven't special feautures for branches,
so code reordering is used.
Stavros
>
> CMIIW
>
> >
> > thanks
> > -Manoj
> >
> > --
> > What is important? What you want to be true, or what is true?
> > ---------------------------------------------------------------------------
> > http://awmanoj.blogspot.com
>
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive: http://mail.nl.linux.org/kernelnewbies/
> FAQ: http://kernelnewbies.org/faq/
>
--
What is important? What you want to be true, or what is true?
---------------------------------------------------------------------------
http://awmanoj.blogspot.com
--
What is important? What you want to be true, or what is true?
---------------------------------------------------------------------------
http://awmanoj.blogspot.com