Revert "vfio/type1: Unpin zero pages"
Subsystems (2)
PATCH 1/1 Revert "vfio/type1: Unpin zero pages"
This reverts commit 873aefb376bbc0ed1dd2381ea1d6ec88106fdbd4.
This was a heinous workaround and it turns out it's been fixed in mm twice since it was introduced. Most recently, commit c8070b787519 ("mm: Don't pin ZERO_PAGE in pin_user_pages()") would have prevented running up the zeropage refcount, but even before that commit 84209e87c696 ("mm/gup: reliable R/O long-term pinning in COW mappings") avoids the vfio use case from pinning the zeropage at all, instead replacing it with exclusive anonymous pages.
Remove this now useless overhead.
--- drivers/vfio/vfio_iommu_type1.c | 12 ------------ 1 file changed, 12 deletions(-)
drivers/vfio/vfio_iommu_type1.c +0 -12
@@ -567,18 +567,6 @@ static int vaddr_get_pfns(struct mm_struct *mm, unsigned long vaddr, ret =pin_user_pages_remote (mm, vaddr, npages, flags |FOLL_LONGTERM , pages,NULL );if (ret >0 ) { -int i; - -/* -* The zero page is always resident, we don't need to pin it -* and it falls into our invalid/reserved test so we don't -* unpin in put_pfn(). Unpin all zero pages in the batch here. -*/ -for (i =0 ; i < ret; i++) { -if (unlikely (is_zero_pfn (page_to_pfn (pages[i])))) -unpin_user_page (pages[i]); - } - *pfn =page_to_pfn (pages[0 ]); goto done; }
Signature · 1 line
2.43.2
Quoted 31 lines · Alex Williamson
This reverts commit
873aefb376bbc0ed1dd2381ea1d6ec88106fdbd4.This was a heinous workaround and it turns out it's been fixed in mm twice since it was introduced. Most recently, commit
c8070b787519("mm: Don't pinZERO_PAGEinpin_user_pages()") would have prevented running up the zeropage refcount, but even before that commit84209e87c696("mm/gup: reliable R/O long-term pinning in COW mappings") avoids the vfio use case from pinning the zeropage at all, instead replacing it with exclusive anonymous pages.Remove this now useless overhead.
Suggested-by David Hildenbrand <[email protected]>Signed-off-by Alex Williamson <[email protected]>--- drivers/vfio/vfio_iommu_type1.c | 12 ------------ 1 file changed, 12 deletions(-)drivers/vfio/vfio_iommu_type1.c +0
-5@@ -567,18 +567,6 @@ static int vaddr_get_pfns(struct mm_struct *mm, unsigned long vaddr, ret =pin_user_pages_remote (mm, vaddr, npages, flags |FOLL_LONGTERM , pages,NULL );if (ret >0 ) { -int i; - -/* -* The zero page is always resident, we don't need to pin it -* and it falls into our invalid/reserved test so we don't
drivers/vfio/vfio_iommu_type1.c static int vaddr_get_pfns(struct mm_struct *mm, unsigned long vaddr, · line 572
Quoted 10 lines
drivers/vfio/vfio_iommu_type1.c +0
-7-* unpin in put_pfn(). Unpin all zero pages in the batch here. -*/ -for (i =0 ; i < ret; i++) { -if (unlikely (is_zero_pfn (page_to_pfn (pages[i])))) -unpin_user_page (pages[i]); - } - *pfn =page_to_pfn (pages[0 ]); goto done; }
Signature · 3 lines
Cheers, David / dhildenb
Quoted 13 lines
From: Alex Williamson <[email protected]>
Sent: Friday, March 1, 2024 6:36 AMThis reverts commit
873aefb376bbc0ed1dd2381ea1d6ec88106fdbd4.This was a heinous workaround and it turns out it's been fixed in mm twice since it was introduced. Most recently, commit
c8070b787519("mm: Don't pinZERO_PAGEinpin_user_pages()") would have prevented running up the zeropage refcount, but even before that commit84209e87c696("mm/gup: reliable R/O long-term pinning in COW mappings") avoids the vfio use case from pinning the zeropage at all, instead replacing it with exclusive anonymous pages.
Quoted 4 lines
Remove this now useless overhead.
Suggested-by David Hildenbrand <[email protected]>Signed-off-by Alex Williamson <[email protected]>