pci: vfio: Release memory slots upon unmap

This prevents starvation of the limited set of memory slots in the
kernel.

Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
This commit is contained in:
Rob Bradford 2024-11-21 15:41:22 +00:00
parent 81f8a27ef6
commit 0d6cef4521
2 changed files with 6 additions and 0 deletions

View File

@ -1699,6 +1699,9 @@ impl VfioPciDevice {
error!("Could not remove the userspace memory region: {}", e);
}
self.memory_slot_allocator
.free_memory_slot(user_memory_region.slot);
// SAFETY: FFI call with correct arguments
let ret = unsafe {
libc::munmap(

View File

@ -222,6 +222,9 @@ impl VfioUserPciDevice {
error!("Could not remove the userspace memory region: {}", e);
}
self.memory_slot_allocator
.free_memory_slot(user_memory_region.slot);
// Remove mmaps
// SAFETY: FFI call with correct arguments
let ret = unsafe {