From e227b4c404a47f9596c8dea215babf6d32fbbae6 Mon Sep 17 00:00:00 2001 From: Archana Shinde Date: Tue, 21 Jun 2022 12:28:19 -0700 Subject: [PATCH] block: Leverage multiqueue for virtio-block Similar to network, we can use multiple queues for virtio-block devices. This can help improve storage performance. This commit changes the number of queues for block devices to the number of cpus for cloud-hypervisor and qemu. Today the default number of cpus a VM starts with is 1. Hence the queues used will be 1. This change will help improve performance when the default cold-plugged cpus is greater than one by changing this in the config file. This may also help when we use the sandboxing feature with k8s that passes down the sum of the resources required down to Kata. Fixes #4502 Signed-off-by: Archana Shinde --- src/runtime/virtcontainers/clh.go | 5 +++++ src/runtime/virtcontainers/qemu.go | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/runtime/virtcontainers/clh.go b/src/runtime/virtcontainers/clh.go index ce8f8fa577..a255c1febe 100644 --- a/src/runtime/virtcontainers/clh.go +++ b/src/runtime/virtcontainers/clh.go @@ -753,6 +753,11 @@ func (clh *cloudHypervisor) hotplugAddBlockDevice(drive *config.BlockDrive) erro clhDisk.Readonly = &drive.ReadOnly clhDisk.VhostUser = func(b bool) *bool { return &b }(false) + queues := int32(clh.config.NumVCPUs) + queueSize := int32(1024) + clhDisk.NumQueues = &queues + clhDisk.QueueSize = &queueSize + diskRateLimiterConfig := clh.getDiskRateLimiterConfig() if diskRateLimiterConfig != nil { clhDisk.SetRateLimiterConfig(*diskRateLimiterConfig) diff --git a/src/runtime/virtcontainers/qemu.go b/src/runtime/virtcontainers/qemu.go index 656548e88c..4e877604ce 100644 --- a/src/runtime/virtcontainers/qemu.go +++ b/src/runtime/virtcontainers/qemu.go @@ -1341,7 +1341,9 @@ func (q *qemu) hotplugAddBlockDevice(ctx context.Context, drive *config.BlockDri return err } - if err = q.qmpMonitorCh.qmp.ExecutePCIDeviceAdd(q.qmpMonitorCh.ctx, drive.ID, devID, driver, addr, bridge.ID, romFile, 0, true, defaultDisableModern); err != nil { + queues := int(q.config.NumVCPUs) + + if err = q.qmpMonitorCh.qmp.ExecutePCIDeviceAdd(q.qmpMonitorCh.ctx, drive.ID, devID, driver, addr, bridge.ID, romFile, queues, true, defaultDisableModern); err != nil { return err } case q.config.BlockDeviceDriver == config.VirtioBlockCCW: