On 09/03/21 11:21, David Edmondson wrote:
- /* The critical section started in qemu_co_rwlock_wrlock. */
- qemu_co_queue_restart_all(&lock->queue);
+ /* The critical section started in qemu_co_rwlock_wrlock or
+ * qemu_co_rwlock_upgrade.
+ */
+ qemu_co_queue_restart_all(&lock->wqueue);
+ qemu_co_queue_restart_all(&lock->rqueue);
Hmm, the devil is in the details---this is a thundering herd waiting to
happen. But fortunately this can be fixed while making the unlock
primitive even simpler:
if (lock->reader) {
self->locks_held--;
/* Read-side critical sections do not keep lock->mutex. */
qemu_co_mutex_lock(&lock->mutex);
lock->reader--;
assert(lock->reader >= 0);
}
/* If there are no remaining readers wake one waiting writer
* or all waiting readers.
*/
if (!lock->reader && !qemu_co_queue_next(&lock->wqueue)) {
assert(!lock->pending_writer);
qemu_co_queue_restart_all(&lock->rqueue);
}
Thanks,
Paolo