From 25cf0551c7d210c8c085c109891dc97a2cc61e27 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 6 Jan 2015 09:59:47 +0000 Subject: [PATCH] igt/gem_ctx_thrash: Tweak resource limits On some systems (ok, most systems!) we may need to enlarge the allowed number of open files in order to create enough fd to fill the aperture. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=87572 Signed-off-by: Chris Wilson --- tests/gem_ctx_thrash.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/gem_ctx_thrash.c b/tests/gem_ctx_thrash.c index f9f6faa4..5c272338 100644 --- a/tests/gem_ctx_thrash.c +++ b/tests/gem_ctx_thrash.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "ioctl_wrappers.h" #include "igt_aux.h" @@ -140,6 +141,7 @@ processes(void) { int *all_fds; uint64_t aperture; + struct rlimit rlim; int ppgtt_mode; int ctx_size; int obj_size; @@ -165,6 +167,16 @@ processes(void) igt_info("Creating %d contexts (assuming of size %d)\n", num_ctx, ctx_size); intel_require_memory(num_ctx, ctx_size, CHECK_RAM | CHECK_SWAP); + + /* 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)) { + rlim.rlim_cur = ALIGN(num_ctx + 1024, 1024); + if (rlim.rlim_cur > rlim.rlim_max) + rlim.rlim_max = rlim.rlim_cur; + igt_assert(setrlimit(RLIMIT_NOFILE, &rlim) == 0); + } + all_fds = malloc(num_ctx * sizeof(int)); igt_assert(all_fds); for (n = 0; n < num_ctx; n++) {