[SRU][N][PATCH 1/2] UBUNTU: SAUCE: Revert "vfio/pci: Insert full vma on mmap'd MMIO fault"
Jacob Martin
jacob.martin at canonical.com
Tue Dec 10 15:23:41 UTC 2024
BugLink: https://bugs.launchpad.net/bugs/2089306
This reverts commit "vfio/pci: Insert full vma on mmap'd MMIO fault".
The original commit changes vfio_pci to pre-fault the entire vma when
handling a fault. For PCIe devices with large BAR regions, this can take
a very long time to complete, causing kernel soft lockup warnings. This
is particularly noticeable when launching a virtual machine with a
passthrough PCIe GPU.
Signed-off-by: Jacob Martin <jacob.martin at canonical.com>
---
drivers/vfio/pci/vfio_pci_core.c | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
index 6280589b2187..2280cfc28278 100644
--- a/drivers/vfio/pci/vfio_pci_core.c
+++ b/drivers/vfio/pci/vfio_pci_core.c
@@ -1659,7 +1659,6 @@ static vm_fault_t vfio_pci_mmap_fault(struct vm_fault *vmf)
struct vm_area_struct *vma = vmf->vma;
struct vfio_pci_core_device *vdev = vma->vm_private_data;
unsigned long pfn, pgoff = vmf->pgoff - vma->vm_pgoff;
- unsigned long addr = vma->vm_start;
vm_fault_t ret = VM_FAULT_SIGBUS;
pfn = vma_to_pfn(vma);
@@ -1667,25 +1666,11 @@ static vm_fault_t vfio_pci_mmap_fault(struct vm_fault *vmf)
down_read(&vdev->memory_lock);
if (vdev->pm_runtime_engaged || !__vfio_pci_memory_enabled(vdev))
- goto out_unlock;
+ goto out_disabled;
ret = vmf_insert_pfn(vma, vmf->address, pfn + pgoff);
- if (ret & VM_FAULT_ERROR)
- goto out_unlock;
- /*
- * Pre-fault the remainder of the vma, abort further insertions and
- * supress error if fault is encountered during pre-fault.
- */
- for (; addr < vma->vm_end; addr += PAGE_SIZE, pfn++) {
- if (addr == vmf->address)
- continue;
-
- if (vmf_insert_pfn(vma, addr, pfn) & VM_FAULT_ERROR)
- break;
- }
-
-out_unlock:
+out_disabled:
up_read(&vdev->memory_lock);
return ret;
--
2.43.0
More information about the kernel-team
mailing list