summaryrefslogtreecommitdiff
path: root/tests/i915/gem_shrink.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-08-09 14:17:20 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2019-08-13 16:40:06 +0100
commit5b41a9e291bb993a7167595115f2876078b31caa (patch)
treebcfa5df44ae252fd6fe1e120b78bbbda7e9c8e76 /tests/i915/gem_shrink.c
parentbfd7241fa594d772e1414574e09d1e4d9fa6643a (diff)
i915/gem_shrink: Make some pages dirty
Trying to hit a deadlock for invalidating dirty userptr pages (via kcompactd). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Andi Shyti <andi.shyti@intel.com>
Diffstat (limited to 'tests/i915/gem_shrink.c')
-rw-r--r--tests/i915/gem_shrink.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/tests/i915/gem_shrink.c b/tests/i915/gem_shrink.c
index 037ff005..3db754f5 100644
--- a/tests/i915/gem_shrink.c
+++ b/tests/i915/gem_shrink.c
@@ -45,6 +45,13 @@ static void get_pages(int fd, uint64_t alloc)
gem_madvise(fd, handle, I915_MADV_DONTNEED);
}
+static void get_pages_dirty(int fd, uint64_t alloc)
+{
+ uint32_t handle = gem_create(fd, alloc);
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
+ gem_madvise(fd, handle, I915_MADV_DONTNEED);
+}
+
static void pwrite_(int fd, uint64_t alloc)
{
uint32_t tmp;
@@ -214,7 +221,8 @@ static void hang(int fd, uint64_t alloc)
munmap(obj, obj_size);
}
-static void userptr(int fd, uint64_t alloc)
+static void userptr(int fd, uint64_t alloc, unsigned int flags)
+#define UDIRTY (1 << 0)
{
struct local_i915_gem_userptr userptr;
void *ptr;
@@ -231,7 +239,11 @@ static void userptr(int fd, uint64_t alloc)
userptr.user_ptr = to_user_pointer(ptr);
do_ioctl(fd, LOCAL_IOCTL_I915_GEM_USERPTR, &userptr);
- gem_set_domain(fd, userptr.handle, I915_GEM_DOMAIN_GTT, 0);
+ if (flags & UDIRTY)
+ gem_set_domain(fd, userptr.handle,
+ I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
+ else
+ gem_set_domain(fd, userptr.handle, I915_GEM_DOMAIN_GTT, 0);
madvise(ptr, alloc, MADV_FREE);
}
@@ -273,7 +285,8 @@ static void leak(int fd, uint64_t alloc)
#define SOLO 1
#define USERPTR 2
-#define OOM 4
+#define USERPTR_DIRTY 4
+#define OOM 8
static void run_test(int nchildren, uint64_t alloc,
void (*func)(int, uint64_t), unsigned flags)
@@ -309,7 +322,20 @@ static void run_test(int nchildren, uint64_t alloc,
igt_until_timeout(timeout) {
int fd = drm_open_driver(DRIVER_INTEL);
for (int pass = 0; pass < nchildren; pass++)
- userptr(fd, alloc);
+ userptr(fd, alloc, 0);
+ close(fd);
+ }
+ }
+ nchildren = (nchildren + 1)/2;
+ }
+
+ if (flags & USERPTR_DIRTY) {
+ igt_require(has_userptr());
+ igt_fork(child, (nchildren + 1)/2) {
+ igt_until_timeout(timeout) {
+ int fd = drm_open_driver(DRIVER_INTEL);
+ for (int pass = 0; pass < nchildren; pass++)
+ userptr(fd, alloc, UDIRTY);
close(fd);
}
}
@@ -373,6 +399,7 @@ igt_main
void (*func)(int, uint64_t);
} tests[] = {
{ "get-pages", get_pages },
+ { "get-pages-dirty", get_pages_dirty },
{ "pwrite", pwrite_ },
{ "pread", pread_ },
{ "mmap-gtt", mmap_gtt },
@@ -390,6 +417,7 @@ igt_main
{ "-sanitycheck", SOLO },
{ "", 0 },
{ "-userptr", USERPTR },
+ { "-userptr-dirty", USERPTR | USERPTR_DIRTY },
{ "-oom", USERPTR | OOM },
{ NULL },
};