• D
    futex: add requeue_pi functionality · 52400ba9
    Darren Hart 提交于
    PI Futexes and their underlying rt_mutex cannot be left ownerless if
    there are pending waiters as this will break the PI boosting logic, so
    the standard requeue commands aren't sufficient.  The new commands
    properly manage pi futex ownership by ensuring a futex with waiters
    has an owner at all times.  This will allow glibc to properly handle
    pi mutexes with pthread_condvars.
    
    The approach taken here is to create two new futex op codes:
    
    FUTEX_WAIT_REQUEUE_PI:
    Tasks will use this op code to wait on a futex (such as a non-pi waitqueue)
    and wake after they have been requeued to a pi futex.  Prior to returning to
    userspace, they will acquire this pi futex (and the underlying rt_mutex).
    
    futex_wait_requeue_pi() is the result of a high speed collision between
    futex_wait() and futex_lock_pi() (with the first part of futex_lock_pi() being
    done by futex_proxy_trylock_atomic() on behalf of the top_waiter).
    
    FUTEX_REQUEUE_PI (and FUTEX_CMP_REQUEUE_PI):
    This call must be used to wake tasks waiting with FUTEX_WAIT_REQUEUE_PI,
    regardless of how many tasks the caller intends to wake or requeue.
    pthread_cond_broadcast() should call this with nr_wake=1 and
    nr_requeue=INT_MAX.  pthread_cond_signal() should call this with nr_wake=1 and
    nr_requeue=0.  The reason being we need both callers to get the benefit of the
    futex_proxy_trylock_atomic() routine.  futex_requeue() also enqueues the
    top_waiter on the rt_mutex via rt_mutex_start_proxy_lock().
    Signed-off-by: NDarren Hart <dvhltc@us.ibm.com>
    Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
    Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
    52400ba9
thread_info.h 3.4 KB