[igt-dev] [RFC i-g-t 7/7] tests/i915/svm: Add stress test

Niranjana Vishwanathapura niranjana.vishwanathapura at intel.com
Fri Dec 13 21:54:29 UTC 2019


Run multiple processes in parallel each running a number of random
tests. Make number of processes and number of tests to run configurable.

Usage:
./i915_svm_basic --stress
./i915_svm_basic -s 0x00xxyyzz
where,
xx = delay b/w tests
yy = number of tests each process should run
zz = number of proccesses to run in parallel

Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
Cc: Jon Bloomfield <jon.bloomfield at intel.com>
Cc: Daniel Vetter <daniel.vetter at intel.com>
Cc: Sudeep Dutt <sudeep.dutt at intel.com>
Signed-off-by: Vanshidhar Konda <vanshidhar.r.konda at intel.com>
Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura at intel.com>
---
 tests/i915/i915_svm_basic.c | 81 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 79 insertions(+), 2 deletions(-)

diff --git a/tests/i915/i915_svm_basic.c b/tests/i915/i915_svm_basic.c
index 568ee321..e8ff671d 100644
--- a/tests/i915/i915_svm_basic.c
+++ b/tests/i915/i915_svm_basic.c
@@ -600,7 +600,41 @@ static void run_sys(int fd, uint32_t size, bool migrate, bool copy,
 	igt_waitchildren();
 }
 
-igt_main
+static uint8_t stress_num_child = 2;
+static uint8_t stress_iters = 2;
+static uint8_t stress_delay = 2;
+static bool stress;
+
+static int opt_handler(int opt, int opt_index, void *data)
+{
+	uint32_t tmp;
+
+	switch (opt) {
+	case 's':
+		stress = true;
+		if (optarg) {
+			tmp = strtoul(optarg, NULL, 0);
+			stress_num_child = tmp & 0xff;
+			stress_iters = (tmp & 0x0000ff00) >> 8;
+			stress_delay = (tmp & 0x00ff0000) >> 16;
+		}
+		if (!stress_num_child || !stress_iters)
+			return IGT_OPT_HANDLER_ERROR;
+		break;
+	default:
+		return IGT_OPT_HANDLER_ERROR;
+	}
+
+	return IGT_OPT_HANDLER_SUCCESS;
+}
+
+const char *help_str = "  --stress|-s\t\tRun the stress test.\n";
+static struct option long_options[] = {
+	{"stress", 0, 0, 's'},
+	{ NULL, 0, 0, 0 }
+};
+
+igt_main_args("s:", long_options, help_str, opt_handler, NULL)
 {
 	struct {
 		const char *name;
@@ -685,6 +719,49 @@ igt_main
 		def_size = DEFAULT_BUFF_SIZE;
 	}
 
+	if (stress) {
+		igt_subtest_f("stress") {
+			igt_fork(child, stress_num_child) {
+				uint32_t num_sys_tests, num_rt_tests;
+				uint32_t i, n, type, size;
+				bool migrate;
+
+				srand(__INT_MAX__);
+				num_sys_tests = ARRAY_SIZE(sys_tests);
+				num_rt_tests = ARRAY_SIZE(rt_tests);
+
+				for (i = 0; i < stress_iters; i++) {
+					svm_info("Running iter %d\n", i + 1);
+					type = rand() % 2;
+					if (type) {
+						n = rand() % num_sys_tests;
+						s = &sys_tests[n];
+						migrate = has_lmem ? s->migrate : false;
+						size = s->size ? : def_size;
+
+						svm_info("Running test %s\n", s->name);
+						run_sys(fd, size, migrate, s->copy,
+							s->alloc_type, s->unbind,
+							s->num_ctxts, 0);
+					} else {
+						n = rand() % num_rt_tests;
+						r = &rt_tests[n];
+						migrate = has_lmem ? r->migrate : false;
+						size = r->size ? : def_size;
+
+						svm_info("Running test %s\n", r->name);
+						run_rt(fd, size, migrate, r->copy, r->bind,
+						       r->unbind, r->num_ctxts, r->mmap, 0);
+					}
+					if (stress_delay)
+						sleep(stress_delay);
+				}
+			}
+			igt_waitchildren();
+		}
+		goto out;
+	}
+
 	/* Below are System (sys) allocator tests */
 	for (idx = 0, s = sys_tests; idx < ARRAY_SIZE(sys_tests); idx++, s++) {
 		bool migrate = has_lmem ? s->migrate : false;
@@ -722,7 +799,7 @@ igt_main
 			run_rt(fd, size, migrate, r->copy, r->bind, r->unbind,
 			       r->num_ctxts, r->mmap, NUM_PROCS);
 	}
-
+out:
 	igt_fixture {
 		close(fd);
 	}
-- 
2.21.0.rc0.32.g243a4c7e27



More information about the igt-dev mailing list