From c46f3c341caebfbe114aaafa412173db419083e9 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 10 Apr 2016 20:44:58 +0100 Subject: igt/gem_concurrent_blit: Purge the libdrm caches before cloning When forking, the entire VM is cloned including the VMA backed by GEM objects from the libdrm buffer cache. This is not only slow, but can also cause the system to exceed the maximum number of VMA and premature test failure. Signed-off-by: Chris Wilson --- tests/gem_concurrent_all.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/tests/gem_concurrent_all.c b/tests/gem_concurrent_all.c index 10e535750942..b4b1e9ad4639 100644 --- a/tests/gem_concurrent_all.c +++ b/tests/gem_concurrent_all.c @@ -650,7 +650,8 @@ static int read_sysctl(const char *path) FILE *file = fopen(path, "r"); int max = 0; if (file) { - fscanf(file, "%d", &max); + if (fscanf(file, "%d", &max) != 1) + max = 0; /* silence! */ fclose(file); } return max; @@ -757,6 +758,27 @@ static void buffers_create(struct buffers *b) b->snoop = snoop_create_bo(b); } +static void buffers_reset(struct buffers *b, bool enable_reuse) +{ + buffers_destroy(b); + + igt_assert(b->count == 0); + igt_assert(b->tmp); + igt_assert(b->src); + igt_assert(b->dst); + + intel_batchbuffer_free(b->batch); + drm_intel_bufmgr_destroy(b->bufmgr); + + b->bufmgr = drm_intel_bufmgr_gem_init(fd, 4096); + igt_assert(b->bufmgr); + + if (enable_reuse) + drm_intel_bufmgr_gem_enable_reuse(b->bufmgr); + b->batch = intel_batchbuffer_alloc(b->bufmgr, devid); + igt_assert(b->batch); +} + static void buffers_fini(struct buffers *b) { if (b->bufmgr == NULL) @@ -1301,20 +1323,17 @@ static void __run_forked(struct buffers *buffers, do_hang do_hang_func) { - int _num_buffers = buffers->num_buffers; - - _num_buffers /= num_children; - _num_buffers += MIN_BUFFERS; - - buffers_destroy(buffers); + /* purge the libdrm caches before cloing the process */ + buffers_reset(buffers, true); igt_fork(child, num_children) { /* recreate process local variables */ fd = drm_open_driver(DRIVER_INTEL); - buffers_init(buffers, buffers->name, - buffers->create, buffers->mode, - buffers->size, _num_buffers, fd, true); + buffers->num_buffers /= num_children; + buffers->num_buffers += MIN_BUFFERS; + + buffers_reset(buffers, true); buffers_create(buffers); igt_interruptible(interrupt) { -- cgit v1.2.3