tests/gem_mmap_gtt: add test mmap_closed_bo
PATCH 1/1 tests/gem_mmap_gtt: add test mmap_closed_bo
From: Chuansheng Liu <[email protected]>
Recently we figured out one memory leak in i915 driver when running below alike test:
create_bogem_mmap_gtt bogem_mmap_gtt bo twiceclose_bo
then the memory leak is detected. More details can be referred in
https://patchwork.freedesktop.org/patch/475802/?series=100532&rev=2
For detecting such issue, this test case mmap_closed_bo is created, it will close the bo with keeping one mmap, then second mmap the bo, in normal situation, we expect second mmap failure with EACCESS. But it will succeed if driver has the vm_node allowance leak.
V2: (Tvrtko) some variable placement and comments tuning.
V3: (Tvrtko) Using igt_drop_caches_set(fd, DROP_FREED) directly.
v4: [tursulin] Fixed a conflict, added igt_describe.
--- tests/i915/gem_mmap_gtt.c | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
tests/i915/gem_mmap_gtt.c +49 -0
@@ -320,6 +320,52 @@ test_wc(int fd) 5*gtt_writes/256., 5*cpu_writes/256.); } +static void mmap_closed_bo (int fd) +{ +int loop =0 ; + +while (loop++ <2 ) { +struct drm_i915_gem_mmap_gtt mmap_arg; +void *p1, *p2; +int i = loop; + +memset (&mmap_arg,0 ,sizeof (mmap_arg)); + mmap_arg.handle =gem_create (fd,OBJECT_SIZE ); +igt_assert (mmap_arg.handle); + +while (i--) { +/* +* Get mmap offset by calling GEM_MMAP_GTT one or multiple times in +* order to try to provoke a memory leak in the driver. +*/ +do_ioctl (fd,DRM_IOCTL_I915_GEM_MMAP_GTT , &mmap_arg); + } + + p1 =mmap64 (0 ,OBJECT_SIZE ,PROT_READ |PROT_WRITE , +MAP_SHARED , fd, mmap_arg.offset); +igt_assert (p1 !=MAP_FAILED ); + +gem_close (fd, mmap_arg.handle); + +/* +* Drop the freed objects for consistent 2nd mmap result. +*/ +igt_drop_caches_set (fd,DROP_FREED ); + + p2 =mmap64 (0 ,OBJECT_SIZE ,PROT_READ |PROT_WRITE , +MAP_SHARED , fd, mmap_arg.offset); + +munmap (p1,OBJECT_SIZE ); + +/* +* we expect mmapping p2 would fail, otherwise the driver +* may not clean up the allowance of vm_node, it would +* cause memory leak. +*/ +igt_assert (p2 ==MAP_FAILED ); + } +} +static int mmap_gtt_version (int i915) {int val =0 ;
@@ -1315,6 +1361,9 @@ igt_main "writes into it from another GTT mmapped."); igt_subtest("basic-write-gtt")test_write_gtt (fd); +igt_describe ("Check mmap of a closed handle is rejected." ); + igt_subtest("mmap-closed-bo") +mmap_closed_bo (fd);igt_describe ("Inspect a GTT mmap using ptrace()." ); igt_subtest("ptrace")test_ptrace (fd);
Signature · 1 line
2.34.1
Patchwork
CI[igt-dev] ✗ Fi.CI.BAT: failure for tests/gem_mmap_gtt: add test mmap_closed_bo (rev4)
== Series Details ==
== Series Details ==
Series: tests/gem_mmap_gtt: add test mmap_closed_bo (rev4)
URL : https://patchwork.freedesktop.org/series/101035/
State : failure
== Summary ==
CI Bug Log - changes from IGT_7102 -> IGTPW_8263
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with IGTPW_8263 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in IGTPW_8263, 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_8263/index.html
Participating hosts (44 -> 46)
------------------------------
Additional (2): bat-atsm-1 fi-ilk-650
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in IGTPW_8263:
### IGT changes ###
#### Possible regressions ####
* igt@i915_selftest@live@execlists:
- fi-bsw-nick: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7102/fi-bsw-nick/igt@i915_selftest@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8263/fi-bsw-nick/igt@i915_selftest@[email protected]
Known issues
------------
Here are the changes found in IGTPW_8263 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_exec_gttfill@basic:
- fi-pnv-d510: [PASS][3] -> [FAIL][4] ([i915#7229])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7102/fi-pnv-d510/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8263/fi-pnv-d510/igt@[email protected]
* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-ilk-650: NOTRUN -> [SKIP][5] ([fdo#109271]) +20 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8263/fi-ilk-650/igt@[email protected]
* igt@i915_selftest@live@execlists:
- fi-kbl-soraka: [PASS][6] -> [INCOMPLETE][7] ([i915#7156])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7102/fi-kbl-soraka/igt@i915_selftest@[email protected]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8263/fi-kbl-soraka/igt@i915_selftest@[email protected]
* igt@i915_selftest@live@gt_heartbeat:
- fi-kbl-soraka: [PASS][8] -> [DMESG-FAIL][9] ([i915#5334])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7102/fi-kbl-soraka/igt@i915_selftest@live@gt_heartbeat.html
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8263/fi-kbl-soraka/igt@i915_selftest@live@gt_heartbeat.html
* igt@i915_suspend@basic-s3-without-i915:
- fi-rkl-11600: [PASS][10] -> [INCOMPLETE][11] ([i915#4817])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7102/fi-rkl-11600/igt@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8263/fi-rkl-11600/igt@[email protected]
* igt@kms_chamelium@dp-hpd-fast:
- fi-ilk-650: NOTRUN -> [SKIP][12] ([fdo#109271] / [fdo#111827]) +8 similar issues
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8263/fi-ilk-650/igt@[email protected]
* igt@runner@aborted:
- fi-bsw-nick: NOTRUN -> [FAIL][13] ([fdo#109271] / [i915#4312])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8263/fi-bsw-nick/igt@[email protected]
#### Possible fixes ####
* igt@i915_selftest@live@mman:
- fi-rkl-guc: [TIMEOUT][14] ([i915#6794]) -> [PASS][15]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7102/fi-rkl-guc/igt@i915_selftest@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8263/fi-rkl-guc/igt@i915_selftest@[email protected]
{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#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#1836]: https://gitlab.freedesktop.org/drm/intel/issues/1836
[i915#2582]: https://gitlab.freedesktop.org/drm/intel/issues/2582
[i915#3546]: https://gitlab.freedesktop.org/drm/intel/issues/3546
[i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
[i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#4817]: https://gitlab.freedesktop.org/drm/intel/issues/4817
[i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
[i915#6077]: https://gitlab.freedesktop.org/drm/intel/issues/6077
[i915#6078]: https://gitlab.freedesktop.org/drm/intel/issues/6078
[i915#6093]: https://gitlab.freedesktop.org/drm/intel/issues/6093
[i915#6094]: https://gitlab.freedesktop.org/drm/intel/issues/6094
[i915#6166]: https://gitlab.freedesktop.org/drm/intel/issues/6166
[i915#6311]: https://gitlab.freedesktop.org/drm/intel/issues/6311
[i915#6367]: https://gitlab.freedesktop.org/drm/intel/issues/6367
[i915#6621]: https://gitlab.freedesktop.org/drm/intel/issues/6621
[i915#6645]: https://gitlab.freedesktop.org/drm/intel/issues/6645
[i915#6794]: https://gitlab.freedesktop.org/drm/intel/issues/6794
[i915#7156]: https://gitlab.freedesktop.org/drm/intel/issues/7156
[i915#7229]: https://gitlab.freedesktop.org/drm/intel/issues/7229
[i915#7357]: https://gitlab.freedesktop.org/drm/intel/issues/7357
Build changes
-------------
* CI: CI-20190529 -> None
* IGT: IGT_7102 -> IGTPW_8263
CI-20190529: 20190529
CI_DRM_12521: 584eb294ab7b1273c5ef505a33f2a5d89c877fcd @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_8263: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8263/index.html
IGT_7102: bacfdc84a9c02556c5441deb21e3a3f18a07347d @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Testlist changes
----------------
+igt@gem_mmap_gtt@mmap-closed-bo
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8263/index.html
Quoted 18 lines · Tvrtko Ursulin
From: Chuansheng Liu <[email protected]>
Recently we figured out one memory leak in i915 driver when running below alike test:
create_bogem_mmap_gttbogem_mmap_gttbo twiceclose_bothen the memory leak is detected. More details can be referred in
https://patchwork.freedesktop.org/patch/475802/?series=100532&rev=2For detecting such issue, this test case
mmap_closed_bois created, it will close the bo with keeping one mmap, then second mmap the bo, in normal situation, we expect second mmap failure with EACCESS. But it will succeed if driver has thevm_nodeallowance leak.
Quoted 8 lines
V2: (Tvrtko) some variable placement and comments tuning.
V3: (Tvrtko) Usingigt_drop_caches_set(fd, DROP_FREED)directly.
v4: [tursulin] Fixed a conflict, addedigt_describe.Cc Tvrtko Ursulin <[email protected]>Signed-off-by Chuansheng Liu <[email protected]>Reviewed-by Tvrtko Ursulin <[email protected]>Signed-off-by Tvrtko Ursulin <[email protected]>
Quoted 71 lines
--- tests/i915/gem_mmap_gtt.c | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)tests/i915/gem_mmap_gtt.c +49
-0@@ -320,6 +320,52 @@ test_wc(int fd) 5*gtt_writes/256., 5*cpu_writes/256.); } +static void mmap_closed_bo (int fd) +{ +int loop =0 ; + +while (loop++ <2 ) { +struct drm_i915_gem_mmap_gtt mmap_arg; +void *p1, *p2; +int i = loop; + +memset (&mmap_arg,0 ,sizeof (mmap_arg)); + mmap_arg.handle =gem_create (fd,OBJECT_SIZE ); +igt_assert (mmap_arg.handle); + +while (i--) { +/* +* Get mmap offset by calling GEM_MMAP_GTT one or multiple times in +* order to try to provoke a memory leak in the driver. +*/ +do_ioctl (fd,DRM_IOCTL_I915_GEM_MMAP_GTT , &mmap_arg); + } + + p1 =mmap64 (0 ,OBJECT_SIZE ,PROT_READ |PROT_WRITE , +MAP_SHARED , fd, mmap_arg.offset); +igt_assert (p1 !=MAP_FAILED ); + +gem_close (fd, mmap_arg.handle); + +/* +* Drop the freed objects for consistent 2nd mmap result. +*/ +igt_drop_caches_set (fd,DROP_FREED ); + + p2 =mmap64 (0 ,OBJECT_SIZE ,PROT_READ |PROT_WRITE , +MAP_SHARED , fd, mmap_arg.offset); + +munmap (p1,OBJECT_SIZE ); + +/* +* we expect mmapping p2 would fail, otherwise the driver +* may not clean up the allowance of vm_node, it would +* cause memory leak. +*/ +igt_assert (p2 ==MAP_FAILED ); + } +} +static int mmap_gtt_version (int i915) {int val =0 ;@@ -1315,6 +1361,9 @@ igt_main "writes into it from another GTT mmapped."); igt_subtest("basic-write-gtt")test_write_gtt (fd); +igt_describe ("Check mmap of a closed handle is rejected." ); + igt_subtest("mmap-closed-bo") +mmap_closed_bo (fd);igt_describe ("Inspect a GTT mmap using ptrace()." ); igt_subtest("ptrace")test_ptrace (fd);