Re: [PATCH v2 2/3] thread-pool: replace semaphore with condition variable

2022-05-13 Thread Paolo Bonzini
On 5/13/22 13:56, Nicolas Saenz Julienne wrote: pool->idle_threads++; -    qemu_mutex_unlock(&pool->lock); -    ret = qemu_sem_timedwait(&pool->sem, 1); -    qemu_mutex_lock(&pool->lock); +    ret = qemu_cond_timedwait(&pool->request_cond, &pool-

Re: [PATCH v2 2/3] thread-pool: replace semaphore with condition variable

2022-05-13 Thread Nicolas Saenz Julienne
Hi Paolo, On Thu, 2022-05-12 at 12:43 +0200, Paolo Bonzini wrote: [...] > diff --git a/util/thread-pool.c b/util/thread-pool.c > index 4979f30ca3..da189d9338 100644 > --- a/util/thread-pool.c > +++ b/util/thread-pool.c > @@ -57,7 +57,7 @@ struct ThreadPool { > QEMUBH *completion_bh; >

[PATCH v2 2/3] thread-pool: replace semaphore with condition variable

2022-05-12 Thread Paolo Bonzini
Since commit f9fc8932b1 ("thread-posix: remove the posix semaphore support", 2022-04-06) QemuSemaphore has its own mutex and condition variable; this adds unnecessary overhead on I/O with small block sizes. Check the QTAILQ directly instead of adding the indirection of a semaphore's count. Using