[Intel-gfx] [PATCH i-g-t] tests/gem_fence_thrash.c: Reduce memory usage
Chris Wilson
chris at chris-wilson.co.uk
Tue Jun 23 08:08:02 PDT 2015
On Tue, Jun 23, 2015 at 04:01:53PM +0100, Derek Morton wrote:
> 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 thread is
> finished with its handles 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.
>
> Signed-off-by: Derek Morton <derek.j.morton at intel.com>
> ---
> tests/gem_fence_thrash.c | 33 ++++++++++++++++++++++-----------
> 1 file changed, 22 insertions(+), 11 deletions(-)
>
> diff --git a/tests/gem_fence_thrash.c b/tests/gem_fence_thrash.c
> index 6447e13..bfb2e6d 100644
> --- a/tests/gem_fence_thrash.c
> +++ b/tests/gem_fence_thrash.c
> @@ -60,26 +60,25 @@ struct test {
> };
>
> static void *
> -bo_create (int fd, int tiling)
> +bo_create (int fd, int tiling, uint32_t *handle)
> {
> void *ptr;
> - int handle;
>
> - handle = gem_create(fd, OBJECT_SIZE);
> + *handle = gem_create(fd, OBJECT_SIZE);
>
> /* dirty cpu caches a bit ... */
> - ptr = gem_mmap__cpu(fd, handle, 0, OBJECT_SIZE, PROT_READ | PROT_WRITE);
> + ptr = gem_mmap__cpu(fd, *handle, 0, OBJECT_SIZE, PROT_READ | PROT_WRITE);
> igt_assert(ptr);
> memset(ptr, 0, OBJECT_SIZE);
> munmap(ptr, OBJECT_SIZE);
>
> - gem_set_tiling(fd, handle, tiling, 1024);
> + gem_set_tiling(fd, *handle, tiling, 1024);
>
> - ptr = gem_mmap(fd, handle, OBJECT_SIZE, PROT_READ | PROT_WRITE);
> + ptr = gem_mmap(fd, *handle, OBJECT_SIZE, PROT_READ | PROT_WRITE);
> igt_assert(ptr);
>
> /* XXX: mmap_gtt pulls the bo into the GTT read domain. */
> - gem_sync(fd, handle);
> + gem_sync(fd, *handle);
Just call gem_close(fd, handle); the mmap will hold the reference for
the test.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the Intel-gfx
mailing list