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

From: Daniel Walker
Date: Sat May 24 2008 - 11:33:28 EST



On Sat, 2008-05-24 at 10:55 +0200, Thomas Gleixner wrote:

> Normal futexes have no ordering guarantees at all. There is no
> mechanism to prevent lock stealing from lower priority tasks. So why
> should we care about the once a year case, where a sleepers priority
> is modified ?

Lock stealing? The usage of sched_setscheduler is fairly pervasive in
userspace, if a task becomes SCHED_FIFO it did so via
sched_setscheduler. So I don't think this is at all "once a year". Tasks
shouldn't be forced to determine if a task is sleeping or not before it
calls sched_setscheduler.

> If you need ordering guarantees then use PI futexes.

There are degree's of overhead with each step.. Someone may not need or
want priority inheritance.

> > +void futex_adjust_waiters(struct task_struct *p)
> > +{
> > + spin_lock(&p->pi_lock);
> > + spin_lock(&hb->lock);
> > ...
> > + spin_unlock(&hb->lock);
> > + }
> > + spin_unlock(&p->pi_lock);
> > +}
>
> vs.
>
> > @@ -1155,6 +1191,8 @@ static int futex_wait(u32 __user *uaddr,
> {
> ....
> hb = queue_lock(&q);
>
> > + spin_lock(&current->pi_lock);
> > + current->blocked_on = &blocked_on;
> > + spin_unlock(&current->pi_lock);
>
> There are more issues vs. pi futexes as well. The simple case of
> futex_wait() vs. futex_adjust_waiters will just upset lockdep, but
> there are real dealocks vs. unqueue_me_pi waiting.

You mean the lock ordering would cause the deadlock vs. unqueue_me_pi ,
or are you talking about something else?

Daniel

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