Dynamic sub-subtests of smem-oom subtest spawn smem memory hog helper
processes which are expected to be killed by OOM killer.  When that
happens, a default IGT signal helper inherited from its parent process is
now executed inside the helper process.  That leads to a dynamic sub-
subtest CRASH result message sent to stdout, followed by a parent subtest
SUCCESS result message.  Meanwhile, processing of the dynamic sub-subtest
that spawned that helper still continues, and then another set of result
messages is submitted on its completion.  As a consequence, ambiguous
results from that dynamic sub-subtests and its parent subtest are detected
and reported by igt_runner, even if an error code returned by the helper
is ignored.

Shut those redundant messages up by installing a custom signal handler
that just exists the helper process when killed by the OOM killer, without
reporting any IGT results or executing any IGT exit handlers.

Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/5493
Signed-off-by: Janusz Krzysztofik <[email protected]>
---
 tests/intel/gem_lmem_swapping.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tests/intel/gem_lmem_swapping.c b/tests/intel/gem_lmem_swapping.c
index 8e0dac42d8..5e11092c04 100644
--- a/tests/intel/gem_lmem_swapping.c
+++ b/tests/intel/gem_lmem_swapping.c
@@ -668,6 +668,11 @@ static void smem_oom_exit_handler(int sig)
        (*lmem_done)++;
 }
 
+static void smem_oom_helper_sig_handler(int sig)
+{
+       _exit(0);
+}
+
 static void test_smem_oom(int i915,
                          const intel_ctx_t *ctx,
                          struct drm_i915_memory_region_info *region)
@@ -706,6 +711,8 @@ static void test_smem_oom(int i915,
        while (!READ_ONCE(*lmem_done)) {
                igt_fork_helper(&smem_proc) {
                        igt_fork(child, 1) {
+                               signal(SIGBUS, smem_oom_helper_sig_handler);
+
                                for (int pass = 0; pass < num_alloc; pass++) {
                                        if (READ_ONCE(*lmem_done))
                                                break;
@@ -715,6 +722,8 @@ static void test_smem_oom(int i915,
                        igt_fork(child, 1) {
                                int fd = drm_reopen_driver(i915);
 
+                               signal(SIGBUS, smem_oom_helper_sig_handler);
+
                                for (int pass = 0; pass < num_alloc; pass++) {
                                        if (READ_ONCE(*lmem_done))
                                                break;
-- 
2.51.1

Reply via email to