All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrzej Turko <andrzej.turko@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 2/3] tests/i915/api_intel_allocator: Exercise allocator in multiprocess mode
Date: Wed, 16 Jun 2021 16:01:57 +0200	[thread overview]
Message-ID: <20210616140158.7441-3-andrzej.turko@linux.intel.com> (raw)
In-Reply-To: <20210616140158.7441-1-andrzej.turko@linux.intel.com>

Test creation and usage of allocators in multiprocess mode
for contexts shared with the parent process as well as
private for the child.

This new test discovers a bug in the allocator implementation:
allocator is not correctly initialized if it is opened by
a child process using its private file descriptor.

Signed-off-by: Andrzej Turko <andrzej.turko@linux.intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
---
 tests/i915/api_intel_allocator.c | 40 ++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/tests/i915/api_intel_allocator.c b/tests/i915/api_intel_allocator.c
index ea4ba8bb1..fdfbdba82 100644
--- a/tests/i915/api_intel_allocator.c
+++ b/tests/i915/api_intel_allocator.c
@@ -621,6 +621,43 @@ static void execbuf_with_allocator(int fd)
 	igt_assert(intel_allocator_close(ahnd) == true);
 }
 
+static void fork_reopen_allocator(int fd, uint8_t type)
+{
+	uint64_t p_ahnd, sh_ahnd, fd_ahnd, ctx_ahnd;
+	uint64_t offset;
+
+	intel_allocator_multiprocess_start();
+
+	p_ahnd = intel_allocator_open(fd, 0, type);
+	offset = intel_allocator_alloc(p_ahnd, 1, 123, 0);
+	if (type == INTEL_ALLOCATOR_SIMPLE)
+		igt_assert(intel_allocator_is_allocated(p_ahnd, 1, 123, offset));
+
+	igt_fork(child, 1) {
+		sh_ahnd = intel_allocator_open(fd, 0, type);
+		if (type == INTEL_ALLOCATOR_SIMPLE)
+			igt_assert(intel_allocator_is_allocated(sh_ahnd, 1, 123, offset));
+
+		ctx_ahnd = intel_allocator_open(fd, 1, type);
+		igt_assert(!intel_allocator_is_allocated(ctx_ahnd, 1, 123, offset));
+		intel_allocator_alloc(ctx_ahnd, 2, 123, 0);
+
+		fd = gem_reopen_driver(fd);
+		fd_ahnd = intel_allocator_open(fd, 0, type);
+		igt_assert(!intel_allocator_is_allocated(fd_ahnd, 1, 123, offset));
+		intel_allocator_alloc(fd_ahnd, 2, 123, 0);
+
+		intel_allocator_close(sh_ahnd);
+		intel_allocator_close(ctx_ahnd);
+		intel_allocator_close(fd_ahnd);
+	}
+
+	igt_waitchildren();
+	intel_allocator_close(p_ahnd);
+
+	intel_allocator_multiprocess_stop();
+}
+
 struct allocators {
 	const char *name;
 	uint8_t type;
@@ -672,6 +709,9 @@ igt_main
 				igt_dynamic("reserve")
 					reserve(fd, a->type);
 			}
+
+			igt_dynamic("fork-reopen-allocator")
+					fork_reopen_allocator(fd, a->type);
 		}
 	}
 
-- 
2.25.1

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

  parent reply	other threads:[~2021-06-16 14:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16 14:01 [igt-dev] [PATCH v5 i-g-t 0/3] Fix the multiprocess mode of intel allocator Andrzej Turko
2021-06-16 14:01 ` [igt-dev] [PATCH i-g-t 1/3] lib/intel_allocator: Check validity of the file descriptor Andrzej Turko
2021-06-16 14:01 ` Andrzej Turko [this message]
2021-06-16 14:01 ` [igt-dev] [PATCH i-g-t 3/3] lib/intel_allocator: Move ioctl calls to client processes Andrzej Turko
2021-06-16 18:09 ` [igt-dev] ✓ Fi.CI.BAT: success for Fix the multiprocess mode of intel allocator Patchwork
2021-06-16 21:09 ` [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=20210616140158.7441-3-andrzej.turko@linux.intel.com \
    --to=andrzej.turko@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.