Re: Active waiting with yield()

From: Peter Zijlstra
Date: Wed Nov 19 2008 - 11:14:49 EST


On Tue, 2008-11-18 at 12:11 -0500, Mikulas Patocka wrote:
> On Tue, 18 Nov 2008, Alan Cox wrote:
>
> > > You will touch the wait queue always when finishing the last pending
> > > request --- just to find out that there is no one waiting on it.
> >
> > Why ? If my fast path for this something like
> >
> > if (unlikely(foo->unload_pending) && count == 0)
> > wake_up(..)
> >
> > chances are that I can put unload_pending somewhere in a cache line with
> > other stuff (certainly for L2) and it will get predicted well.
>
> This makes a code branch that is very rarely tested and a potential bug.
> Every such rarely executed branch is a danger and even a silly typo in the
> code can hide there for many years without being noticed.

If you cannot get these simple things right, and stubbornly refuse to
listen to people telling you to the kernel is not the place to cut
corners, perhaps you should not be doing kernel code.


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