All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] tests/gem_cpu_reloc: Fix gem_cpu_reloc OOM failure
@ 2015-05-12 12:09 Derek Morton
  2015-05-13 11:06 ` Gore, Tim
  2015-05-13 16:41 ` Thomas Wood
  0 siblings, 2 replies; 3+ messages in thread
From: Derek Morton @ 2015-05-12 12:09 UTC (permalink / raw)
  To: intel-gfx; +Cc: thomas.wood

On android with small memory footprints gem_cpu_reloc can fail
due to OOM.

Refactor gem_cpu_reloc into 2 tests, a basic test which performs
10 relocations and a full test which skips if there is insufficient
memory.

Changed the memory required test to better estimate the actual
RAM used.

Signed-off-by: Derek Morton <derek.j.morton@intel.com>
---
 tests/gem_cpu_reloc.c | 48 ++++++++++++++++++++++++++++++++++++------------
 1 file changed, 36 insertions(+), 12 deletions(-)

diff --git a/tests/gem_cpu_reloc.c b/tests/gem_cpu_reloc.c
index 058089c..2f5fc60 100644
--- a/tests/gem_cpu_reloc.c
+++ b/tests/gem_cpu_reloc.c
@@ -159,16 +159,14 @@ uint32_t gen8_batch[] = {
 uint32_t *batch = gen6_batch;
 uint32_t batch_size = sizeof(gen6_batch);
 
-igt_simple_main
+void run_test(int fd, int count)
 {
 	const uint32_t hang[] = {-1, -1, -1, -1};
 	const uint32_t end[] = {MI_BATCH_BUFFER_END, 0};
-	uint64_t aper_size;
 	uint32_t noop;
 	uint32_t *handles;
-	int fd, i, count;
+	int i;
 
-	fd = drm_open_any();
 	noop = intel_get_drm_devid(fd);
 
 	use_blt = 0;
@@ -180,13 +178,6 @@ igt_simple_main
 		batch_size += 2 * 4;
 	}
 
-	aper_size = gem_mappable_aperture_size();
-	count = aper_size / 4096 * 2;
-	if (igt_run_in_simulation())
-		count = 10;
-
-	intel_require_memory(1+count, 4096, CHECK_RAM);
-
 	handles = malloc (count * sizeof(uint32_t));
 	igt_assert(handles);
 
@@ -246,6 +237,39 @@ igt_simple_main
 		igt_progress("gem_cpu_reloc: ", 2*count+i, 3*count);
 	}
 
-	igt_info("Test suceeded, cleanup up - this might take a while.\n");
+	igt_info("Subtest suceeded, cleanup up - this might take a while.\n");
+	for (i = 0; i < count; i++) {
+		gem_close(fd, handles[i]);
+	}
+	gem_close(fd, noop);
+	free(handles);
+}
+
+igt_main
+{
+	uint64_t aper_size;
+	int fd, count;
+
+	igt_fixture {
+		fd = drm_open_any();
+	}
+
+	igt_subtest("basic") {
+		run_test (fd, 10);
+	}
+
+	igt_skip_on_simulation();
+
+	igt_subtest("full") {
+		aper_size = gem_mappable_aperture_size();
+		count = aper_size / 4096 * 2;
+
+		/* count + 2 (noop & bad) buffers. A gem object appears to
+                   require about 2kb + buffer + kernel overhead */
+		intel_require_memory(2+count, 2048+4096, CHECK_RAM);
+
+		run_test (fd, count);
+	}
+
 	close(fd);
 }
-- 
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] tests/gem_cpu_reloc: Fix gem_cpu_reloc OOM failure
  2015-05-12 12:09 [PATCH i-g-t] tests/gem_cpu_reloc: Fix gem_cpu_reloc OOM failure Derek Morton
@ 2015-05-13 11:06 ` Gore, Tim
  2015-05-13 16:41 ` Thomas Wood
  1 sibling, 0 replies; 3+ messages in thread
From: Gore, Tim @ 2015-05-13 11:06 UTC (permalink / raw)
  To: Morton, Derek J, intel-gfx; +Cc: Wood, Thomas



