From 88bfe6ac417f3eb52e9915047ebf7443bc91c828 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 2 Apr 2016 16:37:20 +0100 Subject: igt/gem_shrink: Add pread/pwrite stress Signed-off-by: Chris Wilson --- tests/gem_shrink.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'tests/gem_shrink.c') diff --git a/tests/gem_shrink.c b/tests/gem_shrink.c index 43fc228e..0a4a192e 100644 --- a/tests/gem_shrink.c +++ b/tests/gem_shrink.c @@ -40,11 +40,29 @@ static void get_pages(int fd, uint64_t alloc) gem_madvise(fd, handle, I915_MADV_DONTNEED); } +static void pwrite_(int fd, uint64_t alloc) +{ + uint32_t tmp; + uint32_t handle = gem_create(fd, alloc); + for (int page = 0; page < alloc>>12; page++) + gem_write(fd, handle, (page + page % 4095) & ~3, &tmp, 4); + gem_madvise(fd, handle, I915_MADV_DONTNEED); +} + +static void pread_(int fd, uint64_t alloc) +{ + uint32_t tmp; + uint32_t handle = gem_create(fd, alloc); + for (int page = 0; page < alloc>>12; page++) + gem_read(fd, handle, (page + page % 4095) & ~3, &tmp, 4); + gem_madvise(fd, handle, I915_MADV_DONTNEED); +} + static void mmap_gtt(int fd, uint64_t alloc) { uint32_t handle = gem_create(fd, alloc); uint32_t *ptr = gem_mmap__gtt(fd, handle, alloc, PROT_WRITE); - for (int page = 0; page < alloc >>12; page++) + for (int page = 0; page < alloc>>12; page++) ptr[page<<10] = 0; munmap(ptr, alloc); gem_madvise(fd, handle, I915_MADV_DONTNEED); @@ -54,7 +72,7 @@ static void mmap_cpu(int fd, uint64_t alloc) { uint32_t handle = gem_create(fd, alloc); uint32_t *ptr = gem_mmap__cpu(fd, handle, 0, alloc, PROT_WRITE); - for (int page = 0; page < alloc >>12; page++) + for (int page = 0; page < alloc>>12; page++) ptr[page<<10] = 0; munmap(ptr, alloc); gem_madvise(fd, handle, I915_MADV_DONTNEED); @@ -165,6 +183,8 @@ igt_main void (*func)(int, uint64_t); } tests[] = { { "get-pages", get_pages }, + { "pwrite", pwrite_ }, + { "pread", pread_ }, { "mmap-gtt", mmap_gtt }, { "mmap-cpu", mmap_cpu }, { "execbuf1", execbuf1 }, -- cgit v1.2.3