[igt-dev] [PATCH i-g-t] i915/gem_mmap_gtt: Reduce RSS for fault-concurrent

Chris Wilson chris at chris-wilson.co.uk
Mon Sep 30 10:37:45 UTC 2019


The intent of exercising parallel page fault is not necessarily to
exercise parallel swap-in (we can safely rely on that being well tested
and is orthogonal to page faulting), but to make sure that our object
and GGTT locking is exercised. We can safely reduce our RSS without loss
of coverage. Furthermore, by using varying sizes we can exercise
different code paths within page faulting, rather than all being
serviced as partial mmaps. Instead of allocating 32 surfaces, each of
16MiB, we allocate 32 surfaces in incremental 512KiB sizes; halving the
memory requirement.

References: https://bugs.freedesktop.org/show_bug.cgi?id=111864
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 tests/i915/gem_mmap_gtt.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
index 91da5a37b..0f856666e 100644
--- a/tests/i915/gem_mmap_gtt.c
+++ b/tests/i915/gem_mmap_gtt.c
@@ -67,12 +67,12 @@ mmap_bo(int fd, uint32_t handle)
 }
 
 static void *
-create_pointer(int fd)
+create_pointer_size(int fd, uint64_t size)
 {
 	uint32_t handle;
 	void *ptr;
 
-	handle = gem_create(fd, OBJECT_SIZE);
+	handle = gem_create(fd, size);
 
 	ptr = mmap_bo(fd, handle);
 
@@ -81,6 +81,12 @@ create_pointer(int fd)
 	return ptr;
 }
 
+static void *
+create_pointer(int fd)
+{
+	return create_pointer_size(fd, OBJECT_SIZE);
+}
+
 static void
 test_access(int fd)
 {
@@ -958,10 +964,16 @@ thread_fault_concurrent(void *closure)
 	int n;
 
 	for (n = 0; n < 32; n++) {
+		unsigned int id = (n + t->id) % 32;
+		uint32_t sz = *t->ptr[id] - 1;
+		int idx = rand() % sz + 1;
+
 		if (n & 1)
-			*t->ptr[(n + t->id) % 32] = val;
+			t->ptr[id][idx] = val;
 		else
-			val = *t->ptr[(n + t->id) % 32];
+			val = t->ptr[id][idx];
+
+		val++;
 	}
 
 	return NULL;
@@ -975,7 +987,10 @@ test_fault_concurrent(int fd)
 	int n;
 
 	for (n = 0; n < 32; n++) {
-		ptr[n] = create_pointer(fd);
+		uint32_t sz = n << 19; /* 512KiB increments */
+
+		ptr[n] = create_pointer_size(fd, sz);
+		*ptr[n] = sz / sizeof(uint32_t); /* num_elems for convenience */
 	}
 
 	for (n = 0; n < 64; n++) {
@@ -987,9 +1002,8 @@ test_fault_concurrent(int fd)
 	for (n = 0; n < 64; n++)
 		pthread_join(thread[n].thread, NULL);
 
-	for (n = 0; n < 32; n++) {
-		munmap(ptr[n], OBJECT_SIZE);
-	}
+	for (n = 0; n < 32; n++)
+		munmap(ptr[n], *ptr[n] * sizeof(uint32_t));
 }
 
 static void
-- 
2.23.0



More information about the igt-dev mailing list