Migration testing in i915 uses current task's address space to allocate new userspace mapping, without registering real user for that address space in mm_struct.
It was observed that mm->mm_users would occasionally drop to 0 during the test, which reaped userspace mappings, further leading to failures upon reading from userland memory. Prevent this by artificially increasing mm_users counter for the duration of the test. Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14204 Signed-off-by: Krzysztof Karas <[email protected]> --- drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c index 032bc2f17685..2f3104c17324 100644 --- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c +++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c @@ -1193,6 +1193,13 @@ static int __igt_mmap_migrate(struct intel_memory_region **placements, if (IS_ERR(mock_file)) return PTR_ERR(mock_file); + /* + * Artificially increase mm_users for current->mm to ensure the kernel + * does not try to clean up the userspace mappings of the current task + * during the test. + */ + atomic_inc(¤t->mm->mm_users); + addr = igt_mmap_offset_with_file(i915, offset, obj->base.size, PROT_WRITE, MAP_SHARED, mock_file); if (IS_ERR_VALUE(addr)) { @@ -1303,6 +1310,7 @@ static int __igt_mmap_migrate(struct intel_memory_region **placements, out_addr: vm_munmap(addr, obj->base.size); + atomic_dec(¤t->mm->mm_users); out_fput: fput(mock_file); -- 2.43.0 -- Best Regards, Krzysztof
