Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 i-g-t] tests/intel/gem_exec_schedule: Improve synchronization in pi-ringfull
@ 2025-09-26 18:03 Krzysztof Niemiec
  2025-09-26 19:20 ` ✓ Xe.CI.BAT: success for tests/intel/gem_exec_schedule: Improve synchronization in pi-ringfull (rev2) Patchwork
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Krzysztof Niemiec @ 2025-09-26 18:03 UTC (permalink / raw)
  To: igt-dev
  Cc: Chris Wilson, Andi Shyti, Krzysztof Karas, Sebastian Brzezinka,
	Janusz Krzysztofik, Zbigniew Kempczynski, Krzysztof Niemiec

Move the interrupt timer from the parent thread to the child thread as
an explicit signal raise, and make sure the order of execution between
them is always the same. This reduces nondeterminism in the test, fixing
bugs like [1], where the child is starved out of CPU time up until the
parent gets signalled and monopolizes the CPU before the child could
submit its own execbuf, failing the test.

[1] https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14898

v2: make the sync variable actually work (Zbigniew)

Signed-off-by: Krzysztof Niemiec <krzysztof.niemiec@intel.com>
---
 tests/intel/gem_exec_schedule.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/tests/intel/gem_exec_schedule.c b/tests/intel/gem_exec_schedule.c
index 84219b4cf..2f3958723 100644
--- a/tests/intel/gem_exec_schedule.c
+++ b/tests/intel/gem_exec_schedule.c
@@ -2447,6 +2447,7 @@ static void test_pi_ringfull(int fd, const intel_ctx_cfg_t *cfg,
 	struct itimerval itv;
 	IGT_CORK_HANDLE(c);
 	bool *result;
+	bool *sync;
 
 	/*
 	 * We start simple. A low priority client should never prevent a high
@@ -2469,6 +2470,8 @@ static void test_pi_ringfull(int fd, const intel_ctx_cfg_t *cfg,
 	result = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
 	igt_assert(result != MAP_FAILED);
 
+	sync = result + 0x100;
+
 	memset(&execbuf, 0, sizeof(execbuf));
 	memset(&obj, 0, sizeof(obj));
 
@@ -2528,10 +2531,15 @@ static void test_pi_ringfull(int fd, const intel_ctx_cfg_t *cfg,
 
 	/* both parent + child on the same cpu, only parent is RT */
 	bind_to_cpu(0);
+	*sync = 0;
 
 	igt_fork(child, 1) {
 		int err;
 
+		/* We want the parent to always go first */
+		while (!*sync)
+			sched_yield();
+
 		/* Replace our batch to avoid conflicts over shared resources? */
 		if (!(flags & SHARED)) {
 			obj[1].handle = gem_create(fd, 4096);
@@ -2542,7 +2550,6 @@ static void test_pi_ringfull(int fd, const intel_ctx_cfg_t *cfg,
 
 		igt_debug("Waking parent\n");
 		kill(getppid(), SIGALRM);
-		sched_yield();
 		result[1] = true;
 
 		sigaction(SIGALRM, &sa, NULL);
@@ -2566,17 +2573,19 @@ static void test_pi_ringfull(int fd, const intel_ctx_cfg_t *cfg,
 
 		if (!(flags & SHARED))
 			gem_close(fd, obj[1].handle);
+
+		/* Interrupt parent's execbuf now that the child is done */
+		kill(getppid(), SIGALRM);
 	}
 
+	*sync = 1;
+
 	/* Relinquish CPU just to allow child to create a context */
-	sleep(1);
+	pause();
 	igt_assert_f(result[0], "HP context (child) not created\n");
 	igt_assert_f(!result[1], "Child released too early!\n");
 
 	/* Parent sleeps waiting for ringspace, releasing child */
-	itv.it_value.tv_sec = 0;
-	itv.it_value.tv_usec = 50000;
-	setitimer(ITIMER_REAL, &itv, NULL);
 	igt_debug("LP parent executing\n");
 	igt_assert_eq(__execbuf(fd, &execbuf), -EINTR);
 	igt_assert_f(result[1], "Child was not released!\n");
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-09-30  9:35 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-26 18:03 [PATCH v2 i-g-t] tests/intel/gem_exec_schedule: Improve synchronization in pi-ringfull Krzysztof Niemiec
2025-09-26 19:20 ` ✓ Xe.CI.BAT: success for tests/intel/gem_exec_schedule: Improve synchronization in pi-ringfull (rev2) Patchwork
2025-09-26 19:36 ` ✓ i915.CI.BAT: " Patchwork
2025-09-27  1:20 ` ✗ i915.CI.Full: failure " Patchwork
2025-09-27  2:12 ` ✗ Xe.CI.Full: " Patchwork
2025-09-29  5:47 ` [PATCH v2 i-g-t] tests/intel/gem_exec_schedule: Improve synchronization in pi-ringfull Zbigniew Kempczyński
2025-09-29  6:02 ` Krzysztof Karas
2025-09-29  8:44 ` Janusz Krzysztofik
2025-09-29 13:29   ` Krzysztof Niemiec
2025-09-30  9:35     ` Kamil Konieczny
2025-09-29 13:36 ` Sebastian Brzezinka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox