From b11533691a24b7ff0d576a4c5a8f7a717c25ed84 Mon Sep 17 00:00:00 2001 From: Egor Lazarchuk Date: Mon, 20 Nov 2023 16:47:18 +0000 Subject: [PATCH] feat(vhost-user-blk): added `config_change_time_us` metric Added `config_change_time_us` metric to the vhost-user-block device. Signed-off-by: Egor Lazarchuk --- src/vmm/src/devices/virtio/vhost_user_block/device.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vmm/src/devices/virtio/vhost_user_block/device.rs b/src/vmm/src/devices/virtio/vhost_user_block/device.rs index 7293dace3879..588b7f8c5f7e 100644 --- a/src/vmm/src/devices/virtio/vhost_user_block/device.rs +++ b/src/vmm/src/devices/virtio/vhost_user_block/device.rs @@ -256,6 +256,8 @@ impl VhostUserBlockImpl { } pub fn config_update(&mut self) -> Result<(), VhostUserBlockError> { + let start_time = utils::time::get_time_us(utils::time::ClockType::Monotonic); + // This buffer is used for config size check in vhost crate. let buffer = [0u8; BLOCK_CONFIG_SPACE_SIZE as usize]; let (_, new_config_space) = self @@ -273,6 +275,9 @@ impl VhostUserBlockImpl { .trigger_irq(IrqType::Config) .map_err(VhostUserBlockError::IrqTrigger)?; + let delta_us = utils::time::get_time_us(utils::time::ClockType::Monotonic) - start_time; + self.metrics.config_change_time_us.store(delta_us); + Ok(()) } }