* [PATCH] tests/intel/xe_exec_compute_mode: Add userptr free / munmap sections
@ 2024-03-16 5:45 Matthew Brost
2024-03-16 5:58 ` ✗ Fi.CI.BUILD: failure for " Patchwork
2024-03-16 6:03 ` ✗ GitLab.Pipeline: warning " Patchwork
0 siblings, 2 replies; 6+ messages in thread
From: Matthew Brost @ 2024-03-16 5:45 UTC (permalink / raw)
To: igt-dev; +Cc: Matthew Brost
Add userptr free / munmap sections which does the aforementioned while
the userptr still has a mapping. The userptr will be invalidated
triggering a rebind which will faill pinning pages as the userptr is no
longer valid. This is allowed and should not corrupt the VM or future
submissions.
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
tests/intel/xe_exec_compute_mode.c | 44 ++++++++++++++++++++++++++----
1 file changed, 38 insertions(+), 6 deletions(-)
diff --git a/tests/intel/xe_exec_compute_mode.c b/tests/intel/xe_exec_compute_mode.c
index 7dad715093..1700cbae10 100644
--- a/tests/intel/xe_exec_compute_mode.c
+++ b/tests/intel/xe_exec_compute_mode.c
@@ -28,9 +28,11 @@
#define REBIND (0x1 << 1)
#define INVALIDATE (0x1 << 2)
#define RACE (0x1 << 3)
-#define BIND_EXECQUEUE (0x1 << 4)
+#define BIND_EXECQUEUE (0x1 << 4)
#define VM_FOR_BO (0x1 << 5)
-#define EXEC_QUEUE_EARLY (0x1 << 6)
+#define EXEC_QUEUE_EARLY (0x1 << 6)
+#define FREE_MAPPPING (0x1 << 7)
+#define UNMAP_MAPPPING (0x1 << 8)
/**
* SUBTEST: twice-%s
@@ -50,6 +52,8 @@
* @basic: basic
* @preempt-fence-early: preempt fence early
* @userptr: userptr
+ * @userptr-free: userptr free
+ * @userptr-unmap: userptr unmap
* @rebind: rebind
* @userptr-rebind: userptr rebind
* @userptr-invalidate: userptr invalidate
@@ -71,8 +75,11 @@
* arg[1]:
*
* @basic: basic
+ * @malloc-ufence: malloc user fence
* @preempt-fence-early: preempt fence early
* @userptr: userptr
+ * @userptr-free: userptr free
+ * @userptr-unmap: userptr unmap
* @rebind: rebind
* @userptr-rebind: userptr rebind
* @userptr-invalidate: userptr invalidate
@@ -87,7 +94,7 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
int n_exec_queues, int n_execs, unsigned int flags)
{
uint32_t vm;
- uint64_t addr = 0x1a0000;
+ uint64_t addr = 0x1a0000, dummy_addr = 0x10001a0000;
#define USER_FENCE_VALUE 0xdeadbeefdeadbeefull
struct drm_xe_sync sync[1] = {
{ .type = DRM_XE_SYNC_TYPE_USER_FENCE,
@@ -113,6 +120,7 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
int i, j, b;
int map_fd = -1;
int64_t fence_timeout;
+ void *dummy;
igt_assert(n_exec_queues <= MAX_N_EXECQUEUES);
@@ -141,6 +149,17 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
bo_size);
igt_assert(data);
}
+ if (flags & UNMAP_MAPPPING) {
+ dummy = mmap((void *)MAP_ADDRESS, bo_size, PROT_READ |
+ PROT_WRITE, MAP_SHARED | MAP_FIXED |
+ MAP_ANONYMOUS, -1, 0);
+ igt_assert(data != MAP_FAILED);
+ }
+ if (flags & FREE_MAPPPING) {
+ dummy = aligned_alloc(xe_get_default_alignment(fd),
+ bo_size);
+ igt_assert(dummy);
+ }
} else {
bo = xe_bo_create(fd, flags & VM_FOR_BO ? vm : 0,
bo_size, vram_if_possible(fd, eci->gt_id),
@@ -156,16 +175,21 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
xe_bind_exec_queue_create(fd, vm, 0);
else
bind_exec_queues[i] = 0;
- };
+ }
sync[0].addr = to_user_pointer(&data[0].vm_sync);
- if (bo)
+ if (bo) {
xe_vm_bind_async(fd, vm, bind_exec_queues[0], bo, 0, addr,
bo_size, sync, 1);
- else
+ } else {
+ if (flags & (FREE_MAPPPING | UNMAP_MAPPPING))
+ xe_vm_bind_userptr_async(fd, vm, bind_exec_queues[0],
+ to_user_pointer(dummy),
+ dummy_addr, bo_size, 0, 0);
xe_vm_bind_userptr_async(fd, vm, bind_exec_queues[0],
to_user_pointer(data), addr,
bo_size, sync, 1);
+ }
#define ONE_SEC MS_TO_NS(1000)
#define HUNDRED_SEC MS_TO_NS(100000)
@@ -196,6 +220,12 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
exec.address = batch_addr;
xe_exec(fd, &exec);
+ if (flags & FREE_MAPPPING && !i)
+ free(dummy);
+
+ if (flags & UNMAP_MAPPPING && !i)
+ munmap(dummy, bo_size);
+
if (flags & REBIND && i + 1 != n_execs) {
xe_wait_ufence(fd, &data[i].exec_sync, USER_FENCE_VALUE,
exec_queues[e], fence_timeout);
@@ -410,6 +440,8 @@ igt_main
{ "basic", 0 },
{ "preempt-fence-early", VM_FOR_BO | EXEC_QUEUE_EARLY },
{ "userptr", USERPTR },
+ { "userptr-free", USERPTR | FREE_MAPPPING },
+ { "userptr-unmap", USERPTR | UNMAP_MAPPPING },
{ "rebind", REBIND },
{ "userptr-rebind", USERPTR | REBIND },
{ "userptr-invalidate", USERPTR | INVALIDATE },
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* ✗ Fi.CI.BUILD: failure for tests/intel/xe_exec_compute_mode: Add userptr free / munmap sections
2024-03-16 5:45 [PATCH] tests/intel/xe_exec_compute_mode: Add userptr free / munmap sections Matthew Brost
@ 2024-03-16 5:58 ` Patchwork
2024-03-16 6:03 ` ✗ GitLab.Pipeline: warning " Patchwork
1 sibling, 0 replies; 6+ messages in thread
From: Patchwork @ 2024-03-16 5:58 UTC (permalink / raw)
To: Matthew Brost; +Cc: igt-dev
== Series Details ==
Series: tests/intel/xe_exec_compute_mode: Add userptr free / munmap sections
URL : https://patchwork.freedesktop.org/series/131211/
State : failure
== Summary ==
IGT patchset build failed on latest successful build
ed47dd9fb6b5be6c88513c2816f0f7cfdd0e02f6 scripts/xls_to_doc.py: make pylint happy
Tail of build.log:
Warning: igt@sysfs_heartbeat_interval@off Functionality documentation is missing
Warning: igt@sysfs_heartbeat_interval@precise Category documentation is missing
Warning: igt@sysfs_heartbeat_interval@precise Sub-category documentation is missing
Warning: igt@sysfs_heartbeat_interval@precise Functionality documentation is missing
Warning: igt@sysfs_preempt_timeout@idempotent Category documentation is missing
Warning: igt@sysfs_preempt_timeout@idempotent Sub-category documentation is missing
Warning: igt@sysfs_preempt_timeout@idempotent Functionality documentation is missing
Warning: igt@sysfs_preempt_timeout@invalid Category documentation is missing
Warning: igt@sysfs_preempt_timeout@invalid Sub-category documentation is missing
Warning: igt@sysfs_preempt_timeout@invalid Functionality documentation is missing
Warning: igt@sysfs_preempt_timeout@off Category documentation is missing
Warning: igt@sysfs_preempt_timeout@off Sub-category documentation is missing
Warning: igt@sysfs_preempt_timeout@off Functionality documentation is missing
Warning: igt@sysfs_preempt_timeout@timeout Category documentation is missing
Warning: igt@sysfs_preempt_timeout@timeout Sub-category documentation is missing
Warning: igt@sysfs_preempt_timeout@timeout Functionality documentation is missing
Warning: igt@sysfs_timeslice_duration@duration Category documentation is missing
Warning: igt@sysfs_timeslice_duration@duration Sub-category documentation is missing
Warning: igt@sysfs_timeslice_duration@duration Functionality documentation is missing
Warning: igt@sysfs_timeslice_duration@idempotent Category documentation is missing
Warning: igt@sysfs_timeslice_duration@idempotent Sub-category documentation is missing
Warning: igt@sysfs_timeslice_duration@idempotent Functionality documentation is missing
Warning: igt@sysfs_timeslice_duration@invalid Category documentation is missing
Warning: igt@sysfs_timeslice_duration@invalid Sub-category documentation is missing
Warning: igt@sysfs_timeslice_duration@invalid Functionality documentation is missing
Warning: igt@sysfs_timeslice_duration@off Category documentation is missing
Warning: igt@sysfs_timeslice_duration@off Sub-category documentation is missing
Warning: igt@sysfs_timeslice_duration@off Functionality documentation is missing
Warning: igt@sysfs_timeslice_duration@timeout Category documentation is missing
Warning: igt@sysfs_timeslice_duration@timeout Sub-category documentation is missing
Warning: igt@sysfs_timeslice_duration@timeout Functionality documentation is missing
Warning: igt@vgem_basic@bad-fence Sub-category documentation is missing
Warning: igt@vgem_basic@bad-flag Sub-category documentation is missing
Warning: igt@vgem_basic@bad-handle Sub-category documentation is missing
Warning: igt@vgem_basic@bad-pad Sub-category documentation is missing
Warning: igt@vgem_basic@busy-fence Sub-category documentation is missing
Warning: igt@vgem_basic@create Sub-category documentation is missing
Warning: igt@vgem_basic@debugfs Sub-category documentation is missing
Warning: igt@vgem_basic@dmabuf-export Sub-category documentation is missing
Warning: igt@vgem_basic@dmabuf-fence Sub-category documentation is missing
Warning: igt@vgem_basic@dmabuf-fence-before Sub-category documentation is missing
Warning: igt@vgem_basic@dmabuf-mmap Sub-category documentation is missing
Warning: igt@vgem_basic@mmap Sub-category documentation is missing
Warning: igt@vgem_basic@second-client Sub-category documentation is missing
Warning: igt@vgem_basic@setversion Sub-category documentation is missing
Warning: igt@vgem_basic@sysfs Sub-category documentation is missing
Warning: igt@vgem_basic@unload Sub-category documentation is missing
[1667/1672] Generating kms_tests.rst with a custom command.
[1668/1672] Generating intel-ci-tests with a custom command.
ninja: build stopped: subcommand failed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* ✗ GitLab.Pipeline: warning for tests/intel/xe_exec_compute_mode: Add userptr free / munmap sections
2024-03-16 5:45 [PATCH] tests/intel/xe_exec_compute_mode: Add userptr free / munmap sections Matthew Brost
2024-03-16 5:58 ` ✗ Fi.CI.BUILD: failure for " Patchwork
@ 2024-03-16 6:03 ` Patchwork
1 sibling, 0 replies; 6+ messages in thread
From: Patchwork @ 2024-03-16 6:03 UTC (permalink / raw)
To: Matthew Brost; +Cc: igt-dev
== Series Details ==
Series: tests/intel/xe_exec_compute_mode: Add userptr free / munmap sections
URL : https://patchwork.freedesktop.org/series/131211/
State : warning
== Summary ==
Pipeline status: FAILED.
see https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/1129314 for the overview.
build:tests-debian-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/56378285):
[1/821] Generating version.h with a custom command.
[2/8] Linking target runner/runner_test.
[3/8] Linking target assembler/intel-gen4asm.
[4/8] Generating kms_tests.html with a custom command.
[5/8] Generating i915_tests.html with a custom command.
[6/8] Generating xe_tests.rst with a custom command.
FAILED: docs/testplan/xe_tests.rst
/builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
Warning: igt@sriov_basic@bind-unbind-vf Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-autoprobe-off Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-autoprobe-on Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-bind-unbind-each Functionality documentation is missing
Warning: Documented igt@xe_exec_compute_mode@many-execqueues-malloc-ufence doesn't exist on source files
ninja: build stopped: subcommand failed.
section_end:1710568787:step_script
section_start:1710568787:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1710568788:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/56378280):
[1/823] Generating version.h with a custom command.
[2/7] Linking target runner/runner_test.
[3/7] Generating kms_tests.html with a custom command.
[4/7] Generating i915_tests.html with a custom command.
[5/7] Generating intel-ci-tests with a custom command.
[6/7] Generating xe_tests.rst with a custom command.
FAILED: docs/testplan/xe_tests.rst
/builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
Warning: igt@sriov_basic@bind-unbind-vf Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-autoprobe-off Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-autoprobe-on Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-bind-unbind-each Functionality documentation is missing
Warning: Documented igt@xe_exec_compute_mode@many-execqueues-malloc-ufence doesn't exist on source files
ninja: build stopped: subcommand failed.
section_end:1710568790:step_script
section_start:1710568790:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1710568791:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-clang has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/56378284):
ninja: Entering directory `build'
[1/823] Generating version.h with a custom command.
[2/6] Generating intel-ci-tests with a custom command.
[3/6] Generating i915_tests.html with a custom command.
[4/6] Generating kms_tests.html with a custom command.
[5/6] Generating xe_tests.rst with a custom command.
FAILED: docs/testplan/xe_tests.rst
/builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
Warning: igt@sriov_basic@bind-unbind-vf Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-autoprobe-off Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-autoprobe-on Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-bind-unbind-each Functionality documentation is missing
Warning: Documented igt@xe_exec_compute_mode@many-execqueues-malloc-ufence doesn't exist on source files
ninja: build stopped: subcommand failed.
section_end:1710568813:step_script
section_start:1710568813:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1710568814:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-no-libdrm-nouveau has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/56378283):
[1/773] Generating version.h with a custom command.
[2/7] Linking target runner/runner_test.
[3/7] Generating kms_tests.html with a custom command.
[4/7] Generating i915_tests.html with a custom command.
[5/7] Generating intel-ci-tests with a custom command.
[6/7] Generating xe_tests.rst with a custom command.
FAILED: docs/testplan/xe_tests.rst
/builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
Warning: igt@sriov_basic@bind-unbind-vf Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-autoprobe-off Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-autoprobe-on Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-bind-unbind-each Functionality documentation is missing
Warning: Documented igt@xe_exec_compute_mode@many-execqueues-malloc-ufence doesn't exist on source files
ninja: build stopped: subcommand failed.
section_end:1710568793:step_script
section_start:1710568793:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1710568794:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-no-libunwind has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/56378281):
[2/8] Linking target runner/runner_test.
[3/8] Linking target assembler/intel-gen4asm.
[4/8] Generating kms_tests.html with a custom command.
[5/8] Generating i915_tests.html with a custom command.
[6/8] Generating intel-ci-tests with a custom command.
[7/8] Generating xe_tests.rst with a custom command.
FAILED: docs/testplan/xe_tests.rst
/builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
Warning: igt@sriov_basic@bind-unbind-vf Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-autoprobe-off Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-autoprobe-on Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-bind-unbind-each Functionality documentation is missing
Warning: Documented igt@xe_exec_compute_mode@many-execqueues-malloc-ufence doesn't exist on source files
ninja: build stopped: subcommand failed.
section_end:1710568794:step_script
section_start:1710568794:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1710568795:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-oldest-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/56378282):
[1/823] Generating version.h with a custom command.
[2/7] Linking target runner/runner_test.
[3/7] Generating i915_tests.html with a custom command.
[4/7] Generating intel-ci-tests with a custom command.
[5/7] Generating kms_tests.html with a custom command.
[6/7] Generating xe_tests.rst with a custom command.
FAILED: docs/testplan/xe_tests.rst
/builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
Warning: igt@sriov_basic@bind-unbind-vf Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-autoprobe-off Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-autoprobe-on Functionality documentation is missing
Warning: igt@sriov_basic@enable-vfs-bind-unbind-each Functionality documentation is missing
Warning: Documented igt@xe_exec_compute_mode@many-execqueues-malloc-ufence doesn't exist on source files
ninja: build stopped: subcommand failed.
section_end:1710568793:step_script
section_start:1710568793:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1710568794:cleanup_file_variables
ERROR: Job failed: exit code 1
== Logs ==
For more details see: https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/1129314
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] tests/intel/xe_exec_compute_mode: Add userptr free / munmap sections
@ 2024-07-19 19:09 Matthew Brost
2024-07-23 8:00 ` Kumar, Janga Rahul
0 siblings, 1 reply; 6+ messages in thread
From: Matthew Brost @ 2024-07-19 19:09 UTC (permalink / raw)
To: igt-dev
Add userptr free / munmap sections which does the aforementioned while
the userptr still has a mapping. The userptr will be invalidated
triggering a rebind which will faill pinning pages as the userptr is no
longer valid. This is allowed and should not corrupt the VM or future
submissions.
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
tests/intel/xe_exec_compute_mode.c | 43 +++++++++++++++++++++++++-----
1 file changed, 37 insertions(+), 6 deletions(-)
diff --git a/tests/intel/xe_exec_compute_mode.c b/tests/intel/xe_exec_compute_mode.c
index 389de7ca40..704d975178 100644
--- a/tests/intel/xe_exec_compute_mode.c
+++ b/tests/intel/xe_exec_compute_mode.c
@@ -29,9 +29,11 @@
#define REBIND (0x1 << 1)
#define INVALIDATE (0x1 << 2)
#define RACE (0x1 << 3)
-#define BIND_EXECQUEUE (0x1 << 4)
+#define BIND_EXECQUEUE (0x1 << 4)
#define VM_FOR_BO (0x1 << 5)
-#define EXEC_QUEUE_EARLY (0x1 << 6)
+#define EXEC_QUEUE_EARLY (0x1 << 6)
+#define FREE_MAPPPING (0x1 << 7)
+#define UNMAP_MAPPPING (0x1 << 8)
/**
* SUBTEST: twice-%s
@@ -51,6 +53,8 @@
* @basic: basic
* @preempt-fence-early: preempt fence early
* @userptr: userptr
+ * @userptr-free: userptr free
+ * @userptr-unmap: userptr unmap
* @rebind: rebind
* @userptr-rebind: userptr rebind
* @userptr-invalidate: userptr invalidate
@@ -74,6 +78,8 @@
* @basic: basic
* @preempt-fence-early: preempt fence early
* @userptr: userptr
+ * @userptr-free: userptr free
+ * @userptr-unmap: userptr unmap
* @rebind: rebind
* @userptr-rebind: userptr rebind
* @userptr-invalidate: userptr invalidate
@@ -88,7 +94,7 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
int n_exec_queues, int n_execs, unsigned int flags)
{
uint32_t vm;
- uint64_t addr = 0x1a0000;
+ uint64_t addr = 0x1a0000, dummy_addr = 0x10001a0000;
#define USER_FENCE_VALUE 0xdeadbeefdeadbeefull
struct drm_xe_sync sync[1] = {
{ .type = DRM_XE_SYNC_TYPE_USER_FENCE,
@@ -114,6 +120,7 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
int i, j, b;
int map_fd = -1;
int64_t fence_timeout;
+ void *dummy;
igt_assert(n_exec_queues <= MAX_N_EXECQUEUES);
@@ -142,6 +149,17 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
bo_size);
igt_assert(data);
}
+ if (flags & UNMAP_MAPPPING) {
+ dummy = mmap((void *)MAP_ADDRESS, bo_size, PROT_READ |
+ PROT_WRITE, MAP_SHARED | MAP_FIXED |
+ MAP_ANONYMOUS, -1, 0);
+ igt_assert(data != MAP_FAILED);
+ }
+ if (flags & FREE_MAPPPING) {
+ dummy = aligned_alloc(xe_get_default_alignment(fd),
+ bo_size);
+ igt_assert(dummy);
+ }
} else {
bo = xe_bo_create(fd, flags & VM_FOR_BO ? vm : 0,
bo_size, vram_if_possible(fd, eci->gt_id),
@@ -157,16 +175,21 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
xe_bind_exec_queue_create(fd, vm, 0);
else
bind_exec_queues[i] = 0;
- };
+ }
sync[0].addr = to_user_pointer(&data[0].vm_sync);
- if (bo)
+ if (bo) {
xe_vm_bind_async(fd, vm, bind_exec_queues[0], bo, 0, addr,
bo_size, sync, 1);
- else
+ } else {
+ if (flags & (FREE_MAPPPING | UNMAP_MAPPPING))
+ xe_vm_bind_userptr_async(fd, vm, bind_exec_queues[0],
+ to_user_pointer(dummy),
+ dummy_addr, bo_size, 0, 0);
xe_vm_bind_userptr_async(fd, vm, bind_exec_queues[0],
to_user_pointer(data), addr,
bo_size, sync, 1);
+ }
#define ONE_SEC MS_TO_NS(1000)
#define HUNDRED_SEC MS_TO_NS(100000)
@@ -197,6 +220,12 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
exec.address = batch_addr;
xe_exec(fd, &exec);
+ if (flags & FREE_MAPPPING && !i)
+ free(dummy);
+
+ if (flags & UNMAP_MAPPPING && !i)
+ munmap(dummy, bo_size);
+
if (flags & REBIND && i + 1 != n_execs) {
xe_wait_ufence(fd, &data[i].exec_sync, USER_FENCE_VALUE,
exec_queues[e], fence_timeout);
@@ -489,6 +518,8 @@ igt_main
{ "basic", 0 },
{ "preempt-fence-early", VM_FOR_BO | EXEC_QUEUE_EARLY },
{ "userptr", USERPTR },
+ { "userptr-free", USERPTR | FREE_MAPPPING },
+ { "userptr-unmap", USERPTR | UNMAP_MAPPPING },
{ "rebind", REBIND },
{ "userptr-rebind", USERPTR | REBIND },
{ "userptr-invalidate", USERPTR | INVALIDATE },
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [PATCH] tests/intel/xe_exec_compute_mode: Add userptr free / munmap sections
2024-07-19 19:09 [PATCH] " Matthew Brost
@ 2024-07-23 8:00 ` Kumar, Janga Rahul
2024-07-23 20:40 ` Matthew Brost
0 siblings, 1 reply; 6+ messages in thread
From: Kumar, Janga Rahul @ 2024-07-23 8:00 UTC (permalink / raw)
To: Brost, Matthew, igt-dev@lists.freedesktop.org; +Cc: Gandi, Ramadevi
> -----Original Message-----
> From: igt-dev <igt-dev-bounces@lists.freedesktop.org> On Behalf Of Matthew
> Brost
> Sent: Saturday, July 20, 2024 12:39 AM
> To: igt-dev@lists.freedesktop.org
> Subject: [PATCH] tests/intel/xe_exec_compute_mode: Add userptr free /
> munmap sections
>
> Add userptr free / munmap sections which does the aforementioned while the
> userptr still has a mapping. The userptr will be invalidated triggering a rebind
Which will trigger the userptr invalidation in this test.free and munmap ?
or do we have to refer this addr in batch buffer so that the addr will be invalidated
during exec buff submission.
> which will faill pinning pages as the userptr is no longer valid. This is allowed and
^fail
> should not corrupt the VM or future submissions.
>
> Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> ---
> tests/intel/xe_exec_compute_mode.c | 43 +++++++++++++++++++++++++-----
> 1 file changed, 37 insertions(+), 6 deletions(-)
>
> diff --git a/tests/intel/xe_exec_compute_mode.c
> b/tests/intel/xe_exec_compute_mode.c
> index 389de7ca40..704d975178 100644
> --- a/tests/intel/xe_exec_compute_mode.c
> +++ b/tests/intel/xe_exec_compute_mode.c
> @@ -29,9 +29,11 @@
> #define REBIND (0x1 << 1)
> #define INVALIDATE (0x1 << 2)
> #define RACE (0x1 << 3)
> -#define BIND_EXECQUEUE (0x1 << 4)
> +#define BIND_EXECQUEUE (0x1 << 4)
> #define VM_FOR_BO (0x1 << 5)
> -#define EXEC_QUEUE_EARLY (0x1 << 6)
> +#define EXEC_QUEUE_EARLY (0x1 << 6)
> +#define FREE_MAPPPING (0x1 << 7)
> +#define UNMAP_MAPPPING (0x1 << 8)
>
> /**
> * SUBTEST: twice-%s
> @@ -51,6 +53,8 @@
> * @basic: basic
> * @preempt-fence-early: preempt fence early
> * @userptr: userptr
> + * @userptr-free: userptr free
> + * @userptr-unmap: userptr unmap
> * @rebind: rebind
> * @userptr-rebind: userptr rebind
> * @userptr-invalidate: userptr invalidate
> @@ -74,6 +78,8 @@
> * @basic: basic
> * @preempt-fence-early: preempt fence early
> * @userptr: userptr
> + * @userptr-free: userptr free
> + * @userptr-unmap: userptr unmap
> * @rebind: rebind
> * @userptr-rebind: userptr rebind
> * @userptr-invalidate: userptr invalidate
> @@ -88,7 +94,7 @@ test_exec(int fd, struct drm_xe_engine_class_instance
> *eci,
> int n_exec_queues, int n_execs, unsigned int flags) {
> uint32_t vm;
> - uint64_t addr = 0x1a0000;
> + uint64_t addr = 0x1a0000, dummy_addr = 0x10001a0000;
> #define USER_FENCE_VALUE 0xdeadbeefdeadbeefull
> struct drm_xe_sync sync[1] = {
> { .type = DRM_XE_SYNC_TYPE_USER_FENCE, @@ -114,6
> +120,7 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
> int i, j, b;
> int map_fd = -1;
> int64_t fence_timeout;
> + void *dummy;
>
> igt_assert(n_exec_queues <= MAX_N_EXECQUEUES);
>
> @@ -142,6 +149,17 @@ test_exec(int fd, struct drm_xe_engine_class_instance
> *eci,
> bo_size);
> igt_assert(data);
> }
> + if (flags & UNMAP_MAPPPING) {
> + dummy = mmap((void *)MAP_ADDRESS, bo_size,
> PROT_READ |
> + PROT_WRITE, MAP_SHARED | MAP_FIXED |
> + MAP_ANONYMOUS, -1, 0);
> + igt_assert(data != MAP_FAILED);
Check dummy here. ->igt_assert(dummy != MAP_FAILED);
Thanks,
Rahul
> + }
> + if (flags & FREE_MAPPPING) {
> + dummy = aligned_alloc(xe_get_default_alignment(fd),
> + bo_size);
> + igt_assert(dummy);
> + }
> } else {
> bo = xe_bo_create(fd, flags & VM_FOR_BO ? vm : 0,
> bo_size, vram_if_possible(fd, eci->gt_id), @@
> -157,16 +175,21 @@ test_exec(int fd, struct drm_xe_engine_class_instance
> *eci,
> xe_bind_exec_queue_create(fd, vm, 0);
> else
> bind_exec_queues[i] = 0;
> - };
> + }
>
> sync[0].addr = to_user_pointer(&data[0].vm_sync);
> - if (bo)
> + if (bo) {
> xe_vm_bind_async(fd, vm, bind_exec_queues[0], bo, 0, addr,
> bo_size, sync, 1);
> - else
> + } else {
> + if (flags & (FREE_MAPPPING | UNMAP_MAPPPING))
> + xe_vm_bind_userptr_async(fd, vm,
> bind_exec_queues[0],
> + to_user_pointer(dummy),
> + dummy_addr, bo_size, 0, 0);
> xe_vm_bind_userptr_async(fd, vm, bind_exec_queues[0],
> to_user_pointer(data), addr,
> bo_size, sync, 1);
> + }
> #define ONE_SEC MS_TO_NS(1000)
> #define HUNDRED_SEC MS_TO_NS(100000)
>
> @@ -197,6 +220,12 @@ test_exec(int fd, struct drm_xe_engine_class_instance
> *eci,
> exec.address = batch_addr;
> xe_exec(fd, &exec);
>
> + if (flags & FREE_MAPPPING && !i)
> + free(dummy);
> +
> + if (flags & UNMAP_MAPPPING && !i)
> + munmap(dummy, bo_size);
> +
> if (flags & REBIND && i + 1 != n_execs) {
> xe_wait_ufence(fd, &data[i].exec_sync,
> USER_FENCE_VALUE,
> exec_queues[e], fence_timeout); @@ -
> 489,6 +518,8 @@ igt_main
> { "basic", 0 },
> { "preempt-fence-early", VM_FOR_BO | EXEC_QUEUE_EARLY },
> { "userptr", USERPTR },
> + { "userptr-free", USERPTR | FREE_MAPPPING },
> + { "userptr-unmap", USERPTR | UNMAP_MAPPPING },
> { "rebind", REBIND },
> { "userptr-rebind", USERPTR | REBIND },
> { "userptr-invalidate", USERPTR | INVALIDATE },
> --
> 2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tests/intel/xe_exec_compute_mode: Add userptr free / munmap sections
2024-07-23 8:00 ` Kumar, Janga Rahul
@ 2024-07-23 20:40 ` Matthew Brost
0 siblings, 0 replies; 6+ messages in thread
From: Matthew Brost @ 2024-07-23 20:40 UTC (permalink / raw)
To: Kumar, Janga Rahul; +Cc: igt-dev@lists.freedesktop.org, Gandi, Ramadevi
On Tue, Jul 23, 2024 at 02:00:40AM -0600, Kumar, Janga Rahul wrote:
>
>
> > -----Original Message-----
> > From: igt-dev <igt-dev-bounces@lists.freedesktop.org> On Behalf Of Matthew
> > Brost
> > Sent: Saturday, July 20, 2024 12:39 AM
> > To: igt-dev@lists.freedesktop.org
> > Subject: [PATCH] tests/intel/xe_exec_compute_mode: Add userptr free /
> > munmap sections
> >
> > Add userptr free / munmap sections which does the aforementioned while the
> > userptr still has a mapping. The userptr will be invalidated triggering a rebind
> Which will trigger the userptr invalidation in this test.free and munmap ?
> or do we have to refer this addr in batch buffer so that the addr will be invalidated
> during exec buff submission.
>
Before this patch [1] if we failed to pin a userptr in exec IOCTL or
preempt rebind worker we errord out. Apartently UMDs call free or unmap
on a userptr before unbinding. This verifies this doesn't cause
problems if free or unmap occurs.
[1] https://patchwork.freedesktop.org/patch/582642/?series=130935&rev=4
> > which will faill pinning pages as the userptr is no longer valid. This is allowed and
> ^fail
>
> > should not corrupt the VM or future submissions.
> >
> > Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> > ---
> > tests/intel/xe_exec_compute_mode.c | 43 +++++++++++++++++++++++++-----
> > 1 file changed, 37 insertions(+), 6 deletions(-)
> >
> > diff --git a/tests/intel/xe_exec_compute_mode.c
> > b/tests/intel/xe_exec_compute_mode.c
> > index 389de7ca40..704d975178 100644
> > --- a/tests/intel/xe_exec_compute_mode.c
> > +++ b/tests/intel/xe_exec_compute_mode.c
> > @@ -29,9 +29,11 @@
> > #define REBIND (0x1 << 1)
> > #define INVALIDATE (0x1 << 2)
> > #define RACE (0x1 << 3)
> > -#define BIND_EXECQUEUE (0x1 << 4)
> > +#define BIND_EXECQUEUE (0x1 << 4)
> > #define VM_FOR_BO (0x1 << 5)
> > -#define EXEC_QUEUE_EARLY (0x1 << 6)
> > +#define EXEC_QUEUE_EARLY (0x1 << 6)
> > +#define FREE_MAPPPING (0x1 << 7)
> > +#define UNMAP_MAPPPING (0x1 << 8)
> >
> > /**
> > * SUBTEST: twice-%s
> > @@ -51,6 +53,8 @@
> > * @basic: basic
> > * @preempt-fence-early: preempt fence early
> > * @userptr: userptr
> > + * @userptr-free: userptr free
> > + * @userptr-unmap: userptr unmap
> > * @rebind: rebind
> > * @userptr-rebind: userptr rebind
> > * @userptr-invalidate: userptr invalidate
> > @@ -74,6 +78,8 @@
> > * @basic: basic
> > * @preempt-fence-early: preempt fence early
> > * @userptr: userptr
> > + * @userptr-free: userptr free
> > + * @userptr-unmap: userptr unmap
> > * @rebind: rebind
> > * @userptr-rebind: userptr rebind
> > * @userptr-invalidate: userptr invalidate
> > @@ -88,7 +94,7 @@ test_exec(int fd, struct drm_xe_engine_class_instance
> > *eci,
> > int n_exec_queues, int n_execs, unsigned int flags) {
> > uint32_t vm;
> > - uint64_t addr = 0x1a0000;
> > + uint64_t addr = 0x1a0000, dummy_addr = 0x10001a0000;
> > #define USER_FENCE_VALUE 0xdeadbeefdeadbeefull
> > struct drm_xe_sync sync[1] = {
> > { .type = DRM_XE_SYNC_TYPE_USER_FENCE, @@ -114,6
> > +120,7 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
> > int i, j, b;
> > int map_fd = -1;
> > int64_t fence_timeout;
> > + void *dummy;
> >
> > igt_assert(n_exec_queues <= MAX_N_EXECQUEUES);
> >
> > @@ -142,6 +149,17 @@ test_exec(int fd, struct drm_xe_engine_class_instance
> > *eci,
> > bo_size);
> > igt_assert(data);
> > }
> > + if (flags & UNMAP_MAPPPING) {
> > + dummy = mmap((void *)MAP_ADDRESS, bo_size,
> > PROT_READ |
> > + PROT_WRITE, MAP_SHARED | MAP_FIXED |
> > + MAP_ANONYMOUS, -1, 0);
> > + igt_assert(data != MAP_FAILED);
> Check dummy here. ->igt_assert(dummy != MAP_FAILED);
>
Yes, will fix.
Matt
> Thanks,
> Rahul
>
> > + }
> > + if (flags & FREE_MAPPPING) {
> > + dummy = aligned_alloc(xe_get_default_alignment(fd),
> > + bo_size);
> > + igt_assert(dummy);
> > + }
> > } else {
> > bo = xe_bo_create(fd, flags & VM_FOR_BO ? vm : 0,
> > bo_size, vram_if_possible(fd, eci->gt_id), @@
> > -157,16 +175,21 @@ test_exec(int fd, struct drm_xe_engine_class_instance
> > *eci,
> > xe_bind_exec_queue_create(fd, vm, 0);
> > else
> > bind_exec_queues[i] = 0;
> > - };
> > + }
> >
> > sync[0].addr = to_user_pointer(&data[0].vm_sync);
> > - if (bo)
> > + if (bo) {
> > xe_vm_bind_async(fd, vm, bind_exec_queues[0], bo, 0, addr,
> > bo_size, sync, 1);
> > - else
> > + } else {
> > + if (flags & (FREE_MAPPPING | UNMAP_MAPPPING))
> > + xe_vm_bind_userptr_async(fd, vm,
> > bind_exec_queues[0],
> > + to_user_pointer(dummy),
> > + dummy_addr, bo_size, 0, 0);
> > xe_vm_bind_userptr_async(fd, vm, bind_exec_queues[0],
> > to_user_pointer(data), addr,
> > bo_size, sync, 1);
> > + }
> > #define ONE_SEC MS_TO_NS(1000)
> > #define HUNDRED_SEC MS_TO_NS(100000)
> >
> > @@ -197,6 +220,12 @@ test_exec(int fd, struct drm_xe_engine_class_instance
> > *eci,
> > exec.address = batch_addr;
> > xe_exec(fd, &exec);
> >
> > + if (flags & FREE_MAPPPING && !i)
> > + free(dummy);
> > +
> > + if (flags & UNMAP_MAPPPING && !i)
> > + munmap(dummy, bo_size);
> > +
> > if (flags & REBIND && i + 1 != n_execs) {
> > xe_wait_ufence(fd, &data[i].exec_sync,
> > USER_FENCE_VALUE,
> > exec_queues[e], fence_timeout); @@ -
> > 489,6 +518,8 @@ igt_main
> > { "basic", 0 },
> > { "preempt-fence-early", VM_FOR_BO | EXEC_QUEUE_EARLY },
> > { "userptr", USERPTR },
> > + { "userptr-free", USERPTR | FREE_MAPPPING },
> > + { "userptr-unmap", USERPTR | UNMAP_MAPPPING },
> > { "rebind", REBIND },
> > { "userptr-rebind", USERPTR | REBIND },
> > { "userptr-invalidate", USERPTR | INVALIDATE },
> > --
> > 2.34.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-07-23 20:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-16 5:45 [PATCH] tests/intel/xe_exec_compute_mode: Add userptr free / munmap sections Matthew Brost
2024-03-16 5:58 ` ✗ Fi.CI.BUILD: failure for " Patchwork
2024-03-16 6:03 ` ✗ GitLab.Pipeline: warning " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2024-07-19 19:09 [PATCH] " Matthew Brost
2024-07-23 8:00 ` Kumar, Janga Rahul
2024-07-23 20:40 ` Matthew Brost
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox