public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [igt PATCH v2 1/1] lib: Incrementally mlock()
@ 2019-02-22  2:03 Caz Yokoyama
  2019-02-21 20:25 ` Chris Wilson
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Caz Yokoyama @ 2019-02-22  2:03 UTC (permalink / raw)
  To: igt-dev

As we already have the previous portion of the mmap mlocked, we only
need to mlock() the fresh portion for testing available memory.

Address calculation on mlock is fixed.

When the parent process mlocks, i.e.,
  igt_assert(!mlock(can_mlock, *can_mlock));
most likely killed.

In suspend.c, OOM kills when 64MB less memory is mlocked.

This patch does not make the test faster. It runs 300-900sec.
I recommend followings.

1. Run patched i915_suspend@shrink only on full test(shard test ?)
2. add lighter test such as 1) mlock 3/4 of avail memory, 2) suspend-resume

2 constantly runs less than 5 sec. However, it does not suspend-resume
with exhausting all of system memory.

Signed-off-by: Caz Yokoyama <caz.yokoyama@intel.com>
---
 lib/intel_os.c       | 17 +++++++++--------
 tests/i915/suspend.c |  7 +++++--
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/lib/intel_os.c b/lib/intel_os.c
index e1e31e23..44e852ee 100644
--- a/lib/intel_os.c
+++ b/lib/intel_os.c
@@ -250,22 +250,23 @@ intel_get_total_pinnable_mem(void)
 	}
 
 	for (uint64_t inc = 1024 << 20; inc >= 4 << 10; inc >>= 2) {
-		igt_debug("Testing mlock %'"PRIu64" B (%'"PRIu64" MiB)\n",
-			  *can_mlock, *can_mlock >> 20);
+		uint64_t locked = *can_mlock;
+
+		igt_debug("Testing mlock %'"PRIu64"B (%'"PRIu64"MiB) + %'"PRIu64"B\n",
+			  locked, locked >> 20, inc);
 
 		igt_fork(child, 1) {
-			for (uint64_t bytes = *can_mlock;
-			     bytes <= pin;
-			     bytes += inc) {
-				if (mlock(can_mlock, bytes))
+			uint64_t bytes = *can_mlock;
+
+			while (bytes <= pin) {
+				if (mlock((void *)can_mlock + bytes, inc))
 					break;
 
-				*can_mlock = bytes;
+				*can_mlock = bytes += inc;
 				__sync_synchronize();
 			}
 		}
 		__igt_waitchildren();
-		igt_assert(!mlock(can_mlock, *can_mlock));
 	}
 
 out:
diff --git a/tests/i915/suspend.c b/tests/i915/suspend.c
index 84cb3b49..99ab68be 100644
--- a/tests/i915/suspend.c
+++ b/tests/i915/suspend.c
@@ -160,6 +160,9 @@ test_sysfs_reader(bool hibernate)
 	igt_stop_helper(&reader);
 }
 
+#define MB (1 << 20)
+#define LESS_MEM (252*MB)
+
 static void
 test_shrink(int fd, unsigned int mode)
 {
@@ -170,8 +173,8 @@ test_shrink(int fd, unsigned int mode)
 	intel_purge_vm_caches(fd);
 
 	size = intel_get_total_pinnable_mem();
-	igt_require(size > 64 << 20);
-	size -= 64 << 20;
+	igt_require(size > LESS_MEM);
+	size -= LESS_MEM;
 
 	mem = mmap(NULL, size, PROT_READ, MAP_SHARED | MAP_ANON, -1, 0);
 
-- 
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] 5+ messages in thread

end of thread, other threads:[~2019-02-26 15:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-22  2:03 [igt-dev] [igt PATCH v2 1/1] lib: Incrementally mlock() Caz Yokoyama
2019-02-21 20:25 ` Chris Wilson
2019-02-22 16:12 ` Ashutosh Dixit
2019-02-22 17:28   ` Caz Yokoyama
2019-02-26 16:06 ` Caz Yokoyama

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox