Re: [PATCH 3/3] futex: fix miss ordered wakeups

From: Arjan van de Ven
Date: Sat May 24 2008 - 16:35:22 EST


On Sat, 24 May 2008 12:19:34 -0700
Daniel Walker <dwalker@xxxxxxxxxx> wrote:

> > There is no kernel side controlled handover of a normal futex. The
> > woken up waiters race for it and a low prio thread on another CPU
> > can steal it even if there is a high prio waiter woken up.
>
> After reading futex_wake, Doesn't it depend how many waiters are
> woken? Given that comes from userspace, glibc could wake a single
> waiter and obtain a priority ordering, couldn't it?

nope. Don't look at the release path... look at the acquire path.
If a thread sees the futex is free, it'll take it, without even going
to the kernel at all. So you have the situation where the kernel spends
a lot of time finding the "perfect" candidate to wake up, but kaboom
some other thread just happens to try to get the mutex between the
wakeup and the acquire of the wakee.. and just "steal" the lock.


--
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/