> -----Original Message-----
> From: Morton, Derek J
> Sent: Tuesday, May 12, 2015 1:10 PM
> To: intel-gfx@lists.freedesktop.org
> Cc: Wood, Thomas; Gore, Tim; Morton, Derek J
> Subject: [PATCH i-g-t] tests/gem_cpu_reloc: Fix gem_cpu_reloc OOM failure
> 
> On android with small memory footprints gem_cpu_reloc can fail due to
> OOM.
> 
> Refactor gem_cpu_reloc into 2 tests, a basic test which performs
> 10 relocations and a full test which skips if there is insufficient memory.
> 
> Changed the memory required test to better estimate the actual RAM used.
> 
> Signed-off-by: Derek Morton <derek.j.morton@intel.com>
> ---
>  tests/gem_cpu_reloc.c | 48 ++++++++++++++++++++++++++++++++++++-
> -----------
>  1 file changed, 36 insertions(+), 12 deletions(-)
> 
> diff --git a/tests/gem_cpu_reloc.c b/tests/gem_cpu_reloc.c index
> 058089c..2f5fc60 100644
> --- a/tests/gem_cpu_reloc.c
> +++ b/tests/gem_cpu_reloc.c
> @@ -159,16 +159,14 @@ uint32_t gen8_batch[] = {  uint32_t *batch =
> gen6_batch;  uint32_t batch_size = sizeof(gen6_batch);
> 
> -igt_simple_main
> +void run_test(int fd, int count)
>  {
>  	const uint32_t hang[] = {-1, -1, -1, -1};
>  	const uint32_t end[] = {MI_BATCH_BUFFER_END, 0};
> -	uint64_t aper_size;
>  	uint32_t noop;
>  	uint32_t *handles;
> -	int fd, i, count;
> +	int i;
> 
> -	fd = drm_open_any();
>  	noop = intel_get_drm_devid(fd);
> 
>  	use_blt = 0;
> @@ -180,13 +178,6 @@ igt_simple_main
>  		batch_size += 2 * 4;
>  	}
> 
> -	aper_size = gem_mappable_aperture_size();
> -	count = aper_size / 4096 * 2;
> -	if (igt_run_in_simulation())
> -		count = 10;
> -
> -	intel_require_memory(1+count, 4096, CHECK_RAM);
> -
>  	handles = malloc (count * sizeof(uint32_t));
>  	igt_assert(handles);
> 
> @@ -246,6 +237,39 @@ igt_simple_main
>  		igt_progress("gem_cpu_reloc: ", 2*count+i, 3*count);
>  	}
> 
> -	igt_info("Test suceeded, cleanup up - this might take a while.\n");
> +	igt_info("Subtest suceeded, cleanup up - this might take a while.\n");
> +	for (i = 0; i < count; i++) {
> +		gem_close(fd, handles[i]);
> +	}
> +	gem_close(fd, noop);
> +	free(handles);
> +}
> +
> +igt_main
> +{
> +	uint64_t aper_size;
> +	int fd, count;
> +
> +	igt_fixture {
> +		fd = drm_open_any();
> +	}
> +
> +	igt_subtest("basic") {
> +		run_test (fd, 10);
> +	}
> +
> +	igt_skip_on_simulation();
> +
> +	igt_subtest("full") {
> +		aper_size = gem_mappable_aperture_size();
> +		count = aper_size / 4096 * 2;
> +
> +		/* count + 2 (noop & bad) buffers. A gem object appears to
> +                   require about 2kb + buffer + kernel overhead */
> +		intel_require_memory(2+count, 2048+4096, CHECK_RAM);
> +
> +		run_test (fd, count);
> +	}
> +
>  	close(fd);
>  }
> --
> 1.9.1

Works for me. This follows the pattern we have been using for other tests
that cannot run on low memory systems.

Reviewed-by: Tim Gore <tim.gore@intel.com>
_______________________________________________
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] tests/gem_cpu_reloc: Fix gem_cpu_reloc OOM failure
  2015-05-12 12:09 [PATCH i-g-t] tests/gem_cpu_reloc: Fix gem_cpu_reloc OOM failure Derek Morton
  2015-05-13 11:06 ` Gore, Tim
@ 2015-05-13 16:41 ` Thomas Wood
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Wood @ 2015-05-13 16:41 UTC (permalink / raw)
  To: Derek Morton; +Cc: Intel Graphics Development

