[PATCH i-g-t 1/2] tests/gem_mmap_offset: Split 'clear' subtest

Janusz Krzysztofik janusz.krzysztofik at linux.intel.com
Thu Nov 21 10:39:27 UTC 2024


Commit e25913a1a79d ("i915/gem_mmap_offset: Ignore ENOSPC error for making
residency execbuf") not only resolved the issue of unnecessary failures on
ENOSPC errors, but also introduced an alternative method of clearing
memory of an object, with random selection of one of those methods on each
iteration.  The new method expects the memory to be cleared in pagefault
handler path.  Since those two methods may give different results, mixing
them in one exercise may make the picture unclear, especially if something
goes wrong.

Add a new subtest that exercises the pagefault method exclusively.

Link: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11738
Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik at linux.intel.com>
---
 tests/intel/gem_mmap_offset.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/tests/intel/gem_mmap_offset.c b/tests/intel/gem_mmap_offset.c
index 3f499abedb..20dca17378 100644
--- a/tests/intel/gem_mmap_offset.c
+++ b/tests/intel/gem_mmap_offset.c
@@ -53,6 +53,7 @@
  * SUBTEST: basic-uaf
  * SUBTEST: blt-coherency
  * SUBTEST: clear
+ * SUBTEST: clear-via-pagefault
  * SUBTEST: close-race
  * SUBTEST: isolation
  * SUBTEST: mmap-boundaries
@@ -720,6 +721,8 @@ struct thread_clear {
 	struct drm_i915_gem_memory_class_instance region;
 	int timeout;
 	int i915;
+	unsigned flags;
+#define CLEAR_IN_EXECBUF	0x1 << 0
 };
 
 static void *thread_clear(void *data)
@@ -743,8 +746,8 @@ static void *thread_clear(void *data)
 		size = npages << 12;
 
 		igt_assert_eq(__gem_create_in_memory_region_list(i915, &handle, &size, 0, &arg->region, 1), 0);
-		/* Zero-init bo in execbuf or pagefault handler path randomly */
-		if (random() & 1)
+		/* Zero-init bo in execbuf or pagefault handler path as requested */
+		if (arg->flags & CLEAR_IN_EXECBUF)
 			make_resident(i915, batch, handle);
 
 		ptr = __mmap_offset(i915, handle, 0, size,
@@ -784,13 +787,14 @@ static void *thread_clear(void *data)
 	return (void *)(uintptr_t)checked;
 }
 
-static void always_clear(int i915, const struct gem_memory_region *r, int timeout)
+static void always_clear(int i915, const struct gem_memory_region *r, int timeout, unsigned flags)
 {
 	struct thread_clear arg = {
 		.i915 = i915,
 		.region = r->ci,
 		.max = r->cpu_size / 2 >> 12, /* in pages */
 		.timeout = timeout,
+		.flags = flags,
 	};
 	const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
 	unsigned long checked;
@@ -1200,7 +1204,14 @@ igt_main
 	igt_subtest_with_dynamic("clear") {
 		for_each_memory_region(r, i915) {
 			igt_dynamic_f("%s", r->name)
-				always_clear(i915, r, 20);
+				always_clear(i915, r, 20, CLEAR_IN_EXECBUF);
+		}
+	}
+
+	igt_subtest_with_dynamic("clear-via-pagefault") {
+		for_each_memory_region(r, i915) {
+			igt_dynamic_f("%s", r->name)
+				always_clear(i915, r, 20, 0);
 		}
 	}
 
-- 
2.47.0



More information about the igt-dev mailing list