On Wed, 2 Mar 2022 at 10:22, Thomas Hellström <thomas.hellstrom@xxxxxxxxxxxxxxx> wrote: > > vms are not getting properly closed. Rather than fixing that, > Remove the vm open count and instead rely on the vm refcount. > > The vm open count existed solely to break the strong references the > vmas had on the vms. Now instead make those references weak and > ensure vmas are destroyed when the vm is destroyed. > > Unfortunately if the vm destructor and the object destructor both > wants to destroy a vma, that may lead to a race in that the vm > destructor just unbinds the vma and leaves the actual vma destruction > to the object destructor. However in order for the object destructor > to ensure the vma is unbound it needs to grab the vm mutex. In order > to keep the vm mutex alive until the object destructor is done with > it, somewhat hackishly grab a vm_resv refcount that is released late > in the vma destruction process, when the vm mutex is no longer needed. > > v2: Address review-comments from Niranjana > - Clarify that the struct i915_address_space::skip_pte_rewrite is a hack and > should ideally be replaced in an upcoming patch. > - Remove an unneeded continue in clear_vm_list and update comment. > > Co-developed-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@xxxxxxxxx> > Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@xxxxxxxxx> > Signed-off-by: Thomas Hellström <thomas.hellstrom@xxxxxxxxxxxxxxx> Reviewed-by: Matthew Auld <matthew.auld@xxxxxxxxx>