On 12 May 2015 at 13:09, Derek Morton <derek.j.morton@intel.com> wrote:
> On android with small memory footprints gem_cpu_reloc can fail
> due to OOM.
>
> Refactor gem_cpu_reloc into 2 tests, a basic test which performs
> 10 relocations and a full test which skips if there is insufficient
> memory.
>
> Changed the memory required test to better estimate the actual
> RAM used.
>
> Signed-off-by: Derek Morton <derek.j.morton@intel.com>
> ---
>  tests/gem_cpu_reloc.c | 48 ++++++++++++++++++++++++++++++++++++------------
>  1 file changed, 36 insertions(+), 12 deletions(-)
>
> diff --git a/tests/gem_cpu_reloc.c b/tests/gem_cpu_reloc.c
> index 058089c..2f5fc60 100644
> --- a/tests/gem_cpu_reloc.c
> +++ b/tests/gem_cpu_reloc.c
> @@ -159,16 +159,14 @@ uint32_t gen8_batch[] = {
>  uint32_t *batch = gen6_batch;
>  uint32_t batch_size = sizeof(gen6_batch);
>
> -igt_simple_main
> +void run_test(int fd, int count)

This function should be marked static.


>  {
>         const uint32_t hang[] = {-1, -1, -1, -1};
>         const uint32_t end[] = {MI_BATCH_BUFFER_END, 0};
> -       uint64_t aper_size;
>         uint32_t noop;
>         uint32_t *handles;
> -       int fd, i, count;
> +       int i;
>
> -       fd = drm_open_any();
>         noop = intel_get_drm_devid(fd);
>
>         use_blt = 0;
> @@ -180,13 +178,6 @@ igt_simple_main
>                 batch_size += 2 * 4;
>         }
>
> -       aper_size = gem_mappable_aperture_size();
> -       count = aper_size / 4096 * 2;
> -       if (igt_run_in_simulation())
> -               count = 10;
> -
> -       intel_require_memory(1+count, 4096, CHECK_RAM);
> -
>         handles = malloc (count * sizeof(uint32_t));
>         igt_assert(handles);
>
> @@ -246,6 +237,39 @@ igt_simple_main
>                 igt_progress("gem_cpu_reloc: ", 2*count+i, 3*count);
>         }
>
> -       igt_info("Test suceeded, cleanup up - this might take a while.\n");
> +       igt_info("Subtest suceeded, cleanup up - this might take a while.\n");
> +       for (i = 0; i < count; i++) {
> +               gem_close(fd, handles[i]);
> +       }
> +       gem_close(fd, noop);
> +       free(handles);
> +}
> +
> +igt_main
> +{
> +       uint64_t aper_size;
> +       int fd, count;
> +
> +       igt_fixture {
> +               fd = drm_open_any();
> +       }
> +
> +       igt_subtest("basic") {
> +               run_test (fd, 10);
> +       }
> +
> +       igt_skip_on_simulation();
> +
> +       igt_subtest("full") {
> +               aper_size = gem_mappable_aperture_size();
> +               count = aper_size / 4096 * 2;
> +
> +               /* count + 2 (noop & bad) buffers. A gem object appears to
> +                   require about 2kb + buffer + kernel overhead */
> +               intel_require_memory(2+count, 2048+4096, CHECK_RAM);
> +
> +               run_test (fd, count);
> +       }
> +
>         close(fd);

This should be inside an igt_fixture block, otherwise fd will be
uninitialised when listing subtests.


>  }
> --
> 1.9.1
>
_______________________________________________
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

end of thread, other threads:[~2015-05-13 16:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-12 12:09 [PATCH i-g-t] tests/gem_cpu_reloc: Fix gem_cpu_reloc OOM failure Derek Morton
2015-05-13 11:06 ` Gore, Tim
2015-05-13 16:41 ` Thomas Wood

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.