From cb171d4a239d5c670db9d40769335d2255f36766 Mon Sep 17 00:00:00 2001 From: Jinrong Liang Date: Thu, 27 Oct 2022 18:52:57 +0800 Subject: [PATCH] device_manager: Avoid checking io_uring support when it's not needed After testing, io_uring_is_supported() causes about 38ms of overhead when creating virtio-blk. By modifying the position of io_uring_is_supported(), the overhead of creating virtio-blk is reduced to less than 1ms when we close io_uring. Signed-off-by: Jinrong Liang --- vmm/src/device_manager.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 04ca0d589..e00ae20f3 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -2100,7 +2100,7 @@ impl DeviceManager { ImageType::FixedVhd => { // Use asynchronous backend relying on io_uring if the // syscalls are supported. - if self.io_uring_is_supported() && !disk_cfg.disable_io_uring { + if !disk_cfg.disable_io_uring && self.io_uring_is_supported() { info!("Using asynchronous fixed VHD disk file (io_uring)"); Box::new( FixedVhdDiskAsync::new(file) @@ -2117,7 +2117,7 @@ impl DeviceManager { ImageType::Raw => { // Use asynchronous backend relying on io_uring if the // syscalls are supported. - if self.io_uring_is_supported() && !disk_cfg.disable_io_uring { + if !disk_cfg.disable_io_uring && self.io_uring_is_supported() { info!("Using asynchronous RAW disk file (io_uring)"); Box::new(RawFileDisk::new(file)) as Box } else {