lkml.org 
[lkml]   [1999]   [May]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: schedule() "spaghetti" in 2.3.2 ..
Hi!

> > why not move code blocks in macros ( like that in mm module ) or better in
> > inline functions.
>
> That would not have the intended effect - to keep jumps out of the
> fast path.
>
> Normally gcc codes a normal if like that (pseudo, m68k like assembly)
>
> if (x < 0) {
> /* error */
> }
> /* rest of fast path */
>
> tst x
> bgr L1 /* jump taken in most cases */
> /* error */
> L1:
> /* rest of fast path */
>
> this means there is a jump in the fast path (on modern CPUs that can be
> quite costly because of the pipeline stall when the jump is mispredicted).
> It is usually faster to have code like this:

What about heuristic which says

if (...) {
...
return;
}

should be moved out of line?

Pavel
> I would prefer a cleaner way too, e.g.
>
> if (__builtin_predict(err < 0, 0)) {
> /* unlikely error code */
> }

maybe
#define unlikely __builtin_one_unlikely()

if (is_error() && unlikely) {
}

:-). Where unlikely is evaluated as 1, but gcc knows that unlikely is
not evaluated in common case. It would permit other nice tricks, like
(dreaming)

if (unlikely) {
...
}

which means code in brackets hardly ever executes, so optimize it for
size, instead ;-).

Pavel
--
I'm really pavel@ucw.cz. Look at http://195.113.31.123/~pavel. Pavel
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:51    [W:0.068 / U:0.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site