aboutsummaryrefslogtreecommitdiff
path: root/include/block
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2023-08-08 11:58:52 -0400
committerKevin Wolf <kwolf@redhat.com>2023-09-08 17:03:09 +0200
commitfa9185fcdfceeb1a02f61a003acd19509e146bde (patch)
tree13ca265e77ddfb14b193c0a4dd7cdb62649a469c /include/block
parent3480ce69a9c7ee956323c45269d21b6905488904 (diff)
downloadqemu-fa9185fcdfceeb1a02f61a003acd19509e146bde.zip
qemu-fa9185fcdfceeb1a02f61a003acd19509e146bde.tar.gz
qemu-fa9185fcdfceeb1a02f61a003acd19509e146bde.tar.bz2
block: change reqs_lock to QemuMutex
CoMutex has poor performance when lock contention is high. The tracked requests list is accessed frequently and performance suffers in QEMU multi-queue block layer scenarios. It is not necessary to use CoMutex for the requests lock. The lock is always released across coroutine yield operations. It is held for relatively short periods of time and it is not beneficial to yield when the lock is held by another coroutine. Change the lock type from CoMutex to QemuMutex to improve multi-queue block layer performance. fio randread bs=4k iodepth=64 with 4 IOThreads handling a virtio-blk device with 8 virtqueues improves from 254k to 517k IOPS (+203%). Full benchmark results and configuration details are available here: https://gitlab.com/stefanha/virt-playbooks/-/commit/980c40845d540e3669add1528739503c2e817b57 In the future we may wish to introduce thread-local tracked requests lists to avoid lock contention completely. That would be much more involved though. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20230808155852.2745350-3-stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'include/block')
-rw-r--r--include/block/block_int-common.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
index 74195c3..7a1e678 100644
--- a/include/block/block_int-common.h
+++ b/include/block/block_int-common.h
@@ -1231,7 +1231,7 @@ struct BlockDriverState {
unsigned int write_gen; /* Current data generation */
/* Protected by reqs_lock. */
- CoMutex reqs_lock;
+ QemuMutex reqs_lock;
QLIST_HEAD(, BdrvTrackedRequest) tracked_requests;
CoQueue flush_queue; /* Serializing flush queue */
bool active_flush_req; /* Flush request in flight? */