diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2017-12-12 21:24:52 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2017-12-13 11:34:01 +0000 |
commit | 4112f30aedbb252bf8cdd27dbba485c0458faca7 (patch) | |
tree | 2dbd0a32f465e3e6f0085cdf3deb9a49cb6164d9 /tests | |
parent | 10c2c640b7219fca60cefc53ba1ca4669832b218 (diff) |
igt/gem_shrink: Exercise allocations in the middle of execbuf under oom-pressure
Having discovered that we would encounter an indefinite wait in the
shrinker within execbuf/request construction, try to exercise that path
by emitting lots of execbuf with fences (which require allocation inside
request construction) whilst under severe mempressure.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gem_shrink.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/gem_shrink.c b/tests/gem_shrink.c index 06f7a301..3d33453a 100644 --- a/tests/gem_shrink.c +++ b/tests/gem_shrink.c @@ -36,6 +36,8 @@ #define MADV_FREE 8 #endif +static unsigned int engines[16], nengine; + static void get_pages(int fd, uint64_t alloc) { uint32_t handle = gem_create(fd, alloc); @@ -150,6 +152,39 @@ static void execbufN(int fd, uint64_t alloc) munmap(obj, obj_size); } +static void execbufX(int fd, uint64_t alloc) +{ + const uint32_t bbe = MI_BATCH_BUFFER_END; + struct drm_i915_gem_exec_object2 *obj; + struct drm_i915_gem_execbuffer2 execbuf; + int count = alloc >> 20; + uint64_t obj_size; + + obj = __gem_calloc(fd, alloc + 1, sizeof(*obj), &obj_size); + memset(&execbuf, 0, sizeof(execbuf)); + + obj[count].handle = gem_create(fd, 4096); + gem_write(fd, obj[count].handle, 0, &bbe, sizeof(bbe)); + + for (int i = 1; i <= count; i++) { + int j = count - i; + + obj[j+1].flags = 0; + + obj[j].handle = gem_create(fd, 1 << 20); + obj[j].flags = EXEC_OBJECT_WRITE; + + execbuf.buffers_ptr = to_user_pointer(&obj[j]); + execbuf.buffer_count = i + 1; + execbuf.flags = engines[j % nengine]; + gem_execbuf(fd, &execbuf); + } + + for (int i = 0; i <= count; i++) + gem_madvise(fd, obj[i].handle, I915_MADV_DONTNEED); + munmap(obj, obj_size); +} + static void hang(int fd, uint64_t alloc) { const uint32_t bbe = MI_BATCH_BUFFER_END; @@ -344,6 +379,7 @@ igt_main { "mmap-cpu", mmap_cpu }, { "execbuf1", execbuf1 }, { "execbufN", execbufN }, + { "execbufX", execbufX }, { "hang", hang }, { NULL }, }; @@ -364,6 +400,8 @@ igt_main igt_fixture { uint64_t mem_size = intel_get_total_ram_mb(); + unsigned int engine; + int fd; /* Spawn enough processes to use all memory, but each only * uses half the available mappable aperture ~128MiB. @@ -379,6 +417,16 @@ igt_main intel_require_memory(num_processes, alloc_size, CHECK_SWAP | CHECK_RAM); + + fd = drm_open_driver(DRIVER_INTEL); + igt_require_gem(fd); + + nengine = 0; + for_each_engine(fd, engine) + engines[nengine++] = engine; + igt_require(nengine); + + close(fd); } igt_subtest("reclaim") |