Commit 471ebbed authored by Derek Morton's avatar Derek Morton Committed by Chris Wilson

igt/gem_fence_thrash: Reduce memory usage

On android platforms with 1Gb RAM gem_fence_thrash was failing
with an out of memory error.
This patch causes gem_close() to be called when a handle is
no longer required rather than relying on the cleanup when
the fd is closed. This greatly improves the memory footprint
of the test allowing it to run on 1Mb systems.

Also fixed a leak of the 'threads' variable.

v2: Simplified as per Chris Wilson's suggestion.
Signed-off-by: default avatarDerek Morton <>
[ickle: fix mmap leak from bo_copy()]
Reviewed-by: Chris Wilson's avatarChris Wilson <>
parent 154192a6
......@@ -62,8 +62,8 @@ struct test {
static void *
bo_create (int fd, int tiling)
uint32_t handle;
void *ptr;
int handle;
handle = gem_create(fd, OBJECT_SIZE);
......@@ -78,8 +78,8 @@ bo_create (int fd, int tiling)
ptr = gem_mmap(fd, handle, OBJECT_SIZE, PROT_READ | PROT_WRITE);
/* XXX: mmap_gtt pulls the bo into the GTT read domain. */
gem_sync(fd, handle);
gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
gem_close(fd, handle);
return ptr;
......@@ -100,6 +100,9 @@ bo_copy (void *_arg)
sched_yield ();
munmap(a, OBJECT_SIZE);
munmap(b, OBJECT_SIZE);
return NULL;
......@@ -188,6 +191,8 @@ static int run_test(int threads_per_fence, void *f, int tiling,
for (n = 0; n < num_threads; n++)
pthread_join (threads[n], NULL);
} else {
void *(*func)(void *) = f;
igt_assert(func(&t) == (void *)0);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment