On Wed, May 21, 2025 at 10:55:12AM -0600, Alex Williamson wrote: > This optimization does rely on an assumption of consecutive _pages_ in > the array returned from GUP. If we cannot assume the next array index > is the next page from the same folio (which afaict we have no basis to > do), we cannot use the folio as the basis for any optimization. Right! I was wondering why this code was messing with folios, it really can't learn anything from folios. The only advantage to folios is during unpinning where we can batch the atomics for all the folio sub pages, which the core mm helpers are doing. Which brings me back to my first remark - this is all solved in iommufd, in a much better way :( I continue to think we should just leave this type1 stuff as-is upstream and encourage people to move forward. Lots of CSPs are running iommufd now. There is a commonly used OOT patch to add the insecure P2P support like VFIO. I know lots of folks have backported iommufd.. No idea about libvirt, but you can run it in compatibility mode and then you don't need to change libvirt. Jason