Re: [PATCH] iommu/arm-smmu-v3: Add a threshold to avoid potential soft lockup

From: Jason Gunthorpe
Date: Wed Jan 24 2024 - 11:28:19 EST


On Wed, Jan 24, 2024 at 12:17:43PM +0000, Robin Murphy wrote:

> I don't think the story here has changed from when I first remember this
> being discussed probably 7 or 8 years ago - what VFIO has always really
> wanted for this situation is to know when it's doing a complete teardown and
> just detach and free the domain, then unpin the pages afterwards, without
> wasting any time at all on frivolous unmapping.

What VFIO/iommufd really wants is a fast way to to read back and unmap
the PFNs from the domain. Today it has to call iommu_iova_to_phys()
and then unmap which ends up walking the radix many times.

Ideally we'd batch read and unmap in a single call with a single radix
walk.

This is because the domain is used to store the 'struct page *' which
is needed to unpin the memory.

Combined with the no-attachments optimization I described it could be
pretty close to optimal.

Jason