diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-06-04 08:48:33 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-06-04 09:04:38 +0100 |
commit | d2a810ed2d6d1aab310cb6c16131fe7a0e436bba (patch) | |
tree | 2580a559f42a2b63eb95aa392def05e216bde417 | |
parent | ce6adbee8fef10186e6ac184828e99d1ebc7e908 (diff) |
igt/gem_ctx_thrash: Scale estimated usage by execlists.num_engines
Since with execlists we use a context per-engine, we consume a lot more
space than we were currently estimating. Enough to hit oom on some
machines.
References: https://bugs.freedesktop.org/show_bug.cgi?id=94145
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | tests/gem_ctx_thrash.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/tests/gem_ctx_thrash.c b/tests/gem_ctx_thrash.c index 46b41ced..9f20b694 100644 --- a/tests/gem_ctx_thrash.c +++ b/tests/gem_ctx_thrash.c @@ -41,7 +41,23 @@ static void xchg_int(void *array, unsigned i, unsigned j) igt_swap(A[i], A[j]); } -static unsigned get_num_contexts(int fd) +static bool has_execlists(void) +{ + FILE *file; + bool enabled = false; + + file = fopen("/sys/module/i915/parameters/enable_execlists", "r"); + if (file) { + int value; + if (fscanf(file, "%d", &value) == 1) + enabled = value != 0; + fclose(file); + } + + return enabled; +} + +static unsigned get_num_contexts(int fd, int num_engines) { uint64_t ggtt_size; unsigned size; @@ -49,7 +65,13 @@ static unsigned get_num_contexts(int fd) /* Compute the number of contexts we can allocate to fill the GGTT */ ggtt_size = gem_global_aperture_size(fd); + size = 64 << 10; /* Most gen require at least 64k for ctx */ + if (has_execlists()) { + size *= 2; /* ringbuffer as well */ + if (num_engines) /* one per engine with execlists */ + size *= num_engines; + } count = 3 * (ggtt_size / size) / 2; igt_info("Creating %lld contexts (assuming of size %lld)\n", @@ -95,7 +117,6 @@ static void single(const char *name, bool all_engines) fd = drm_open_driver_master(DRIVER_INTEL); gen = intel_gen(intel_get_drm_devid(fd)); - num_ctx = get_num_contexts(fd); num_engines = 0; if (all_engines) { @@ -121,6 +142,8 @@ static void single(const char *name, bool all_engines) } else engines[num_engines++] = 0; + num_ctx = get_num_contexts(fd, num_engines); + size = ALIGN(num_ctx * sizeof(uint32_t), 4096); scratch = gem_create(fd, ALIGN(num_ctx * sizeof(uint32_t), 4096)); gem_set_caching(fd, scratch, I915_CACHING_CACHED); @@ -218,7 +241,6 @@ static void processes(void) int fd, *fds; fd = drm_open_driver(DRIVER_INTEL); - num_ctx = get_num_contexts(fd); num_engines = 0; for (e = intel_execution_engines; e->name; e++) { @@ -239,6 +261,8 @@ static void processes(void) break; } + num_ctx = get_num_contexts(fd, num_engines); + /* tweak rlimits to allow us to create this many files */ igt_assert(getrlimit(RLIMIT_NOFILE, &rlim) == 0); if (rlim.rlim_cur < ALIGN(num_ctx + 1024, 1024)) { @@ -337,7 +361,7 @@ static void threads(void) struct thread data; data.fd = drm_open_driver_render(DRIVER_INTEL); - data.num_ctx = get_num_contexts(data.fd); + data.num_ctx = get_num_contexts(data.fd, false); data.all_ctx = malloc(data.num_ctx * sizeof(uint32_t)); igt_assert(data.all_ctx); for (unsigned n = 0; n < data.num_ctx; n++) |