public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
To: Petri Latvala <petri.latvala@intel.com>,
	Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v2 1/1] tests/prime_vgem: Fix broken handling of interprocess pipes
Date: Thu, 11 Jul 2019 10:39:58 +0200	[thread overview]
Message-ID: <20190711083958.6935-2-janusz.krzysztofik@linux.intel.com> (raw)
In-Reply-To: <20190711083958.6935-1-janusz.krzysztofik@linux.intel.com>

If a child process dies for any reason while basic-fence-read or
basic-fence-mmap subtest is run, the subtest may hang indefinitely on
read() from a pipe which is supposed to be written to by that child (can
be interrupted though).  Fix it by first closing unused pipe ends on both
parent and child side before using the pipe, as recommended by pipe(2)
manual page.

Please note that due to the IGT library way of handling signals, now the
subtests may fail with error code 141 (128 + SIGPIPE) and no usual DEBUG
message block on stderr nor FAIL message line on stdout, however some
meaningful error messages will still be printed on stderr by the failing
child processes.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/prime_vgem.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
index 69ae8c9b..bebf9edc 100644
--- a/tests/prime_vgem.c
+++ b/tests/prime_vgem.c
@@ -82,6 +82,8 @@ static void test_fence_read(int i915, int vgem)
 	close(dmabuf);
 
 	igt_fork(child, 1) {
+		close(master[0]);
+		close(slave[1]);
 		for (i = 0; i < 1024; i++) {
 			uint32_t tmp;
 			gem_read(i915, handle, 4096*i, &tmp, sizeof(tmp));
@@ -97,6 +99,8 @@ static void test_fence_read(int i915, int vgem)
 		gem_close(i915, handle);
 	}
 
+	close(master[1]);
+	close(slave[0]);
 	read(master[0], &i, sizeof(i));
 	fence = vgem_fence_attach(vgem, &scratch, VGEM_FENCE_WRITE);
 	write(slave[1], &i, sizeof(i));
@@ -110,8 +114,6 @@ static void test_fence_read(int i915, int vgem)
 
 	igt_waitchildren();
 	close(master[0]);
-	close(master[1]);
-	close(slave[0]);
 	close(slave[1]);
 }
 
@@ -137,6 +139,8 @@ static void test_fence_mmap(int i915, int vgem)
 	close(dmabuf);
 
 	igt_fork(child, 1) {
+		close(master[0]);
+		close(slave[1]);
 		ptr = gem_mmap__gtt(i915, handle, 4096*1024, PROT_READ);
 
 		gem_set_domain(i915, handle, I915_GEM_DOMAIN_GTT, 0);
@@ -153,6 +157,8 @@ static void test_fence_mmap(int i915, int vgem)
 		gem_close(i915, handle);
 	}
 
+	close(master[1]);
+	close(slave[0]);
 	read(master[0], &i, sizeof(i));
 	fence = vgem_fence_attach(vgem, &scratch, VGEM_FENCE_WRITE);
 	write(slave[1], &i, sizeof(i));
@@ -166,8 +172,6 @@ static void test_fence_mmap(int i915, int vgem)
 
 	igt_waitchildren();
 	close(master[0]);
-	close(master[1]);
-	close(slave[0]);
 	close(slave[1]);
 }
 
-- 
2.21.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2019-07-11  8:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-11  8:39 [igt-dev] [PATCH i-g-t v2 0/1] tests/prime_vgem: Fix broken handling of interprocess pipes Janusz Krzysztofik
2019-07-11  8:39 ` Janusz Krzysztofik [this message]
2019-07-11 10:39 ` Ser, Simon
2019-07-11 10:49   ` Janusz Krzysztofik
2019-07-11 11:17     ` Ser, Simon
2019-07-11 14:17 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/prime_vgem: Fix broken handling of interprocess pipes (rev2) Patchwork
2019-07-12  5:47 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190711083958.6935-2-janusz.krzysztofik@linux.intel.com \
    --to=janusz.krzysztofik@linux.intel.com \
    --cc=arkadiusz.hiler@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=petri.latvala@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox