Skip to content

Commit 5363bc5

Browse files
committed
msi: fix size of interrupts HashMap
We are using a HashMap to track the interrupt routes we use in the system. The index to the HashMap is the GSI of the interrupt route. We know the maximum number of GSIs we have available so pre-allocate the space for the HashMap to avoid reallocations at runtime. Signed-off-by: Babis Chalios <[email protected]>
1 parent 6102824 commit 5363bc5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/vmm/src/vstate/vm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ use vm_device::interrupt::{
2828
use vmm_sys_util::errno;
2929
use vmm_sys_util::eventfd::EventFd;
3030

31-
use crate::arch::host_page_size;
3231
pub use crate::arch::{ArchVm as Vm, ArchVmError, VmState};
32+
use crate::arch::{GSI_MSI_END, host_page_size};
3333
use crate::logger::info;
3434
use crate::persist::CreateSnapshotError;
3535
use crate::snapshot::Persist;
@@ -322,7 +322,7 @@ impl Vm {
322322
fd,
323323
max_memslots: kvm.max_nr_memslots(),
324324
guest_memory: GuestMemoryMmap::default(),
325-
interrupts: Mutex::new(HashMap::new()),
325+
interrupts: Mutex::new(HashMap::with_capacity(GSI_MSI_END as usize + 1)),
326326
resource_allocator: Mutex::new(ResourceAllocator::new()),
327327
mmio_bus: Arc::new(vm_device::Bus::new()),
328328
})

0 commit comments

Comments
 (0)