Skip to content

Commit

Permalink
pci: vfio: Release memory slots upon unmap
Browse files Browse the repository at this point in the history
This prevents starvation of the limited set of memory slots in the
kernel.

Signed-off-by: Rob Bradford <[email protected]>
  • Loading branch information
rbradford committed Nov 24, 2024
1 parent 81f8a27 commit 0d6cef4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pci/src/vfio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions pci/src/vfio_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0d6cef4

Please sign in to comment.