When a device file is mapped a second time and the vm_area_struct of the
first mapping still exists (same vm_private_data),
linux_file_mmap_single() frees the new vm_area_struct and uses the existing
VM object. The mmap method of the driver had however already taken what the
mapping needs, and the matching release is done by the close method of its
vm_ops, which was never called for the discarded vm_area_struct.
i915 takes a reference on the GEM object in its mmap method for the
mmap_offset path and drops it in vm_close(). Every additional mapping of an
object that is already mapped therefore leaked one reference and the object
was never freed, with its requests and the vma resources they hold. Mesa's
ANV maps some buffers twice, so each Vulkan process left an object behind
and unloading i915 printed
Freed UMA keg (i915_vma_resource) was not empty (10 items).
Freed UMA keg (i915_request) was not empty (1 items).
Freed UMA keg (drm_i915_gem_object) was not empty (1 items).
(437, 58 and 111 items after a longer run of OpenGL ES and Vulkan tests).
Call the close method before freeing the discarded vm_area_struct, like
Linux does when a vma goes away. No message is printed any more after the
same workloads.