Messages in this thread | | | Subject | Re: [RFC][PATCH 2/3] futex: Reduce hash bucket lock contention | From | Peter Zijlstra <> | Date | Fri, 16 Sep 2011 14:34:50 +0200 |
| |
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.
| |