* [igt-dev] [PATCH i-g-t v4] tests/i915/gem_ppgtt: verify GTT eviction with contended locks @ 2023-01-04 10:36 Matthew Auld 2023-01-04 11:39 ` [igt-dev] ✗ Fi.CI.BAT: failure for tests/i915/gem_ppgtt: verify GTT eviction with contended locks (rev4) Patchwork 0 siblings, 1 reply; 2+ messages in thread From: Matthew Auld @ 2023-01-04 10:36 UTC (permalink / raw) To: igt-dev; +Cc: intel-gfx, Mani Milani, Nirmoy Das We should still be able to GTT evict objects during execbuf (old bindings can linger around), even if there is object lock contention. In the worst case the execbuf should just wait on the contented locks. Returning -ENOSPC smells like a regression from past behaviour, and seems to break userspace. v2: - Add coverage for explicit softpin - Add timeout for the spinner v3: - Improve the test description v4: (Nirmoy) - We only need one handle2 - Prefer NSEC_PER_SEC References: https://gitlab.freedesktop.org/drm/intel/-/issues/7570 Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Andrzej Hajda <andrzej.hajda@intel.com> Cc: Nirmoy Das <nirmoy.das@intel.com> Cc: Mani Milani <mani@chromium.org> Reviewed-by: Nirmoy Das <nirmoy.das@intel.com> --- tests/i915/gem_ppgtt.c | 133 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) diff --git a/tests/i915/gem_ppgtt.c b/tests/i915/gem_ppgtt.c index 9673ce22..ca09f089 100644 --- a/tests/i915/gem_ppgtt.c +++ b/tests/i915/gem_ppgtt.c @@ -255,6 +255,131 @@ static void flink_and_close(void) close(fd2); } +#define PAGE_SIZE 4096 + +static uint32_t batch_create_size(int fd, uint64_t size) +{ + const uint32_t bbe = MI_BATCH_BUFFER_END; + uint32_t handle; + + handle = gem_create(fd, size); + gem_write(fd, handle, 0, &bbe, sizeof(bbe)); + + return handle; +} + +#define IGT_USE_ANY 0x1 +#define IGT_USE_PINNED 0x2 +static void upload(int fd, uint32_t handle, uint32_t in_fence, uint32_t ctx_id, + unsigned int flags) +{ + struct drm_i915_gem_exec_object2 exec[2] = {}; + struct drm_i915_gem_execbuffer2 execbuf = { + .buffers_ptr = to_user_pointer(&exec), + .buffer_count = 1, + .rsvd1 = ctx_id, + }; + + if (in_fence) { + execbuf.rsvd2 = in_fence; + execbuf.flags = I915_EXEC_FENCE_IN; + } + + exec[0].handle = handle; + exec[0].flags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS; + + if (flags & IGT_USE_PINNED) + exec[0].flags |= EXEC_OBJECT_PINNED; /* offset = 0 */ + + if (flags & IGT_USE_ANY) { + exec[0].flags |= EXEC_OBJECT_PAD_TO_SIZE; + exec[0].pad_to_size = gem_aperture_size(fd); + } + + gem_execbuf(fd, &execbuf); +} + +static void shrink_vs_evict(unsigned int flags) +{ + const unsigned int nproc = sysconf(_SC_NPROCESSORS_ONLN) + 1; + const uint64_t timeout_5s = 5LL * NSEC_PER_SEC; + int fd = drm_open_driver(DRIVER_INTEL); + uint64_t ahnd = get_reloc_ahnd(fd, 0); + const intel_ctx_t *ctx_arr[nproc]; + igt_spin_t *spinner; + uint32_t handle1; + int i; + + /* + * Try to simulate some nasty object lock contention during GTT + * eviction. Create a BO and bind across several different VMs. Invoke + * the shrinker on that shared BO, followed by triggering GTT eviction + * across all VMs. Both require the object lock to make forward + * progress when trying to unbind the BO, but the shrinker will be + * blocked by the spinner (until killed). Once the spinner is killed + * the shrinker should be able to unbind the object and drop the object + * lock, and GTT eviction should eventually succeed. At no point should + * we see -ENOSPC from the execbuf, even if we can't currently grab the + * object lock. + */ + + igt_require(gem_uses_full_ppgtt(fd)); + + igt_drop_caches_set(fd, DROP_ALL); + + handle1 = gem_create(fd, PAGE_SIZE); + + spinner = igt_spin_new(fd, + .ahnd = ahnd, + .flags = IGT_SPIN_FENCE_OUT); + igt_spin_set_timeout(spinner, timeout_5s); + + /* + * Create several VMs to ensure we don't block on the same vm lock. The + * goal of the test is to ensure that object lock contention doesn't + * somehow result in -ENOSPC from execbuf, if we need to trigger GTT + * eviction. + */ + for (i = 0; i < nproc; i++) { + ctx_arr[i] = intel_ctx_create(fd, NULL); + + upload(fd, handle1, spinner->execbuf.rsvd2 >> 32, + ctx_arr[i]->id, flags); + } + + igt_fork(child, 1) + igt_drop_caches_set(fd, DROP_ALL); + + sleep(2); /* Give the shrinker time to find handle1 */ + + igt_fork(child, nproc) { + uint32_t handle2; + + /* + * One of these forks will be stuck on the vm mutex, since the + * shrinker is holding it (along with the object lock) while + * trying to unbind the chosen vma, but is blocked by the + * spinner. The rest should only block waiting to grab the + * object lock for handle1, before then trying to GTT evict it + * from their respective vm. In either case the contention of + * the vm->mutex or object lock should never result in -ENOSPC + * or some other error. + */ + handle2 = batch_create_size(fd, PAGE_SIZE); + + upload(fd, handle2, 0, ctx_arr[child]->id, flags); + gem_close(fd, handle2); + } + + igt_waitchildren(); + igt_spin_free(fd, spinner); + + for (i = 0; i < nproc; i++) + intel_ctx_destroy(fd, ctx_arr[i]); + + gem_close(fd, handle1); +} + static bool has_contexts(void) { bool result; @@ -331,4 +456,12 @@ igt_main igt_subtest("flink-and-close-vma-leak") flink_and_close(); + + igt_describe("Regression test to verify GTT eviction can't randomly fail due to object lock contention"); + igt_subtest_group { + igt_subtest("shrink-vs-evict-any") + shrink_vs_evict(IGT_USE_ANY); + igt_subtest("shrink-vs-evict-pinned") + shrink_vs_evict(IGT_USE_PINNED); + } } -- 2.39.0 ^ permalink raw reply related [flat|nested] 2+ messages in thread
* [igt-dev] ✗ Fi.CI.BAT: failure for tests/i915/gem_ppgtt: verify GTT eviction with contended locks (rev4) 2023-01-04 10:36 [igt-dev] [PATCH i-g-t v4] tests/i915/gem_ppgtt: verify GTT eviction with contended locks Matthew Auld @ 2023-01-04 11:39 ` Patchwork 0 siblings, 0 replies; 2+ messages in thread From: Patchwork @ 2023-01-04 11:39 UTC (permalink / raw) To: Matthew Auld; +Cc: igt-dev [-- Attachment #1: Type: text/plain, Size: 10764 bytes --] == Series Details == Series: tests/i915/gem_ppgtt: verify GTT eviction with contended locks (rev4) URL : https://patchwork.freedesktop.org/series/111267/ State : failure == Summary == CI Bug Log - changes from CI_DRM_12541 -> IGTPW_8296 ==================================================== Summary ------- **FAILURE** Serious unknown changes coming with IGTPW_8296 absolutely need to be verified manually. If you think the reported changes have nothing to do with the changes introduced in IGTPW_8296, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI. External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/index.html Participating hosts (42 -> 43) ------------------------------ Additional (2): fi-kbl-soraka fi-rkl-11600 Missing (1): bat-dg2-oem1 Possible new issues ------------------- Here are the unknown changes that may have been introduced in IGTPW_8296: ### IGT changes ### #### Possible regressions #### * igt@debugfs_test@read_all_entries: - fi-icl-u2: [PASS][1] -> [ABORT][2] [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12541/fi-icl-u2/igt@debugfs_test@read_all_entries.html [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-icl-u2/igt@debugfs_test@read_all_entries.html #### Suppressed #### The following results come from untrusted machines, tests, or statuses. They do not affect the overall result. * igt@i915_selftest@live@workarounds: - {bat-rpls-2}: [PASS][3] -> [DMESG-FAIL][4] [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12541/bat-rpls-2/igt@i915_selftest@live@workarounds.html [4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/bat-rpls-2/igt@i915_selftest@live@workarounds.html Known issues ------------ Here are the changes found in IGTPW_8296 that come from known issues: ### IGT changes ### #### Issues hit #### * igt@debugfs_test@basic-hwmon: - fi-rkl-11600: NOTRUN -> [SKIP][5] ([i915#7456]) [5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-rkl-11600/igt@debugfs_test@basic-hwmon.html * igt@gem_exec_gttfill@basic: - fi-kbl-soraka: NOTRUN -> [SKIP][6] ([fdo#109271]) +7 similar issues [6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-kbl-soraka/igt@gem_exec_gttfill@basic.html - fi-pnv-d510: [PASS][7] -> [FAIL][8] ([i915#7229]) [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12541/fi-pnv-d510/igt@gem_exec_gttfill@basic.html [8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-pnv-d510/igt@gem_exec_gttfill@basic.html * igt@gem_huc_copy@huc-copy: - fi-kbl-soraka: NOTRUN -> [SKIP][9] ([fdo#109271] / [i915#2190]) [9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-kbl-soraka/igt@gem_huc_copy@huc-copy.html - fi-rkl-11600: NOTRUN -> [SKIP][10] ([i915#2190]) [10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-rkl-11600/igt@gem_huc_copy@huc-copy.html * igt@gem_lmem_swapping@basic: - fi-kbl-soraka: NOTRUN -> [SKIP][11] ([fdo#109271] / [i915#4613]) +3 similar issues [11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-kbl-soraka/igt@gem_lmem_swapping@basic.html - fi-rkl-11600: NOTRUN -> [SKIP][12] ([i915#4613]) +3 similar issues [12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-rkl-11600/igt@gem_lmem_swapping@basic.html * igt@gem_tiled_pread_basic: - fi-rkl-11600: NOTRUN -> [SKIP][13] ([i915#3282]) [13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-rkl-11600/igt@gem_tiled_pread_basic.html * igt@i915_pm_backlight@basic-brightness: - fi-rkl-11600: NOTRUN -> [SKIP][14] ([i915#7561]) [14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-rkl-11600/igt@i915_pm_backlight@basic-brightness.html * igt@i915_selftest@live@gt_pm: - fi-kbl-soraka: NOTRUN -> [DMESG-FAIL][15] ([i915#1886]) [15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-kbl-soraka/igt@i915_selftest@live@gt_pm.html * igt@i915_selftest@live@perf: - fi-kbl-soraka: NOTRUN -> [INCOMPLETE][16] ([i915#1886]) [16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-kbl-soraka/igt@i915_selftest@live@perf.html * igt@i915_suspend@basic-s3-without-i915: - fi-rkl-11600: NOTRUN -> [INCOMPLETE][17] ([i915#4817]) [17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-rkl-11600/igt@i915_suspend@basic-s3-without-i915.html * igt@kms_chamelium@common-hpd-after-suspend: - bat-dg1-6: NOTRUN -> [SKIP][18] ([fdo#111827]) [18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/bat-dg1-6/igt@kms_chamelium@common-hpd-after-suspend.html * igt@kms_chamelium@hdmi-edid-read: - fi-rkl-11600: NOTRUN -> [SKIP][19] ([fdo#111827]) +7 similar issues [19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-rkl-11600/igt@kms_chamelium@hdmi-edid-read.html * igt@kms_chamelium@hdmi-hpd-fast: - fi-kbl-soraka: NOTRUN -> [SKIP][20] ([fdo#109271] / [fdo#111827]) +7 similar issues [20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-kbl-soraka/igt@kms_chamelium@hdmi-hpd-fast.html * igt@kms_cursor_legacy@basic-busy-flip-before-cursor: - fi-rkl-11600: NOTRUN -> [SKIP][21] ([i915#4103]) [21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-rkl-11600/igt@kms_cursor_legacy@basic-busy-flip-before-cursor.html * igt@kms_force_connector_basic@force-load-detect: - fi-rkl-11600: NOTRUN -> [SKIP][22] ([fdo#109285] / [i915#4098]) [22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-rkl-11600/igt@kms_force_connector_basic@force-load-detect.html * igt@kms_psr@primary_page_flip: - fi-rkl-11600: NOTRUN -> [SKIP][23] ([i915#1072]) +3 similar issues [23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-rkl-11600/igt@kms_psr@primary_page_flip.html * igt@kms_setmode@basic-clone-single-crtc: - fi-rkl-11600: NOTRUN -> [SKIP][24] ([i915#3555] / [i915#4098]) [24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-rkl-11600/igt@kms_setmode@basic-clone-single-crtc.html * igt@prime_vgem@basic-read: - fi-rkl-11600: NOTRUN -> [SKIP][25] ([fdo#109295] / [i915#3291] / [i915#3708]) +2 similar issues [25]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-rkl-11600/igt@prime_vgem@basic-read.html * igt@prime_vgem@basic-userptr: - fi-rkl-11600: NOTRUN -> [SKIP][26] ([fdo#109295] / [i915#3301] / [i915#3708]) [26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-rkl-11600/igt@prime_vgem@basic-userptr.html * igt@runner@aborted: - fi-icl-u2: NOTRUN -> [FAIL][27] ([i915#4312]) [27]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/fi-icl-u2/igt@runner@aborted.html #### Possible fixes #### * igt@i915_selftest@live@hangcheck: - bat-dg1-6: [INCOMPLETE][28] -> [PASS][29] [28]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12541/bat-dg1-6/igt@i915_selftest@live@hangcheck.html [29]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/bat-dg1-6/igt@i915_selftest@live@hangcheck.html * igt@i915_selftest@live@migrate: - {bat-atsm-1}: [DMESG-FAIL][30] ([i915#7699]) -> [PASS][31] [30]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12541/bat-atsm-1/igt@i915_selftest@live@migrate.html [31]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/bat-atsm-1/igt@i915_selftest@live@migrate.html * igt@i915_selftest@live@slpc: - bat-adlp-4: [DMESG-FAIL][32] ([i915#6367]) -> [PASS][33] [32]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12541/bat-adlp-4/igt@i915_selftest@live@slpc.html [33]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/bat-adlp-4/igt@i915_selftest@live@slpc.html * igt@kms_pipe_crc_basic@suspend-read-crc@pipe-c-dp-1: - {bat-adlp-9}: [DMESG-WARN][34] ([i915#2867]) -> [PASS][35] [34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12541/bat-adlp-9/igt@kms_pipe_crc_basic@suspend-read-crc@pipe-c-dp-1.html [35]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/bat-adlp-9/igt@kms_pipe_crc_basic@suspend-read-crc@pipe-c-dp-1.html {name}: This element is suppressed. This means it is ignored when computing the status of the difference (SUCCESS, WARNING, or FAILURE). [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271 [fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285 [fdo#109295]: https://bugs.freedesktop.org/show_bug.cgi?id=109295 [fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827 [i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072 [i915#1886]: https://gitlab.freedesktop.org/drm/intel/issues/1886 [i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190 [i915#2867]: https://gitlab.freedesktop.org/drm/intel/issues/2867 [i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282 [i915#3291]: https://gitlab.freedesktop.org/drm/intel/issues/3291 [i915#3301]: https://gitlab.freedesktop.org/drm/intel/issues/3301 [i915#3546]: https://gitlab.freedesktop.org/drm/intel/issues/3546 [i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555 [i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708 [i915#4098]: https://gitlab.freedesktop.org/drm/intel/issues/4098 [i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103 [i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312 [i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613 [i915#4817]: https://gitlab.freedesktop.org/drm/intel/issues/4817 [i915#4983]: https://gitlab.freedesktop.org/drm/intel/issues/4983 [i915#6367]: https://gitlab.freedesktop.org/drm/intel/issues/6367 [i915#7077]: https://gitlab.freedesktop.org/drm/intel/issues/7077 [i915#7229]: https://gitlab.freedesktop.org/drm/intel/issues/7229 [i915#7456]: https://gitlab.freedesktop.org/drm/intel/issues/7456 [i915#7561]: https://gitlab.freedesktop.org/drm/intel/issues/7561 [i915#7699]: https://gitlab.freedesktop.org/drm/intel/issues/7699 Build changes ------------- * CI: CI-20190529 -> None * IGT: IGT_7106 -> IGTPW_8296 CI-20190529: 20190529 CI_DRM_12541: b832866fa6063614b3637598aca19aee3bc3039f @ git://anongit.freedesktop.org/gfx-ci/linux IGTPW_8296: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/index.html IGT_7106: 8cce332bdc50d2b20d553d7a0221737f4399d031 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git Testlist changes ---------------- +igt@gem_ppgtt@shrink-vs-evict-any +igt@gem_ppgtt@shrink-vs-evict-pinned == Logs == For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8296/index.html [-- Attachment #2: Type: text/html, Size: 12607 bytes --] ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-04 11:39 UTC | newest] Thread overview: 2+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-01-04 10:36 [igt-dev] [PATCH i-g-t v4] tests/i915/gem_ppgtt: verify GTT eviction with contended locks Matthew Auld 2023-01-04 11:39 ` [igt-dev] ✗ Fi.CI.BAT: failure for tests/i915/gem_ppgtt: verify GTT eviction with contended locks (rev4) Patchwork
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox