[igt-dev] [PATCH i-g-t v19 32/34] tests/api_intel_allocator: Prepare to run with sanitizer

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Tue Feb 2 09:24:41 UTC 2021


Allocator code is fragile as it runs in multiprocess environment so
we want to validate its memory consistency using address sanitizer.
As allocator thread is spawned in the main process we need to
create children first before it will start allocating. Otherwise
we can incidentally pass shadow map snapshot to child/children
giving false-positive in sanitizer and fail the test.

Playing with sanitizer reveals it has a bug when multiple children
exists and signals are delivered to them. So we must be careful
when sanitizer and igt_fork_signal_handler() are used together.
Bug is revealed with code:
https://patchwork.freedesktop.org/patch/401979/?series=84102&rev=1

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Reported-by: Andrzej Turko <andrzej.turko at linux.intel.com>
Cc: Andrzej Turko <andrzej.turko at linux.intel.com>
Cc: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
 tests/i915/api_intel_allocator.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/tests/i915/api_intel_allocator.c b/tests/i915/api_intel_allocator.c
index 650c2ff5e..a7c23a4ef 100644
--- a/tests/i915/api_intel_allocator.c
+++ b/tests/i915/api_intel_allocator.c
@@ -362,13 +362,7 @@ static void fork_simple_stress(int fd, bool two_level_inception)
 	uint64_t ahnd0, ahnd1;
 	bool are_empty;
 
-	intel_allocator_multiprocess_start();
-
-	ahnd0 = intel_allocator_open(fd, 0, INTEL_ALLOCATOR_SIMPLE);
-	ahnd1 = intel_allocator_open(fd, 1, INTEL_ALLOCATOR_SIMPLE);
-
-	pthread_create(&thread0, NULL, __fork_simple_thread, (void *) (long) fd);
-	pthread_create(&thread1, NULL, __fork_simple_thread, (void *) (long) fd);
+	__intel_allocator_multiprocess_prepare();
 
 	igt_fork(child, 8) {
 		if (two_level_inception) {
@@ -387,6 +381,15 @@ static void fork_simple_stress(int fd, bool two_level_inception)
 			pthread_join(thread1, NULL);
 		}
 	}
+
+	pthread_create(&thread0, NULL, __fork_simple_thread, (void *) (long) fd);
+	pthread_create(&thread1, NULL, __fork_simple_thread, (void *) (long) fd);
+
+	ahnd0 = intel_allocator_open(fd, 0, INTEL_ALLOCATOR_SIMPLE);
+	ahnd1 = intel_allocator_open(fd, 1, INTEL_ALLOCATOR_SIMPLE);
+
+	__intel_allocator_multiprocess_start();
+
 	igt_waitchildren();
 
 	pthread_join(thread0, NULL);
-- 
2.26.0



More information about the igt-dev mailing list