aboutsummaryrefslogtreecommitdiff
path: root/hw/block
diff options
context:
space:
mode:
authorHiroki Narukawa <hnarukaw@yahoo-corp.jp>2022-02-14 20:53:02 +0900
committerStefan Hajnoczi <stefanha@redhat.com>2022-02-14 17:11:25 +0000
commit4c41c69e05fe28c0f95f8abd2ebf407e95a4f04b (patch)
treeac367ecefb05151002d999fdf4b7b18904fdf6ff /hw/block
parent34deee7b6a1418f3d62a91ff0a9d156e60a788a5 (diff)
downloadqemu-4c41c69e05fe28c0f95f8abd2ebf407e95a4f04b.zip
qemu-4c41c69e05fe28c0f95f8abd2ebf407e95a4f04b.tar.gz
qemu-4c41c69e05fe28c0f95f8abd2ebf407e95a4f04b.tar.bz2
util: adjust coroutine pool size to virtio block queue
Coroutine pool size was 64 from long ago, and the basis was organized in the commit message in 4d68e86b. At that time, virtio-blk queue-size and num-queue were not configuable, and equivalent values were 128 and 1. Coroutine pool size 64 was fine then. Later queue-size and num-queue got configuable, and default values were increased. Coroutine pool with size 64 exhausts frequently with random disk IO in new size, and slows down. This commit adjusts coroutine pool size adaptively with new values. This commit adds 64 by default, but now coroutine is not only for block devices, and is not too much burdon comparing with new default. pool size of 128 * vCPUs. Signed-off-by: Hiroki Narukawa <hnarukaw@yahoo-corp.jp> Message-id: 20220214115302.13294-2-hnarukaw@yahoo-corp.jp Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'hw/block')
-rw-r--r--hw/block/virtio-blk.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 82676cd..540c38f 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -32,6 +32,7 @@
#include "hw/virtio/virtio-bus.h"
#include "migration/qemu-file-types.h"
#include "hw/virtio/virtio-access.h"
+#include "qemu/coroutine.h"
/* Config size before the discard support (hide associated config fields) */
#define VIRTIO_BLK_CFG_SIZE offsetof(struct virtio_blk_config, \
@@ -1214,6 +1215,8 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
for (i = 0; i < conf->num_queues; i++) {
virtio_add_queue(vdev, conf->queue_size, virtio_blk_handle_output);
}
+ qemu_coroutine_increase_pool_batch_size(conf->num_queues * conf->queue_size
+ / 2);
virtio_blk_data_plane_create(vdev, conf, &s->dataplane, &err);
if (err != NULL) {
error_propagate(errp, err);
@@ -1250,6 +1253,8 @@ static void virtio_blk_device_unrealize(DeviceState *dev)
for (i = 0; i < conf->num_queues; i++) {
virtio_del_queue(vdev, i);
}
+ qemu_coroutine_decrease_pool_batch_size(conf->num_queues * conf->queue_size
+ / 2);
qemu_del_vm_change_state_handler(s->change);
blockdev_mark_auto_del(s->blk);
virtio_cleanup(vdev);