[igt-dev] [PATCH i-g-t v10 31/31] tests/api_intel_allocator: Prepare to run with sanitizer

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Fri Nov 20 11:31:31 UTC 2020


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 16f83c43..4085353c 100644
--- a/tests/i915/api_intel_allocator.c
+++ b/tests/i915/api_intel_allocator.c
@@ -381,13 +381,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) {
@@ -406,6 +400,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