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 <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2015-01-06 09:59:47 +00:00
parent eaa1e8e127
commit 25cf0551c7

View File

@ -28,6 +28,7 @@
#include <pthread.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/resource.h>
#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++) {