From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t] tests/xe_create: Add multiple engines create/destroy subtest
Date: Wed, 7 Jun 2023 19:40:28 +0200 [thread overview]
Message-ID: <20230607174028.77235-1-zbigniew.kempczynski@intel.com> (raw)
Exercise basic engine concurrency create/destroy functionality.
v2: use different random seeds in children to avoid same engine
pattern selection (Kamil)
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
tests/xe/xe_create.c | 94 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+)
diff --git a/tests/xe/xe_create.c b/tests/xe/xe_create.c
index ae21154646..be26583b7a 100644
--- a/tests/xe/xe_create.c
+++ b/tests/xe/xe_create.c
@@ -88,6 +88,94 @@ static void create_invalid_size(int fd)
xe_vm_destroy(fd, vm);
}
+enum engine_destroy {
+ NOLEAK,
+ LEAK
+};
+
+static uint32_t __xe_engine_create(int fd, uint32_t vm,
+ struct drm_xe_engine_class_instance *instance,
+ uint64_t ext,
+ uint32_t *enginep)
+{
+ struct drm_xe_engine_create create = {
+ .extensions = ext,
+ .vm_id = vm,
+ .width = 1,
+ .num_placements = 1,
+ .instances = to_user_pointer(instance),
+ };
+ int err = 0;
+
+ if (igt_ioctl(fd, DRM_IOCTL_XE_ENGINE_CREATE, &create) == 0) {
+ *enginep = create.engine_id;
+ } else {
+ igt_warn("Can't create engine, errno: %d\n", errno);
+ err = -errno;
+ igt_assume(err);
+ }
+ errno = 0;
+
+ return err;
+}
+
+#define MAXENGINES 2048
+
+/**
+ * SUBTEST: create-engines-%s
+ * Description: Check process ability of multiple engines creation
+ * Run type: FULL
+ *
+ * arg[1]:
+ *
+ * @noleak: destroy engines in the code
+ * @leak: destroy engines in close() path
+ */
+static void create_engines(int fd, enum engine_destroy ed)
+{
+ uint32_t num_engines, engines_per_process, vm;
+ int nproc = sysconf(_SC_NPROCESSORS_ONLN);
+
+ fd = drm_reopen_driver(fd);
+ num_engines = xe_number_hw_engines(fd);
+ vm = xe_vm_create(fd, DRM_XE_VM_CREATE_ASYNC_BIND_OPS, 0);
+
+ engines_per_process = max_t(uint32_t, 1, MAXENGINES / nproc);
+ igt_debug("nproc: %u, engines per process: %u\n", nproc, engines_per_process);
+
+ igt_fork(n, nproc) {
+ struct drm_xe_engine_class_instance *hwe;
+ uint32_t engine, engines[engines_per_process];
+ int idx, err, i;
+
+ srandom(n);
+
+ for (i = 0; i < engines_per_process; i++) {
+ idx = rand() % num_engines;
+ hwe = xe_hw_engine(fd, idx);
+ err = __xe_engine_create(fd, vm, hwe, 0, &engine);
+ igt_debug("[%2d] Create engine: err=%d, engine=%u [idx = %d]\n",
+ n, err, engine, i);
+ if (err)
+ break;
+
+ if (ed == NOLEAK)
+ engines[i] = engine;
+ }
+
+ if (ed == NOLEAK) {
+ while (--i >= 0) {
+ igt_debug("[%2d] Destroy engine: %u\n", n, engines[i]);
+ xe_engine_destroy(fd, engines[i]);
+ }
+ }
+ }
+ igt_waitchildren();
+
+ xe_vm_destroy(fd, vm);
+ close(fd);
+}
+
/**
* SUBTEST: create-massive-size
* Description: Verifies xe bo create returns expected error code on massive
@@ -121,6 +209,12 @@ igt_main
create_invalid_size(xe);
}
+ igt_subtest("create-engines-noleak")
+ create_engines(xe, NOLEAK);
+
+ igt_subtest("create-engines-leak")
+ create_engines(xe, LEAK);
+
igt_subtest("create-massive-size") {
create_massive_size(xe);
}
--
2.34.1
next reply other threads:[~2023-06-07 17:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-07 17:40 Zbigniew Kempczyński [this message]
2023-06-07 17:43 ` [igt-dev] ✗ GitLab.Pipeline: warning for tests/xe_create: Add multiple engines create/destroy subtest (rev2) Patchwork
2023-06-07 18:16 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-06-08 8:55 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2023-06-06 12:37 [igt-dev] [PATCH i-g-t] tests/xe_create: Add multiple engines create/destroy subtest Zbigniew Kempczyński
2023-06-07 17:23 ` Kamil Konieczny
2023-06-07 17:30 ` Zbigniew Kempczyński
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=20230607174028.77235-1-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