-
- Downloads
sched: fix waitqueue race causing failure to wake up
When waitqueue::wake_all() wakes up waiting threads, it calls sched::thread::wake_lock() to enqueue those waiting threads on the mutex protecting the waitqueue, thus avoiding needless contention on the mutex. However, if a thread is already waking, we let it wake naturally and acquire the mutex itself. The problem is that the waitqueue code (wait_object<waitqueue>::poll()) examines the wait_record it sleeps on and see if it has woken, and if not, goes back to sleep. Since nothing in that thread-already-awake path clears the wait_record, that is what happens, and the thread stalls, until a timeout occurs. Fix by clearing the wait record. As it is protected by the mutex, no extra synchronization is needed. Observed with iperf -P 64 against the guest. Likely triggered by net channels waking up the thread, and then before it has a chance to wake up, a FIN packet arrives that is processed in the driver thread; so when the packets are consumed the thread is in the waking state. Reviewed-by:Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Avi Kivity <avi@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
Loading
Please register or sign in to comment