[Intel-gfx] [PATCH i-g-t] tests/gem_fence_thrash.c: Reduce memory usage
Morton, Derek J
derek.j.morton at intel.com
Tue Jun 23 08:32:21 PDT 2015
>
>
>-----Original Message-----
>From: Chris Wilson [mailto:chris at chris-wilson.co.uk]
>Sent: Tuesday, June 23, 2015 4:08 PM
>To: Morton, Derek J
>Cc: intel-gfx at lists.freedesktop.org; Wood, Thomas
>Subject: Re: [Intel-gfx] [PATCH i-g-t] tests/gem_fence_thrash.c: Reduce memory usage
>
>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.
Thanks for the suggestion. I did not realise that was the case. It simplifies the patch a lot. Will submit a new version.
//Derek
>-Chris
>
>--
>Chris Wilson, Intel Open Source Technology Centre
>
More information about the Intel-gfx
mailing list