]> git.proxmox.com Git - mirror_qemu.git/commit - block/io.c
block: change reqs_lock to QemuMutex
authorStefan Hajnoczi <stefanha@redhat.com>
Tue, 8 Aug 2023 15:58:52 +0000 (11:58 -0400)
committerKevin Wolf <kwolf@redhat.com>
Fri, 8 Sep 2023 15:03:09 +0000 (17:03 +0200)
commitfa9185fcdfceeb1a02f61a003acd19509e146bde
tree13ca265e77ddfb14b193c0a4dd7cdb62649a469c
parent3480ce69a9c7ee956323c45269d21b6905488904
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>
block.c
block/io.c
include/block/block_int-common.h