diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2022-05-14 08:50:11 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-05-25 21:26:13 +0200 |
commit | 900fa208f50623672a6f879374222a7fd4717791 (patch) | |
tree | c69c05bc7c2031c08cc2c21bae67843e226c2614 /qom | |
parent | 3c7b72ddca9ce85a9d1e8a98fd0996b74597b5ae (diff) | |
download | qemu-900fa208f50623672a6f879374222a7fd4717791.zip qemu-900fa208f50623672a6f879374222a7fd4717791.tar.gz qemu-900fa208f50623672a6f879374222a7fd4717791.tar.bz2 |
thread-pool: replace semaphore with condition variable
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 a semaphore has not been necessary since
qemu_cond_timedwait was introduced; the new code has to be careful about
spurious wakeups but it is simpler, for example thread_pool_cancel does
not have to worry about synchronizing the semaphore count with the number
of elements of pool->request_list.
Note that the return value of qemu_cond_timedwait (0 for timeout, 1 for
signal or spurious wakeup) is different from that of qemu_sem_timedwait
(-1 for timeout, 0 for success).
Reported-by: Lukáš Doktor <ldoktor@redhat.com>
Suggested-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
Message-Id: <20220514065012.1149539-3-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'qom')
0 files changed, 0 insertions, 0 deletions