public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v2 5/5] tests/gem_exec_parallel: Avoid acquiring offset for overlapping handle
Date: Mon,  5 Dec 2022 21:27:08 +0100	[thread overview]
Message-ID: <20221205202708.76217-6-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20221205202708.76217-1-zbigniew.kempczynski@intel.com>

Subtest @fds incorporates objects created in some context in new context
created on new (reopened) drm fd. This might lead to clash handles
(same handle created over different fd,ctx) so acquiring offsets from
stateful allocator (reloc is from now on stateful for alloc()/free()
ops) might lead to bind same offset for two different objects. Lets
use some artificial (last max handle + 1) handle for bb to avoid offset
overlapping.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
---
 tests/i915/gem_exec_parallel.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/tests/i915/gem_exec_parallel.c b/tests/i915/gem_exec_parallel.c
index 730fc4a672..429620884b 100644
--- a/tests/i915/gem_exec_parallel.c
+++ b/tests/i915/gem_exec_parallel.c
@@ -75,7 +75,7 @@ static void *thread(void *data)
 	struct drm_i915_gem_relocation_entry reloc;
 	struct drm_i915_gem_execbuffer2 execbuf;
 	const intel_ctx_t *tmp_ctx = NULL;
-	uint64_t offset;
+	uint64_t offset, bb_offset;
 	uint32_t batch[16];
 	uint16_t used;
 	int fd, i;
@@ -136,6 +136,18 @@ static void *thread(void *data)
 		execbuf.rsvd1 = t->ctx->id;
 	}
 
+	/*
+	 * For FDS we have new drm fd, what means gem_create() for bb returns
+	 * handle == 1. As we're using objects from other fd it would overlap,
+	 * thus we need to acquire offset for bb from last handle + 1.
+	 * Other cases are within same fd, so obj[1].handle will be distinguish
+	 * anyway.
+	 */
+	if (t->flags & FDS)
+		bb_offset = get_offset(t->ahnd, t->scratch[NUMOBJ - 1] + 1, 4096, 0);
+	else
+		bb_offset = get_offset(t->ahnd, obj[1].handle, 4096, 0);
+
 	used = 0;
 	igt_until_timeout(1) {
 		unsigned int x = rand() % NUMOBJ;
@@ -154,7 +166,7 @@ static void *thread(void *data)
 			obj[0].offset = offset;
 			obj[0].flags |= EXEC_OBJECT_PINNED | EXEC_OBJECT_WRITE |
 					EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
-			obj[1].offset = get_offset(t->ahnd, obj[1].handle, 4096, 0);
+			obj[1].offset = bb_offset;
 			obj[1].flags |= EXEC_OBJECT_PINNED | EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
 			gem_write(fd, obj[1].handle, 0, batch, sizeof(batch));
 		}
-- 
2.34.1

  parent reply	other threads:[~2022-12-05 20:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-05 20:27 [igt-dev] [PATCH i-g-t v2 0/5] Remove random allocator and improve reloc one Zbigniew Kempczyński
2022-12-05 20:27 ` [igt-dev] [PATCH i-g-t v2 1/5] lib/intel_allocator: Remove RANDOM allocator Zbigniew Kempczyński
2022-12-06 15:56   ` Kamil Konieczny
2022-12-05 20:27 ` [igt-dev] [PATCH i-g-t v2 2/5] tests/api_intel_allocator: Remove duplicated reuse and reserve subtests Zbigniew Kempczyński
2022-12-06 15:58   ` Kamil Konieczny
2022-12-05 20:27 ` [igt-dev] [PATCH i-g-t v2 3/5] lib/intel_allocator_reloc: Introduce stateful allocations in reloc Zbigniew Kempczyński
2022-12-06 21:39   ` Kamil Konieczny
2022-12-05 20:27 ` [igt-dev] [PATCH i-g-t v2 4/5] tests/gem_ctx_shared: Remove necessity of passing offset to function call Zbigniew Kempczyński
2022-12-06 16:31   ` Kamil Konieczny
2022-12-05 20:27 ` Zbigniew Kempczyński [this message]
2022-12-06 17:06   ` [igt-dev] [PATCH i-g-t v2 5/5] tests/gem_exec_parallel: Avoid acquiring offset for overlapping handle Kamil Konieczny
2022-12-07 11:28     ` Zbigniew Kempczyński
2022-12-05 21:06 ` [igt-dev] ✓ Fi.CI.BAT: success for Remove random allocator and improve reloc one (rev2) Patchwork
2022-12-05 22:24 ` [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=20221205202708.76217-6-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox