All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] igt/drv_suspend: Suspend under memory pressure
@ 2018-06-07 20:50 ` Chris Wilson
  0 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2018-06-07 20:50 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 5092a3f03..06d8b0370 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1702,20 +1702,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;
@@ -1761,6 +1748,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 bf8cd66ca..a73b06493 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.1

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

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

* [igt-dev] [PATCH i-g-t] igt/drv_suspend: Suspend under memory pressure
@ 2018-06-07 20:50 ` Chris Wilson
  0 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2018-06-07 20:50 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 5092a3f03..06d8b0370 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1702,20 +1702,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;
@@ -1761,6 +1748,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 bf8cd66ca..a73b06493 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.1

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

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

* [igt-dev] ✓ Fi.CI.BAT: success for igt/drv_suspend: Suspend under memory pressure
  2018-06-07 20:50 ` [igt-dev] " Chris Wilson
  (?)
@ 2018-06-07 21:17 ` Patchwork
  -1 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2018-06-07 21:17 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev

== Series Details ==

Series: igt/drv_suspend: Suspend under memory pressure
URL   : https://patchwork.freedesktop.org/series/44440/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4289 -> IGTPW_1430 =

== Summary - WARNING ==

  Minor unknown changes coming with IGTPW_1430 need to be verified
  manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_1430, 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/44440/revisions/1/mbox/

== Possible new issues ==

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

  === IGT changes ===

    ==== Warnings ====

    igt@gem_exec_gttfill@basic:
      fi-pnv-d510:        SKIP -> PASS

    igt@kms_pipe_crc_basic@nonblocking-crc-pipe-c-frame-sequence:
      fi-glk-j4005:       PASS -> SKIP +1

    igt@kms_pipe_crc_basic@read-crc-pipe-c:
      fi-glk-j4005:       SKIP -> PASS

    
== Known issues ==

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

  === IGT changes ===

    ==== Issues hit ====

    igt@drv_module_reload@basic-no-display:
      fi-glk-j4005:       PASS -> DMESG-WARN (fdo#106725)

    igt@gem_sync@basic-each:
      fi-cnl-y3:          PASS -> INCOMPLETE (fdo#105086)

    igt@kms_flip@basic-flip-vs-dpms:
      fi-glk-j4005:       PASS -> DMESG-WARN (fdo#106000)

    
    ==== Possible fixes ====

    igt@core_auth@basic-auth:
      fi-bdw-gvtdvm:      DMESG-WARN (fdo#105600) -> PASS +2

    igt@kms_flip@basic-flip-vs-modeset:
      fi-glk-j4005:       DMESG-WARN (fdo#106000) -> PASS +2

    igt@kms_pipe_crc_basic@read-crc-pipe-b-frame-sequence:
      fi-glk-j4005:       FAIL (fdo#103481) -> PASS

    
  fdo#103481 https://bugs.freedesktop.org/show_bug.cgi?id=103481
  fdo#105086 https://bugs.freedesktop.org/show_bug.cgi?id=105086
  fdo#105600 https://bugs.freedesktop.org/show_bug.cgi?id=105600
  fdo#106000 https://bugs.freedesktop.org/show_bug.cgi?id=106000
  fdo#106725 https://bugs.freedesktop.org/show_bug.cgi?id=106725


== Participating hosts (40 -> 36) ==

  Missing    (4): fi-ilk-m540 fi-byt-squawks fi-skl-6700hq fi-hsw-4200u 


== Build changes ==

    * IGT: IGT_4509 -> IGTPW_1430

  CI_DRM_4289: 0e963d962be75b4e3d3d1c884e1bf4600473096d @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1430: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1430/
  IGT_4509: c8f1ae58e1b7da17af4722a5ce5a9cd8b9a34059 @ 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_1430/issues.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] ✗ Fi.CI.IGT: failure for igt/drv_suspend: Suspend under memory pressure
  2018-06-07 20:50 ` [igt-dev] " Chris Wilson
  (?)
  (?)
@ 2018-06-07 23:49 ` Patchwork
  -1 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2018-06-07 23:49 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev

== Series Details ==

Series: igt/drv_suspend: Suspend under memory pressure
URL   : https://patchwork.freedesktop.org/series/44440/
State : failure

== Summary ==

= CI Bug Log - changes from IGT_4509_full -> IGTPW_1430_full =

== Summary - FAILURE ==

  Serious unknown changes coming with IGTPW_1430_full absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_1430_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/44440/revisions/1/mbox/

== Possible new issues ==

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

  === IGT changes ===

    ==== Possible regressions ====

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

    
    ==== Warnings ====

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

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

    
== Known issues ==

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

  === IGT changes ===

    ==== Issues hit ====

    igt@drv_selftest@live_hangcheck:
      shard-apl:          PASS -> DMESG-FAIL (fdo#106560)

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

    igt@kms_cursor_legacy@cursor-vs-flip-toggle:
      shard-hsw:          PASS -> FAIL (fdo#103355)

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

    igt@kms_flip_tiling@flip-changes-tiling-yf:
      shard-kbl:          PASS -> DMESG-WARN (fdo#106247)

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

    igt@kms_plane@plane-panning-bottom-right-suspend-pipe-b-planes:
      shard-kbl:          PASS -> INCOMPLETE (fdo#103665)

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

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

    igt@testdisplay:
      shard-glk:          PASS -> INCOMPLETE (fdo#103359, k.org#198133) +1

    
    ==== Possible fixes ====

    igt@drv_selftest@live_gtt:
      shard-glk:          INCOMPLETE (fdo#103359, k.org#198133) -> PASS

    igt@gem_eio@hibernate:
      shard-snb:          INCOMPLETE (fdo#105411) -> PASS

    igt@kms_flip@2x-dpms-vs-vblank-race-interruptible:
      shard-hsw:          FAIL (fdo#103060) -> PASS

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

    igt@kms_flip@2x-plain-flip-fb-recreate-interruptible:
      shard-glk:          FAIL (fdo#100368) -> PASS +1

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

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

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

    igt@perf_pmu@multi-client-vcs1:
      shard-snb:          INCOMPLETE (fdo#105411) -> SKIP

    
  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
  fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
  fdo#103355 https://bugs.freedesktop.org/show_bug.cgi?id=103355
  fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359
  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#104724 https://bugs.freedesktop.org/show_bug.cgi?id=104724
  fdo#105363 https://bugs.freedesktop.org/show_bug.cgi?id=105363
  fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
  fdo#105454 https://bugs.freedesktop.org/show_bug.cgi?id=105454
  fdo#106247 https://bugs.freedesktop.org/show_bug.cgi?id=106247
  fdo#106509 https://bugs.freedesktop.org/show_bug.cgi?id=106509
  fdo#106560 https://bugs.freedesktop.org/show_bug.cgi?id=106560
  k.org#198133 https://bugzilla.kernel.org/show_bug.cgi?id=198133


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

  No changes in participating hosts


== Build changes ==

    * IGT: IGT_4509 -> IGTPW_1430
    * Linux: CI_DRM_4282 -> CI_DRM_4289

  CI_DRM_4282: c1064b9be065603680d060184da1a93d404dcf0c @ git://anongit.freedesktop.org/gfx-ci/linux
  CI_DRM_4289: 0e963d962be75b4e3d3d1c884e1bf4600473096d @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1430: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1430/
  IGT_4509: c8f1ae58e1b7da17af4722a5ce5a9cd8b9a34059 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

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

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

* Re: [igt-dev] [PATCH i-g-t] igt/drv_suspend: Suspend under memory pressure
  2018-06-07 20:50 ` [igt-dev] " Chris Wilson
@ 2018-06-08 10:21   ` Ewelina Musial
  -1 siblings, 0 replies; 12+ messages in thread
From: Ewelina Musial @ 2018-06-08 10:21 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev, Tomi Sarvela, intel-gfx

On Thu, Jun 07, 2018 at 09:50:54PM +0100, Chris Wilson wrote:
> 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 5092a3f03..06d8b0370 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -1702,20 +1702,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;
> @@ -1761,6 +1748,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 bf8cd66ca..a73b06493 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();

I am just curious, what __sync_synchronize() is doing in this case?
-Ewelina

> +			}
> +		}
> +		__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.1
> 
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [igt-dev] [PATCH i-g-t] igt/drv_suspend: Suspend under memory pressure
@ 2018-06-08 10:21   ` Ewelina Musial
  0 siblings, 0 replies; 12+ messages in thread
From: Ewelina Musial @ 2018-06-08 10:21 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev, Tomi Sarvela, intel-gfx

On Thu, Jun 07, 2018 at 09:50:54PM +0100, Chris Wilson wrote:
> 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 5092a3f03..06d8b0370 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -1702,20 +1702,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;
> @@ -1761,6 +1748,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 bf8cd66ca..a73b06493 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();

I am just curious, what __sync_synchronize() is doing in this case?
-Ewelina

> +			}
> +		}
> +		__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.1
> 
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t] igt/drv_suspend: Suspend under memory pressure
  2018-06-08 10:21   ` Ewelina Musial
@ 2018-06-08 10:26     ` Chris Wilson
  -1 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2018-06-08 10:26 UTC (permalink / raw)
  To: Ewelina Musial; +Cc: igt-dev, Tomi Sarvela, intel-gfx

Quoting Ewelina Musial (2018-06-08 11:21:41)
> On Thu, Jun 07, 2018 at 09:50:54PM +0100, Chris Wilson wrote:
> > 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 5092a3f03..06d8b0370 100644
> > --- a/lib/igt_core.c
> > +++ b/lib/igt_core.c
> > @@ -1702,20 +1702,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;
> > @@ -1761,6 +1748,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 bf8cd66ca..a73b06493 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();
> 
> I am just curious, what __sync_synchronize() is doing in this case?

Paranoia. It's mostly about that can_mlock being shared memory and we
want to stress that the parent sees the update even as the child is
killed. So the paranoid in me says we have better flush our cachelines,
just in case they are one day tagged as belonging to this terminated
process and can be aborted.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [igt-dev] [PATCH i-g-t] igt/drv_suspend: Suspend under memory pressure
@ 2018-06-08 10:26     ` Chris Wilson
  0 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2018-06-08 10:26 UTC (permalink / raw)
  To: Ewelina Musial; +Cc: igt-dev, Tomi Sarvela, intel-gfx

Quoting Ewelina Musial (2018-06-08 11:21:41)
> On Thu, Jun 07, 2018 at 09:50:54PM +0100, Chris Wilson wrote:
> > 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 5092a3f03..06d8b0370 100644
> > --- a/lib/igt_core.c
> > +++ b/lib/igt_core.c
> > @@ -1702,20 +1702,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;
> > @@ -1761,6 +1748,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 bf8cd66ca..a73b06493 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();
> 
> I am just curious, what __sync_synchronize() is doing in this case?

Paranoia. It's mostly about that can_mlock being shared memory and we
want to stress that the parent sees the update even as the child is
killed. So the paranoid in me says we have better flush our cachelines,
just in case they are one day tagged as belonging to this terminated
process and can be aborted.
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] ✓ Fi.CI.BAT: success for igt/drv_suspend: Suspend under memory pressure
  2018-06-07 20:50 ` [igt-dev] " Chris Wilson
                   ` (3 preceding siblings ...)
  (?)
@ 2018-06-08 11:30 ` Patchwork
  -1 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2018-06-08 11:30 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev

== Series Details ==

Series: igt/drv_suspend: Suspend under memory pressure
URL   : https://patchwork.freedesktop.org/series/44440/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4293 -> IGTPW_1432 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/44440/revisions/1/mbox/

== Known issues ==

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

  === IGT changes ===

    ==== Issues hit ====

    igt@drv_module_reload@basic-reload-inject:
      fi-glk-j4005:       PASS -> DMESG-WARN (fdo#106000)

    igt@gem_exec_suspend@basic-s4-devices:
      fi-glk-j4005:       PASS -> DMESG-WARN (fdo#106097)

    igt@gem_mmap_gtt@basic-small-bo-tiledx:
      fi-gdg-551:         PASS -> FAIL (fdo#102575)

    igt@kms_pipe_crc_basic@read-crc-pipe-c:
      fi-glk-j4005:       PASS -> DMESG-WARN (fdo#105719)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
      fi-bxt-dsi:         PASS -> INCOMPLETE (fdo#103927)

    igt@prime_vgem@basic-fence-flip:
      fi-ilk-650:         PASS -> FAIL (fdo#104008)

    
    ==== Possible fixes ====

    igt@gem_exec_fence@basic-await-default:
      fi-glk-j4005:       DMESG-WARN (fdo#106000) -> PASS +1

    igt@gem_sync@basic-many-each:
      fi-cnl-y3:          INCOMPLETE (fdo#105086) -> PASS

    
    ==== Warnings ====

    igt@kms_pipe_crc_basic@read-crc-pipe-b-frame-sequence:
      fi-glk-j4005:       DMESG-WARN (fdo#106000, fdo#106097) -> FAIL (fdo#103481)

    
  fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
  fdo#103481 https://bugs.freedesktop.org/show_bug.cgi?id=103481
  fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
  fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008
  fdo#105086 https://bugs.freedesktop.org/show_bug.cgi?id=105086
  fdo#105719 https://bugs.freedesktop.org/show_bug.cgi?id=105719
  fdo#106000 https://bugs.freedesktop.org/show_bug.cgi?id=106000
  fdo#106097 https://bugs.freedesktop.org/show_bug.cgi?id=106097


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

  Missing    (3): fi-ilk-m540 fi-byt-squawks fi-skl-6700hq 


== Build changes ==

    * IGT: IGT_4511 -> IGTPW_1432

  CI_DRM_4293: 70d3bb47919b2acc66aa1d7a6566cdf60a0cf66d @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1432: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1432/
  IGT_4511: 44b837c9b498a2749d2564cbd8acb5a57da02217 @ 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_1432/issues.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] ✓ Fi.CI.IGT: success for igt/drv_suspend: Suspend under memory pressure
  2018-06-07 20:50 ` [igt-dev] " Chris Wilson
                   ` (4 preceding siblings ...)
  (?)
@ 2018-06-08 13:19 ` Patchwork
  -1 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2018-06-08 13:19 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev

== Series Details ==

Series: igt/drv_suspend: Suspend under memory pressure
URL   : https://patchwork.freedesktop.org/series/44440/
State : success

== Summary ==

= CI Bug Log - changes from IGT_4511_full -> IGTPW_1432_full =

== Summary - WARNING ==

  Minor unknown changes coming with IGTPW_1432_full need to be verified
  manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_1432_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/44440/revisions/1/mbox/

== Possible new issues ==

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

  === IGT changes ===

    ==== Warnings ====

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

    igt@gem_pwrite@big-gtt-random:
      shard-apl:          SKIP -> PASS
      shard-glk:          SKIP -> PASS

    
== Known issues ==

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

  === IGT changes ===

    ==== Issues hit ====

    igt@drv_selftest@live_gtt:
      shard-apl:          PASS -> INCOMPLETE (fdo#103927)

    igt@drv_suspend@shrink:
      shard-apl:          NOTRUN -> INCOMPLETE (fdo#103927)

    igt@gem_ctx_isolation@bcs0-s3:
      shard-kbl:          PASS -> INCOMPLETE (fdo#103665) +1

    igt@gem_partial_pwrite_pread@write:
      shard-snb:          PASS -> INCOMPLETE (fdo#105411) +1

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

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

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

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

    igt@kms_rotation_crc@sprite-rotation-90-pos-100-0:
      shard-kbl:          PASS -> FAIL (fdo#103925, fdo#104724)

    
    ==== Possible fixes ====

    igt@gem_exec_reuse@single:
      shard-snb:          INCOMPLETE (fdo#105411) -> PASS

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

    igt@gem_workarounds@suspend-resume-fd:
      shard-kbl:          INCOMPLETE (fdo#103665) -> PASS

    igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions:
      shard-hsw:          FAIL (fdo#102670) -> PASS

    igt@kms_flip@2x-dpms-vs-vblank-race:
      shard-hsw:          FAIL (fdo#103060) -> PASS

    igt@kms_flip@2x-flip-vs-expired-vblank-interruptible:
      shard-hsw:          FAIL (fdo#102887) -> PASS

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

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

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

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

    
    ==== Warnings ====

    igt@drv_selftest@live_gtt:
      shard-glk:          INCOMPLETE (k.org#198133, fdo#103359) -> FAIL (fdo#105347)

    igt@kms_sysfs_edid_timing:
      shard-hsw:          FAIL (fdo#100047) -> WARN (fdo#100047)

    
  fdo#100047 https://bugs.freedesktop.org/show_bug.cgi?id=100047
  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#102670 https://bugs.freedesktop.org/show_bug.cgi?id=102670
  fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
  fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
  fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359
  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#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
  fdo#104724 https://bugs.freedesktop.org/show_bug.cgi?id=104724
  fdo#105347 https://bugs.freedesktop.org/show_bug.cgi?id=105347
  fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
  fdo#105703 https://bugs.freedesktop.org/show_bug.cgi?id=105703
  fdo#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023
  fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
  k.org#198133 https://bugzilla.kernel.org/show_bug.cgi?id=198133


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

  No changes in participating hosts


== Build changes ==

    * IGT: IGT_4511 -> IGTPW_1432
    * Linux: CI_DRM_4292 -> CI_DRM_4293

  CI_DRM_4292: 0646de2b0b0abe16b836b804bf03ce24ea618264 @ git://anongit.freedesktop.org/gfx-ci/linux
  CI_DRM_4293: 70d3bb47919b2acc66aa1d7a6566cdf60a0cf66d @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1432: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1432/
  IGT_4511: 44b837c9b498a2749d2564cbd8acb5a57da02217 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

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

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

* Re: [PATCH i-g-t] igt/drv_suspend: Suspend under memory pressure
  2018-06-07 20:50 ` [igt-dev] " Chris Wilson
@ 2018-06-08 13:22   ` Chris Wilson
  -1 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2018-06-08 13:22 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev, Tomi Sarvela

Quoting Chris Wilson (2018-06-07 21:50:54)
> 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>

With the more discerning oomkiller, this finally works as intended.
Pushed while the iron is hot.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [igt-dev] [PATCH i-g-t] igt/drv_suspend: Suspend under memory pressure
@ 2018-06-08 13:22   ` Chris Wilson
  0 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2018-06-08 13:22 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev, Tomi Sarvela

Quoting Chris Wilson (2018-06-07 21:50:54)
> 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>

With the more discerning oomkiller, this finally works as intended.
Pushed while the iron is hot.
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

end of thread, other threads:[~2018-06-08 13:22 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-07 20:50 [PATCH i-g-t] igt/drv_suspend: Suspend under memory pressure Chris Wilson
2018-06-07 20:50 ` [igt-dev] " Chris Wilson
2018-06-07 21:17 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-06-07 23:49 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2018-06-08 10:21 ` [igt-dev] [PATCH i-g-t] " Ewelina Musial
2018-06-08 10:21   ` Ewelina Musial
2018-06-08 10:26   ` Chris Wilson
2018-06-08 10:26     ` Chris Wilson
2018-06-08 11:30 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-06-08 13:19 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-06-08 13:22 ` [PATCH i-g-t] " Chris Wilson
2018-06-08 13:22   ` [igt-dev] " Chris Wilson

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.