Thread (34 messages) 34 messages, 3 authors, 2021-01-15

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

From: Zbigniew Kempczyński <hidden>
Date: 2021-01-15 12:58:40
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
Reported-by: Andrzej Turko <redacted>
Cc: Andrzej Turko <redacted>
Cc: Dominik Grzegorzek <redacted>
Cc: Chris Wilson <redacted>
---
 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

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help