All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t v2] tests/drv_suspend: Suspend under memory pressure
@ 2018-05-25  7:28 ` Chris Wilson
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Wilson @ 2018-05-25  7:28 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev, Tomi Sarvela

Recently we discovered that we have a race between swapping and
suspend in our resume path (we might be trying to page in an object
after disabling the block devices). Let's try to exercise that by
exhausting all of system memory before suspend.

v2: Explicitly share the large memory area on forking to avoid running
out of memory inside the suspend helpers (for they fork!)

References: https://bugs.freedesktop.org/show_bug.cgi?id=106640
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tomi Sarvela <tomi.p.sarvela@intel.com>
Reviewed-by: Antonio Argenziano <antonio.argenziano@intel.com>
---
 lib/igt_core.c      | 34 ++++++++++++++++------------
 lib/igt_core.h      |  1 +
 tests/drv_suspend.c | 54 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+), 14 deletions(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index e292ca24c..804ce4578 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1756,20 +1756,7 @@ void igt_child_done(pid_t pid)
 		test_children[i] = test_children[i + 1];
 }
 
-/**
- * igt_waitchildren:
- *
- * Wait for all children forked with igt_fork.
- *
- * The magic here is that exit codes from children will be correctly propagated
- * to the main thread, including the relevant exit code if a child thread failed.
- * Of course if multiple children failed with different exit codes the resulting
- * exit code will be non-deterministic.
- *
- * Note that igt_skip() will not be forwarded, feature tests need to be done
- * before spawning threads with igt_fork().
- */
-void igt_waitchildren(void)
+int __igt_waitchildren(void)
 {
 	int err = 0;
 	int count;
@@ -1815,6 +1802,25 @@ void igt_waitchildren(void)
 	}
 
 	num_test_children = 0;
+	return err;
+}
+
+/**
+ * igt_waitchildren:
+ *
+ * Wait for all children forked with igt_fork.
+ *
+ * The magic here is that exit codes from children will be correctly propagated
+ * to the main thread, including the relevant exit code if a child thread failed.
+ * Of course if multiple children failed with different exit codes the resulting
+ * exit code will be non-deterministic.
+ *
+ * Note that igt_skip() will not be forwarded, feature tests need to be done
+ * before spawning threads with igt_fork().
+ */
+void igt_waitchildren(void)
+{
+	int err = __igt_waitchildren();
 	if (err)
 		igt_fail(err);
 }
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 3d7b787b2..6d4260403 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -742,6 +742,7 @@ bool __igt_fork(void);
 	for (int child = 0; child < (num_children); child++) \
 		for (; __igt_fork(); exit(0))
 void igt_child_done(pid_t pid);
+int __igt_waitchildren(void);
 void igt_waitchildren(void);
 void igt_waitchildren_timeout(int seconds, const char *reason);
 
diff --git a/tests/drv_suspend.c b/tests/drv_suspend.c
index 2e39f20ae..9a9ff2005 100644
--- a/tests/drv_suspend.c
+++ b/tests/drv_suspend.c
@@ -160,6 +160,57 @@ test_sysfs_reader(bool hibernate)
 	igt_stop_helper(&reader);
 }
 
+static void
+test_shrink(int fd, unsigned int mode)
+{
+	uint64_t *can_mlock, pin;
+
+	gem_quiescent_gpu(fd);
+	intel_purge_vm_caches(fd);
+
+	pin = (intel_get_total_ram_mb() + 1) << 20;
+
+	igt_debug("Total memory %'"PRIu64" B (%'"PRIu64" MiB)\n",
+		  pin, pin >> 20);
+	can_mlock = mmap(NULL, pin, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+	igt_require(can_mlock != MAP_FAILED);
+
+	/* Lock all the system memory, forcing the driver into swap and OOM */
+	for (uint64_t inc = 64 << 20; inc >= 4 << 10; inc >>= 1) {
+		igt_debug("Testing+ %'"PRIu64" B (%'"PRIu64" MiB)\n",
+			  *can_mlock, *can_mlock >> 20);
+
+		igt_fork(child, 1) {
+			for (uint64_t bytes = *can_mlock;
+			     bytes <= pin;
+			     bytes += inc) {
+				if (mlock(can_mlock, bytes))
+					break;
+
+				*can_mlock = bytes;
+				__sync_synchronize();
+			}
+		}
+		__igt_waitchildren();
+	}
+
+	intel_purge_vm_caches(fd);
+
+	igt_require(*can_mlock > 64 << 20);
+	*can_mlock -= 64 << 20;
+
+	igt_debug("Locking %'"PRIu64" B (%'"PRIu64" MiB)\n",
+		  *can_mlock, *can_mlock >> 20);
+	igt_assert(!mlock(can_mlock, *can_mlock));
+	igt_info("Locked %'"PRIu64" B (%'"PRIu64" MiB)\n",
+		 *can_mlock, *can_mlock >> 20);
+
+	intel_purge_vm_caches(fd);
+	igt_system_suspend_autoresume(mode, SUSPEND_TEST_NONE);
+
+	munmap(can_mlock, pin);
+}
+
 static void
 test_forcewake(int fd, bool hibernate)
 {
@@ -199,6 +250,9 @@ igt_main
 	igt_subtest("sysfs-reader")
 		test_sysfs_reader(false);
 
+	igt_subtest("shrink")
+		test_shrink(fd, SUSPEND_STATE_MEM);
+
 	igt_subtest("forcewake")
 		test_forcewake(fd, false);
 
-- 
2.17.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [igt-dev] [PATCH i-g-t v2] tests/drv_suspend: Suspend under memory pressure
@ 2018-05-25  7:28 ` Chris Wilson
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Wilson @ 2018-05-25  7:28 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev, Tomi Sarvela

Recently we discovered that we have a race between swapping and
suspend in our resume path (we might be trying to page in an object
after disabling the block devices). Let's try to exercise that by
exhausting all of system memory before suspend.

v2: Explicitly share the large memory area on forking to avoid running
out of memory inside the suspend helpers (for they fork!)

References: https://bugs.freedesktop.org/show_bug.cgi?id=106640
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tomi Sarvela <tomi.p.sarvela@intel.com>
Reviewed-by: Antonio Argenziano <antonio.argenziano@intel.com>
---
 lib/igt_core.c      | 34 ++++++++++++++++------------
 lib/igt_core.h      |  1 +
 tests/drv_suspend.c | 54 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+), 14 deletions(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index e292ca24c..804ce4578 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1756,20 +1756,7 @@ void igt_child_done(pid_t pid)
 		test_children[i] = test_children[i + 1];
 }
 
-/**
- * igt_waitchildren:
- *
- * Wait for all children forked with igt_fork.
- *
- * The magic here is that exit codes from children will be correctly propagated
- * to the main thread, including the relevant exit code if a child thread failed.
- * Of course if multiple children failed with different exit codes the resulting
- * exit code will be non-deterministic.
- *
- * Note that igt_skip() will not be forwarded, feature tests need to be done
- * before spawning threads with igt_fork().
- */
-void igt_waitchildren(void)
+int __igt_waitchildren(void)
 {
 	int err = 0;
 	int count;
@@ -1815,6 +1802,25 @@ void igt_waitchildren(void)
 	}
 
 	num_test_children = 0;
+	return err;
+}
+
+/**
+ * igt_waitchildren:
+ *
+ * Wait for all children forked with igt_fork.
+ *
+ * The magic here is that exit codes from children will be correctly propagated
+ * to the main thread, including the relevant exit code if a child thread failed.
+ * Of course if multiple children failed with different exit codes the resulting
+ * exit code will be non-deterministic.
+ *
+ * Note that igt_skip() will not be forwarded, feature tests need to be done
+ * before spawning threads with igt_fork().
+ */
+void igt_waitchildren(void)
+{
+	int err = __igt_waitchildren();
 	if (err)
 		igt_fail(err);
 }
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 3d7b787b2..6d4260403 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -742,6 +742,7 @@ bool __igt_fork(void);
 	for (int child = 0; child < (num_children); child++) \
 		for (; __igt_fork(); exit(0))
 void igt_child_done(pid_t pid);
+int __igt_waitchildren(void);
 void igt_waitchildren(void);
 void igt_waitchildren_timeout(int seconds, const char *reason);
 
diff --git a/tests/drv_suspend.c b/tests/drv_suspend.c
index 2e39f20ae..9a9ff2005 100644
--- a/tests/drv_suspend.c
+++ b/tests/drv_suspend.c
@@ -160,6 +160,57 @@ test_sysfs_reader(bool hibernate)
 	igt_stop_helper(&reader);
 }
 
+static void
+test_shrink(int fd, unsigned int mode)
+{
+	uint64_t *can_mlock, pin;
+
+	gem_quiescent_gpu(fd);
+	intel_purge_vm_caches(fd);
+
+	pin = (intel_get_total_ram_mb() + 1) << 20;
+
+	igt_debug("Total memory %'"PRIu64" B (%'"PRIu64" MiB)\n",
+		  pin, pin >> 20);
+	can_mlock = mmap(NULL, pin, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+	igt_require(can_mlock != MAP_FAILED);
+
+	/* Lock all the system memory, forcing the driver into swap and OOM */
+	for (uint64_t inc = 64 << 20; inc >= 4 << 10; inc >>= 1) {
+		igt_debug("Testing+ %'"PRIu64" B (%'"PRIu64" MiB)\n",
+			  *can_mlock, *can_mlock >> 20);
+
+		igt_fork(child, 1) {
+			for (uint64_t bytes = *can_mlock;
+			     bytes <= pin;
+			     bytes += inc) {
+				if (mlock(can_mlock, bytes))
+					break;
+
+				*can_mlock = bytes;
+				__sync_synchronize();
+			}
+		}
+		__igt_waitchildren();
+	}
+
+	intel_purge_vm_caches(fd);
+
+	igt_require(*can_mlock > 64 << 20);
+	*can_mlock -= 64 << 20;
+
+	igt_debug("Locking %'"PRIu64" B (%'"PRIu64" MiB)\n",
+		  *can_mlock, *can_mlock >> 20);
+	igt_assert(!mlock(can_mlock, *can_mlock));
+	igt_info("Locked %'"PRIu64" B (%'"PRIu64" MiB)\n",
+		 *can_mlock, *can_mlock >> 20);
+
+	intel_purge_vm_caches(fd);
+	igt_system_suspend_autoresume(mode, SUSPEND_TEST_NONE);
+
+	munmap(can_mlock, pin);
+}
+
 static void
 test_forcewake(int fd, bool hibernate)
 {
@@ -199,6 +250,9 @@ igt_main
 	igt_subtest("sysfs-reader")
 		test_sysfs_reader(false);
 
+	igt_subtest("shrink")
+		test_shrink(fd, SUSPEND_STATE_MEM);
+
 	igt_subtest("forcewake")
 		test_forcewake(fd, false);
 
-- 
2.17.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [igt-dev] ✓ Fi.CI.BAT: success for tests/drv_suspend: Suspend under memory pressure (rev2)
  2018-05-25  7:28 ` [igt-dev] " Chris Wilson
  (?)
@ 2018-05-25  8:46 ` Patchwork
  -1 siblings, 0 replies; 4+ messages in thread
From: Patchwork @ 2018-05-25  8:46 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev

== Series Details ==

Series: tests/drv_suspend: Suspend under memory pressure (rev2)
URL   : https://patchwork.freedesktop.org/series/43696/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4238 -> IGTPW_1398 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/43696/revisions/2/mbox/

== Known issues ==

  Here are the changes found in IGTPW_1398 that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@kms_frontbuffer_tracking@basic:
      fi-hsw-peppy:       PASS -> DMESG-FAIL (fdo#106103, fdo#102614)

    
    ==== Possible fixes ====

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-snb-2520m:       INCOMPLETE (fdo#103713) -> PASS

    
  fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614
  fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
  fdo#106103 https://bugs.freedesktop.org/show_bug.cgi?id=106103


== Participating hosts (44 -> 39) ==

  Missing    (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-skl-6700hq 


== Build changes ==

    * IGT: IGT_4498 -> IGTPW_1398

  CI_DRM_4238: 2771a5e6347eb63e43fdfc432a9f15ffb55ef209 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1398: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1398/
  IGT_4498: f9ecb79ad8b02278cfdb5b82495df47061c04f8f @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools



== Testlist changes ==

+igt@drv_suspend@shrink

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1398/issues.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [igt-dev] ✓ Fi.CI.IGT: success for tests/drv_suspend: Suspend under memory pressure (rev2)
  2018-05-25  7:28 ` [igt-dev] " Chris Wilson
  (?)
  (?)
@ 2018-05-25 12:10 ` Patchwork
  -1 siblings, 0 replies; 4+ messages in thread
From: Patchwork @ 2018-05-25 12:10 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev

== Series Details ==

Series: tests/drv_suspend: Suspend under memory pressure (rev2)
URL   : https://patchwork.freedesktop.org/series/43696/
State : success

== Summary ==

= CI Bug Log - changes from IGT_4498_full -> IGTPW_1398_full =

== Summary - WARNING ==

  Minor unknown changes coming with IGTPW_1398_full need to be verified
  manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_1398_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/43696/revisions/2/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in IGTPW_1398_full:

  === IGT changes ===

    ==== Possible regressions ====

    {igt@drv_suspend@shrink}:
      shard-snb:          NOTRUN -> FAIL
      shard-hsw:          NOTRUN -> FAIL
      shard-apl:          NOTRUN -> FAIL
      shard-glk:          NOTRUN -> FAIL

    
    ==== Warnings ====

    igt@gem_exec_schedule@deep-bsd1:
      shard-kbl:          PASS -> SKIP +1

    igt@gem_mocs_settings@mocs-rc6-vebox:
      shard-kbl:          SKIP -> PASS +1

    igt@kms_chv_cursor_fail@pipe-a-256x256-bottom-edge:
      shard-snb:          SKIP -> PASS

    
== Known issues ==

  Here are the changes found in IGTPW_1398_full that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    {igt@drv_suspend@shrink}:
      shard-kbl:          NOTRUN -> INCOMPLETE (fdo#103665)

    igt@kms_atomic_transition@1x-modeset-transitions-nonblocking:
      shard-glk:          PASS -> FAIL (fdo#105703)

    {igt@kms_available_modes_crc@available_mode_test_crc}:
      shard-snb:          PASS -> FAIL (fdo#106641)

    igt@kms_cursor_crc@cursor-128x128-suspend:
      shard-kbl:          PASS -> INCOMPLETE (fdo#106024, fdo#103665)

    igt@kms_cursor_legacy@2x-nonblocking-modeset-vs-cursor-atomic:
      shard-glk:          PASS -> FAIL (fdo#106509, fdo#105454)

    igt@kms_flip@basic-flip-vs-modeset:
      shard-apl:          PASS -> DMESG-WARN (fdo#105602, fdo#103558) +5

    igt@kms_flip@plain-flip-ts-check-interruptible:
      shard-glk:          PASS -> FAIL (fdo#100368)
      shard-hsw:          PASS -> FAIL (fdo#100368)

    igt@kms_flip_tiling@flip-to-y-tiled:
      shard-glk:          PASS -> FAIL (fdo#104724, fdo#103822)

    igt@kms_rotation_crc@primary-rotation-180:
      shard-snb:          PASS -> FAIL (fdo#103925, fdo#104724)

    igt@kms_setmode@basic:
      shard-kbl:          PASS -> FAIL (fdo#99912)

    igt@kms_setmode@clone-exclusive-crtc:
      shard-hsw:          PASS -> DMESG-WARN (fdo#102614)

    igt@kms_vblank@pipe-a-ts-continuation-suspend:
      shard-kbl:          PASS -> INCOMPLETE (fdo#103665)

    igt@perf@blocking:
      shard-hsw:          PASS -> FAIL (fdo#102252)

    
    ==== Possible fixes ====

    igt@drv_selftest@live_gtt:
      shard-kbl:          INCOMPLETE (fdo#103665) -> PASS +1

    igt@gem_ppgtt@blt-vs-render-ctx0:
      shard-kbl:          INCOMPLETE (fdo#106023, fdo#103665) -> PASS

    {igt@kms_available_modes_crc@available_mode_test_crc}:
      shard-apl:          FAIL (fdo#106641) -> PASS

    igt@kms_flip@2x-plain-flip-fb-recreate:
      shard-hsw:          FAIL (fdo#103928) -> PASS

    igt@kms_flip@flip-vs-expired-vblank:
      shard-glk:          FAIL (fdo#102887) -> PASS

    igt@kms_flip@flip-vs-expired-vblank-interruptible:
      shard-glk:          FAIL (fdo#102887, fdo#105363) -> PASS

    igt@kms_flip@plain-flip-fb-recreate:
      shard-glk:          FAIL (fdo#100368) -> PASS

    igt@kms_flip_tiling@flip-to-x-tiled:
      shard-glk:          FAIL (fdo#104724, fdo#103822) -> PASS +1

    igt@kms_plane_multiple@atomic-pipe-a-tiling-x:
      shard-snb:          FAIL (fdo#103166, fdo#104724) -> PASS

    igt@kms_rotation_crc@sprite-rotation-180:
      shard-snb:          FAIL (fdo#103925, fdo#104724) -> PASS

    
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
  fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614
  fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
  fdo#103166 https://bugs.freedesktop.org/show_bug.cgi?id=103166
  fdo#103558 https://bugs.freedesktop.org/show_bug.cgi?id=103558
  fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
  fdo#103822 https://bugs.freedesktop.org/show_bug.cgi?id=103822
  fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
  fdo#103928 https://bugs.freedesktop.org/show_bug.cgi?id=103928
  fdo#104724 https://bugs.freedesktop.org/show_bug.cgi?id=104724
  fdo#105363 https://bugs.freedesktop.org/show_bug.cgi?id=105363
  fdo#105454 https://bugs.freedesktop.org/show_bug.cgi?id=105454
  fdo#105602 https://bugs.freedesktop.org/show_bug.cgi?id=105602
  fdo#105703 https://bugs.freedesktop.org/show_bug.cgi?id=105703
  fdo#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023
  fdo#106024 https://bugs.freedesktop.org/show_bug.cgi?id=106024
  fdo#106509 https://bugs.freedesktop.org/show_bug.cgi?id=106509
  fdo#106641 https://bugs.freedesktop.org/show_bug.cgi?id=106641
  fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912


== Participating hosts (5 -> 5) ==

  No changes in participating hosts


== Build changes ==

    * IGT: IGT_4498 -> IGTPW_1398
    * Linux: CI_DRM_4227 -> CI_DRM_4238

  CI_DRM_4227: a8727d3fe03770e4d523468dfbc487dfe01597d3 @ git://anongit.freedesktop.org/gfx-ci/linux
  CI_DRM_4238: 2771a5e6347eb63e43fdfc432a9f15ffb55ef209 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1398: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1398/
  IGT_4498: f9ecb79ad8b02278cfdb5b82495df47061c04f8f @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1398/shards.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-05-25 12:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-25  7:28 [PATCH i-g-t v2] tests/drv_suspend: Suspend under memory pressure Chris Wilson
2018-05-25  7:28 ` [igt-dev] " Chris Wilson
2018-05-25  8:46 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/drv_suspend: Suspend under memory pressure (rev2) Patchwork
2018-05-25 12:10 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.