add per node mutex for emulated futex
Summary:
The emulated futex (not used on Linux) has an optimization to defer
notification until after the bucket mutex has been unlocked, to avoid
lock collisions between the waiter and waker. That code will have a
use-after-free problem if the waiter's condition_variable has a spurious
wakeup, which is allowed by the spec. That code also doesn't do
anything about contention between multiple waiters.
This diff adds a mutex to each wait node, relieving the waiters from
having to acquire the bucket lock on wakeup. Rather than trying to
perform a racy late notification, we just make sure to release the node
lock immediately after calling notify_one, which seems to have the
desired effect.
Test Plan:
1) existing unit tests
2) new unit tests
Reviewed By: delong.j@fb.com
Subscribers: boseant, njormrod
FB internal diff:
D1602360