[igt-dev] [PATCH i-g-t] igt/gem_userptr_blits: Check mlock requirement before asserting

Antonio Argenziano antonio.argenziano at intel.com
Wed Feb 7 18:47:23 UTC 2018


The tests that do mlocked evictions sometimes fail because a child they
spawn would map a lot of memory and get killed by OOM. This patch does
not consider this a fail since it is a requirement of the test to be
able to mlock the memory.

As a result of this patch some gem_userptr_blits at mlocked* tests might
start skipping instead of failing.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95427
Signed-off-by: Antonio Argenziano <antonio.argenziano at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
 lib/igt_core.c          | 40 ++++++++++++++++++++++++----------------
 lib/igt_core.h          |  1 +
 tests/eviction_common.c |  5 ++++-
 3 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 558a538d..86072761 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1687,20 +1687,7 @@ void igt_child_done(pid_t pid)
 		test_children[i] = test_children[i + 1];
 }
 
-/**
- * igt_waitchildren:
- *
- * Wait for all children forked with igt_fork.
- *
- * The magic here is that exit codes from children will be correctly propagated
- * to the main thread, including the relevant exit code if a child thread failed.
- * Of course if multiple children failed with different exit codes the resulting
- * exit code will be non-deterministic.
- *
- * Note that igt_skip() will not be forwarded, feature tests need to be done
- * before spawning threads with igt_fork().
- */
-void igt_waitchildren(void)
+int __igt_waitchildren(void)
 {
 	int err = 0;
 	int count;
@@ -1746,8 +1733,29 @@ void igt_waitchildren(void)
 	}
 
 	num_test_children = 0;
-	if (err)
-		igt_fail(err);
+
+	return err;
+}
+
+/**
+ * igt_waitchildren:
+ *
+ * Wait for all children forked with igt_fork.
+ *
+ * The magic here is that exit codes from children will be correctly propagated
+ * to the main thread, including the relevant exit code if a child thread failed.
+ * Of course if multiple children failed with different exit codes the resulting
+ * exit code will be non-deterministic.
+ *
+ * Note that igt_skip() will not be forwarded, feature tests need to be done
+ * before spawning threads with igt_fork().
+ */
+void igt_waitchildren(void)
+{
+	int ret = __igt_waitchildren();
+
+	if (ret)
+		igt_fail(ret);
 }
 
 /**
diff --git a/lib/igt_core.h b/lib/igt_core.h
index f8543d65..049edb5c 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -689,6 +689,7 @@ bool __igt_fork(void);
 	for (int child = 0; child < (num_children); child++) \
 		for (; __igt_fork(); exit(0))
 void igt_child_done(pid_t pid);
+int __igt_waitchildren(void);
 void igt_waitchildren(void);
 void igt_waitchildren_timeout(int seconds, const char *reason);
 
diff --git a/tests/eviction_common.c b/tests/eviction_common.c
index 300eb03d..655ea0bd 100644
--- a/tests/eviction_common.c
+++ b/tests/eviction_common.c
@@ -135,6 +135,7 @@ static void mlocked_evictions(int fd, struct igt_eviction_test_ops *ops,
 {
 	unsigned int *can_mlock;
 	uint64_t sz, pin;
+	int child_ret;
 
 	intel_require_memory(surface_count, surface_size, CHECK_RAM);
 
@@ -158,8 +159,10 @@ static void mlocked_evictions(int fd, struct igt_eviction_test_ops *ops,
 		if (locked != NULL && !mlock(locked, pin + sz))
 			*can_mlock = 1;
 	}
-	igt_waitchildren();
+	child_ret = __igt_waitchildren();
 	igt_require(*can_mlock);
+	igt_assert(child_ret == 0);
+
 	munmap(can_mlock, 4096);
 
 	igt_fork(child, 1) {
-- 
2.14.2



More information about the igt-dev mailing list