lkml.org 
[lkml]   [2011]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [RFC][PATCH 2/3] futex: Reduce hash bucket lock contention
    From
    Date
    On Wed, 2011-09-14 at 15:30 +0200, Peter Zijlstra wrote:
    > @@ -964,6 +961,7 @@ futex_wake(u32 __user *uaddr, unsigned i
    > struct futex_q *this, *next;
    > struct plist_head *head;
    > union futex_key key = FUTEX_KEY_INIT;
    > + WAKE_LIST(wake_list);
    > int ret;
    >
    > if (!bitset)
    > @@ -988,7 +986,7 @@ futex_wake(u32 __user *uaddr, unsigned i
    > if (!(this->bitset & bitset))
    > continue;
    >
    > - wake_futex(this);
    > + wake_futex(&wake_list, this);
    > if (++ret >= nr_wake)
    > break;
    > }
    > @@ -996,6 +994,8 @@ futex_wake(u32 __user *uaddr, unsigned i
    >
    > spin_unlock(&hb->lock);
    > put_futex_key(&key);
    > +
    > + wake_up_list(&wake_list, TASK_NORMAL);
    > out:
    > return ret;
    > }

    So while initially I thought the sem patch was busted, it turns out this
    one is.

    Thomas managed to spot the race:

    Task-0 Task-1

    futex_wait()
    queue_me()

    futex_wake()
    wake_list_add();
    __unqueue_futex();
    plist_del();
    if (!plist_node_empty())
    __set_current_state(TASK_RUNNNIG);

    wake_up_list();
    /* waking an already running task-0 */


    I guess the biggest question is, do we care? Ideally everything should
    be able to deal with spurious wakeups, although we generally try to
    avoid them.




    \
     
     \ /
      Last update: 2011-09-16 14:37    [W:0.023 / U:93.272 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site