Skip to contentSkip to conversation

tests/gem_render_linear_blits: split into two subtests

PATCH Superseded [email protected] 2 participants 2 messages Feb 25, 2015

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tests/gem_render_linear_blits: split into two subtests

From: Tim Gore <[email protected]>

The gem_render_linear_blits test tends to get oom killed on low memory (< 4GB) Android systems. This is because the test tries to allocate (sysinfo.totalram * 9 / 10) in buffer objects and the remaining 10% of memory is not always enough for the Android system.
After a discussion with Chris Wilson I have split this test into a "basic" and an "apperture-thrash" subtest, in the same way as gem_linear_blits. The basic test uses just two buffer objects and the apperture-thrash test is skipped if there is insuffiecient memory.

v2: Following comment from Chris Wilson:
a) Remove the command line option for count.
b) Add a third subtest to ensure swap is tested

---
 tests/gem_render_linear_blits.c | 69 +++++++++++++++++++++++++----------------
 1 file changed, 43 insertions(+), 26 deletions(-)
tests/gem_render_linear_blits.c +43 -26
index 60ba831..cdb7c18 100644
@@ -80,18 +80,14 @@ check_bo(int fd, uint32_t handle, uint32_t val)
 	}
 }
 
-int main(int argc, char **argv)
+static void run_test (int fd, int count)
 {
 	drm_intel_bufmgr *bufmgr;
 	struct intel_batchbuffer *batch;
 	uint32_t *start_val;
 	drm_intel_bo **bo;
 	uint32_t start = 0;
-	int i, j, fd, count;
-
-	igt_simple_init(argc, argv);
-
-	fd = drm_open_any();
+	int i, j;
 
 	render_copy = igt_get_render_copyfunc(intel_get_drm_devid(fd));
 	igt_require(render_copy);
@@ -99,24 +95,6 @@ int main(int argc, char **argv)
 	bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
 	batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
 
-	count = 0;
-	if (igt_run_in_simulation())
-		count = 2;
-	if (argc > 1)
-		count = atoi(argv[1]);
-
-	if (count == 0)
-		count = 3 * gem_aperture_size(fd) / SIZE / 2;
-	else if (count < 2) {
-		igt_warn("count must be >= 2\n");
-		return 1;
-	}
-
-	if (count > intel_get_total_ram_mb() * 9 / 10) {
-		count = intel_get_total_ram_mb() * 9 / 10;
-		igt_info("not enough RAM to run test, reducing buffer count\n");
-	}
-
 	bo = malloc(sizeof(*bo)*count);
 	start_val = malloc(sizeof(*start_val)*count);
 
@@ -128,7 +106,7 @@ int main(int argc, char **argv)
 		gem_write(fd, bo[i]->handle, 0, linear, sizeof(linear));
 	}
 
-	igt_info("Verifying initialisation...\n");
+	igt_info("Verifying initialisation - %d buffers of %d bytes\n", count, SIZE);
 	for (i = 0; i < count; i++)
 		check_bo(fd, bo[i]->handle, start_val[i]);
 
@@ -153,7 +131,7 @@ int main(int argc, char **argv)
 		check_bo(fd, bo[i]->handle, start_val[i]);
 
 	if (igt_run_in_simulation())
-		return 0;
+		return;
 
 	igt_info("Cyclic blits, backward...\n");
 	for (i = 0; i < count * 4; i++) {
@@ -200,5 +178,44 @@ int main(int argc, char **argv)
 	for (i = 0; i < count; i++)
 		check_bo(fd, bo[i]->handle, start_val[i]);
 
+	/* release resources */
+	for (i = 0; i < count; i++) {
+	        drm_intel_bo_unreference(bo[i]);
+	}
+	intel_batchbuffer_free(batch);
+	drm_intel_bufmgr_destroy(bufmgr);
+}
+
+int main(int argc, char **argv)
+{
+	static int fd = 0;
+	int count=0;
+
+	igt_subtest_init(argc, argv);
+	igt_fixture {
+		fd = drm_open_any();
+	}
+
+	igt_subtest("basic") {
+		run_test(fd, 2);
+	}
+
+    /* the rest of the tests are too long for simulation */
+	igt_skip_on_simulation();
+
+	igt_subtest("apperture-thrash") {
+        	count = 3 * gem_aperture_size(fd) / SIZE / 2;
+		intel_require_memory(count, SIZE, CHECK_RAM);
+		run_test(fd, count);
+	}
+
+	igt_subtest("swap-thrash") {
+	        uint64_t swap_mb = intel_get_total_swap_mb();
+	        igt_require(swap_mb > 0);
+        	count = ((intel_get_avail_ram_mb() + (swap_mb / 2)) * 1024*1024) / SIZE;
+		intel_require_memory(count, SIZE, CHECK_RAM | CHECK_SWAP);
+		run_test(fd, count);
+	}
+
 	igt_exit();
 }
Signature · 6 lines
2.3.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 13 lines · On Wed, Feb 25, 2015 at 04:11:18PM +0000, [email protected] wrote:

From: Tim Gore <[email protected]>

The gem_render_linear_blits test tends to get oom killed on low memory (< 4GB) Android systems. This is because the test tries to allocate (sysinfo.totalram * 9 / 10) in buffer objects and the remaining 10% of memory is not always enough for the Android system.
After a discussion with Chris Wilson I have split this test into a "basic" and an "apperture-thrash" subtest, in the same way as gem_linear_blits. The basic test uses just two buffer objects and the apperture-thrash test is skipped if there is insuffiecient memory.

Quoted 5 lines

v2: Following comment from Chris Wilson:
a) Remove the command line option for count.
b) Add a third subtest to ensure swap is tested

Looks fine to me. Thomas may sweep in later and and fine tune the buffer count required to thrash swap, but it looks good to go as is. -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx