All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t v2] tests/gem_fence_thrash.c: Reduce memory usage
@ 2015-06-23 15:45 Derek Morton
  2015-06-23 15:58 ` Chris Wilson
  0 siblings, 1 reply; 3+ messages in thread
From: Derek Morton @ 2015-06-23 15:45 UTC (permalink / raw)
  To: intel-gfx; +Cc: thomas.wood

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: Derek Morton <derek.j.morton@intel.com>
---
 tests/gem_fence_thrash.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/gem_fence_thrash.c b/tests/gem_fence_thrash.c
index 6447e13..e2ed024 100644
--- a/tests/gem_fence_thrash.c
+++ b/tests/gem_fence_thrash.c
@@ -63,7 +63,7 @@ static void *
 bo_create (int fd, int tiling)
 {
 	void *ptr;
-	int handle;
+	uint32_t handle;
 
 	handle = gem_create(fd, OBJECT_SIZE);
 
@@ -80,6 +80,7 @@ bo_create (int fd, int tiling)
 
 	/* XXX: mmap_gtt pulls the bo into the GTT read domain. */
 	gem_sync(fd, handle);
+	gem_close(fd, handle);
 
 	return ptr;
 }
@@ -188,6 +189,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);
+
+		free(threads);
 	} else {
 		void *(*func)(void *) = f;
 		igt_assert(func(&t) == (void *)0);
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH i-g-t v2] tests/gem_fence_thrash.c: Reduce memory usage
  2015-06-23 15:45 [PATCH i-g-t v2] tests/gem_fence_thrash.c: Reduce memory usage Derek Morton
@ 2015-06-23 15:58 ` Chris Wilson
  2015-06-23 16:11   ` Chris Wilson
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Wilson @ 2015-06-23 15:58 UTC (permalink / raw)
  To: Derek Morton; +Cc: intel-gfx, thomas.wood

On Tue, Jun 23, 2015 at 04:45:52PM +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 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.

Urm. We allocate the surfaces from the test.fd, and we close(test.fd) at
the end of every test. We munmap all the pointers (except bo_copy has a
leak of the mmaps), so we should not have been leaking any bo between
tests. This should not be improving the memory footprint at all, but
suggests something is wrong in your kernel.

Did you track the kernel objects throughout the test runs?
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH i-g-t v2] tests/gem_fence_thrash.c: Reduce memory usage
  2015-06-23 15:58 ` Chris Wilson
@ 2015-06-23 16:11   ` Chris Wilson
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Wilson @ 2015-06-23 16:11 UTC (permalink / raw)
  To: Derek Morton, intel-gfx, thomas.wood

On Tue, Jun 23, 2015 at 04:58:29PM +0100, Chris Wilson wrote:
> On Tue, Jun 23, 2015 at 04:45:52PM +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 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.
> 
> Urm. We allocate the surfaces from the test.fd, and we close(test.fd) at
> the end of every test. We munmap all the pointers (except bo_copy has a
> leak of the mmaps), so we should not have been leaking any bo between
> tests. This should not be improving the memory footprint at all, but
> suggests something is wrong in your kernel.

Spotted it, _bo_write_verify inflates the memory footprint by 1000%.
Ok, all's happy now!

You also want

diff --git a/tests/gem_fence_thrash.c b/tests/gem_fence_thrash.c
index 6447e13..cada526 100644
--- a/tests/gem_fence_thrash.c
+++ b/tests/gem_fence_thrash.c
@@ -100,6 +100,9 @@ bo_copy (void *_arg)
                sched_yield ();
        }
 
+       munmap(a, OBJECT_SIZE);
+       munmap(b, OBJECT_SIZE);
+
        return NULL;
 }
 
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-23 16:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-23 15:45 [PATCH i-g-t v2] tests/gem_fence_thrash.c: Reduce memory usage Derek Morton
2015-06-23 15:58 ` Chris Wilson
2015-06-23 16:11   ` Chris Wilson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.