[PATCH i-g-t 2/3] tests/gem_barrier_race: Race barrier_preallocate/acquire against itself

Janusz Krzysztofik janusz.krzysztofik at linux.intel.com
Thu Mar 2 10:39:05 UTC 2023


Add a basic subtest that execrises concurrent barrier preallocate-acquire
cycles on intel_context first pin / last unpin.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik at linux.intel.com>
---
 tests/i915/gem_barrier_race.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/tests/i915/gem_barrier_race.c b/tests/i915/gem_barrier_race.c
index 2ee2417dac..70a80a3157 100644
--- a/tests/i915/gem_barrier_race.c
+++ b/tests/i915/gem_barrier_race.c
@@ -115,6 +115,21 @@ intel_context_first_pin_last_unpin_loop(int fd, struct intel_execution_engine2 *
 	close(fd);
 }
 
+static void test_preallocate_acquire(int fd, struct intel_execution_engine2 *e, unsigned int timeout)
+{
+	int *done = mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+
+	igt_assert(done != MAP_FAILED);
+
+	igt_fork(child, 2 * sysconf(_SC_NPROCESSORS_ONLN))
+		intel_context_first_pin_last_unpin_loop(fd, e, done);
+
+	sleep(timeout);
+	*done = 1;
+	igt_waitchildren();
+	munmap(done, 4096);
+}
+
 static void test_remote_request(int fd, struct intel_execution_engine2 *e, unsigned int timeout)
 {
 	int *done = mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
@@ -141,6 +156,20 @@ igt_main
 		igt_require_gem(fd);
 	}
 
+	igt_describe("Race multiple threads calling intel_context_active_acquire/release");
+	igt_subtest_with_dynamic("basic") {
+		struct intel_execution_engine2 *e;
+
+		for_each_physical_engine(fd, e) {
+			if (e->class != I915_ENGINE_CLASS_RENDER &&
+			    e->class != I915_ENGINE_CLASS_COMPUTE)
+				continue;
+
+			igt_dynamic(e->name)
+				test_preallocate_acquire(fd, e, 5);
+		}
+	}
+
 	igt_describe("Race intel_context_prepare_remote_request against intel_context_active_acquire/release");
 	igt_subtest_with_dynamic("remote-request") {
 		struct intel_execution_engine2 *e;
-- 
2.25.1



More information about the Intel-gfx-trybot mailing list