[igt-dev] [PATCH i-g-t] i915/gem_userptr_blits: Only mlock the memfd once, not the arena

Chris Wilson chris at chris-wilson.co.uk
Tue Jan 15 20:55:21 UTC 2019


We multiply the memfd 64k to create a 2G arena which we then attempt to
write into after marking read-only. Howver, when it comes to unlock the
arena after the test, performance tanks as the kernel tries to resolve
the 64k repeated mappings onto the same set of pages. (Must not be a
very common operation!) We can get away with just mlocking the backing
store to prevent its eviction, which should prevent the arena mapping
from being freed as well.

References: https://bugs.freedesktop.org/show_bug.cgi?id=108887
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 tests/i915/gem_userptr_blits.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c
index 909dd19df..c4e60ba92 100644
--- a/tests/i915/gem_userptr_blits.c
+++ b/tests/i915/gem_userptr_blits.c
@@ -1124,7 +1124,7 @@ static void test_readonly(int i915)
 		*(uint32_t *)(space + offset) = offset;
 	}
 	igt_assert_eq_u32(*(uint32_t *)pages, (uint32_t)(total - sz));
-	igt_assert(mlock(space, total) == 0);
+	igt_assert(mlock(pages, sz) == 0);
 	close(memfd);
 
 	/* Check we can create a normal userptr bo wrapping the wrapper */
@@ -1176,6 +1176,7 @@ static void test_readonly(int i915)
 	}
 	igt_waitchildren();
 
+	munlock(pages, sz);
 	munmap(space, total);
 	munmap(pages, sz);
 }
-- 
2.20.1



More information about the igt-dev mailing list