• Thomas Gleixner's avatar
    futex: Revert "futex: Wake up waiter outside the hb->lock section" · 370eaf38
    Thomas Gleixner authored
    This reverts commit 928686b7.
    
    The patch was an optimization of the old futex wake code where we woke
    the waiter and then set q->lock_ptr to NULL. When the waiter preempted
    the waker then we run into lock contention on q->lock_ptr
    aka. hb->lock.
    
    commit f1a11e (futex: remove the wait queue) changes the wakeup logic
    by setting q->lock_ptr to NULL _before_ waking the task. It keeps a
    reference on the task struct of the to be woken task to avoid an exit
    race.
    
    The combination of both patches resulted in different race on -RT:
    
        A is blocked on futex
        B calls futex_wake
        B sets q(A)->lock_ptr to NULL and puts A on the wake list
        B is preempted
        ...
        A wakes up (e.g. timer, signal)
        A detects q->lock_ptr = NULL and returns
        A waits on a different futex
    
        B is scheduled back in
        B wakes A
        A sees a spurious wake up
    Reported-by: default avatarBlaise Gassend <blaise@willowgarage.com>
    Debugged-by: default avatarDarren Hart <dvhltc@us.ibm.com>
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    
     enter the commit message for your changes. Lines starting
    370eaf38
fork.c 45.4 KB