diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-05-07 21:06:50 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-05-07 22:06:57 +0100 |
commit | 4b0f3bfc2edd4228ec469327ab9fe53e8b9722e9 (patch) | |
tree | 31a60b8218be8ef3f87ff43a67e9c2e2b13f6841 | |
parent | b1083e59bd90b212d85d8fc34f5715c10cefe88e (diff) |
igt: Add a few more forked variants of basic tests
Check contention for context and object creation.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | tests/gem_ctx_create.c | 90 | ||||
-rw-r--r-- | tests/gem_ctx_switch.c | 51 | ||||
-rw-r--r-- | tests/gem_exec_create.c | 70 |
3 files changed, 126 insertions, 85 deletions
diff --git a/tests/gem_ctx_create.c b/tests/gem_ctx_create.c index 36e128c5..0bdd4082 100644 --- a/tests/gem_ctx_create.c +++ b/tests/gem_ctx_create.c @@ -53,14 +53,12 @@ static double elapsed(const struct timespec *start, return (end->tv_sec - start->tv_sec) + 1e-9*(end->tv_nsec - start->tv_nsec); } -static void files(int core, int timeout) +static void files(int core, int timeout, const int ncpus) { const uint32_t bbe = MI_BATCH_BUFFER_END; struct drm_i915_gem_execbuffer2 execbuf; struct drm_i915_gem_exec_object2 obj; - struct timespec start, end; uint32_t batch, name; - unsigned count = 0; batch = gem_create(core, 4096); gem_write(core, batch, 0, &bbe, sizeof(bbe)); @@ -71,34 +69,38 @@ static void files(int core, int timeout) execbuf.buffers_ptr = (uintptr_t)&obj; execbuf.buffer_count = 1; - clock_gettime(CLOCK_MONOTONIC, &start); - do { + igt_fork(child, ncpus) { + struct timespec start, end; + unsigned count = 0; + + clock_gettime(CLOCK_MONOTONIC, &start); do { - int fd = drm_open_driver(DRIVER_INTEL); - obj.handle = gem_open(fd, name); - execbuf.flags &= ~ENGINE_FLAGS; - execbuf.flags |= ppgtt_engines[count % ppgtt_nengine]; - gem_execbuf(fd, &execbuf); - close(fd); - } while (++count & 1023); + do { + int fd = drm_open_driver(DRIVER_INTEL); + obj.handle = gem_open(fd, name); + execbuf.flags &= ~ENGINE_FLAGS; + execbuf.flags |= ppgtt_engines[count % ppgtt_nengine]; + gem_execbuf(fd, &execbuf); + close(fd); + } while (++count & 1023); + clock_gettime(CLOCK_MONOTONIC, &end); + } while (elapsed(&start, &end) < timeout); + + gem_sync(core, batch); clock_gettime(CLOCK_MONOTONIC, &end); - } while (elapsed(&start, &end) < timeout); - - gem_sync(core, batch); - clock_gettime(CLOCK_MONOTONIC, &end); - igt_info("File creation + execution: %.3f us\n", - elapsed(&start, &end) / count *1e6); + igt_info("[%d] File creation + execution: %.3f us\n", + child, elapsed(&start, &end) / count *1e6); + } + igt_waitchildren(); gem_close(core, batch); } -static void active(int fd, unsigned engine, int timeout) +static void active(int fd, unsigned engine, int timeout, const int ncpus) { const uint32_t bbe = MI_BATCH_BUFFER_END; struct drm_i915_gem_execbuffer2 execbuf; struct drm_i915_gem_exec_object2 obj; - struct timespec start, end; - unsigned count = 0; gem_require_ring(fd, engine); @@ -111,28 +113,35 @@ static void active(int fd, unsigned engine, int timeout) execbuf.buffer_count = 1; execbuf.flags = engine; - clock_gettime(CLOCK_MONOTONIC, &start); - do { + igt_fork(child, ncpus) { + struct timespec start, end; + unsigned count = 0; + + clock_gettime(CLOCK_MONOTONIC, &start); do { - execbuf.rsvd1 = gem_context_create(fd); - gem_execbuf(fd, &execbuf); - gem_context_destroy(fd, execbuf.rsvd1); - } while (++count & 1023); + do { + execbuf.rsvd1 = gem_context_create(fd); + gem_execbuf(fd, &execbuf); + gem_context_destroy(fd, execbuf.rsvd1); + } while (++count & 1023); + clock_gettime(CLOCK_MONOTONIC, &end); + } while (elapsed(&start, &end) < timeout); + + gem_sync(fd, obj.handle); clock_gettime(CLOCK_MONOTONIC, &end); - } while (elapsed(&start, &end) < timeout); - - gem_sync(fd, obj.handle); - clock_gettime(CLOCK_MONOTONIC, &end); - igt_info("Context creation + execution: %.3f us\n", - elapsed(&start, &end) / count *1e6); + igt_info("[%d] Context creation + execution: %.3f us\n", + child, elapsed(&start, &end) / count *1e6); + } + igt_waitchildren(); gem_close(fd, obj.handle); } igt_main { + const int ncpus = sysconf(_SC_NPROCESSORS_ONLN); struct drm_i915_gem_context_create create; - int fd; + int fd = -1; igt_fixture { fd = drm_open_driver(DRIVER_INTEL); @@ -171,13 +180,18 @@ igt_main igt_assert_eq(__gem_context_create(fd, &create), -EINVAL); } - igt_subtest("files") - files(fd, 20); + igt_subtest("basic-files") + files(fd, 20, 1); + igt_subtest("forked-files") + files(fd, 20, ncpus); for (const struct intel_execution_engine *e = intel_execution_engines; - e->name; e++) + e->name; e++) { igt_subtest_f("active-%s", e->name) - active(fd, e->exec_id | e->flags, 20); + active(fd, e->exec_id | e->flags, 20, 1); + igt_subtest_f("forked-active-%s", e->name) + active(fd, e->exec_id | e->flags, 20, ncpus); + } igt_stop_hang_detector(); diff --git a/tests/gem_ctx_switch.c b/tests/gem_ctx_switch.c index 2827b7fc..691a4f1f 100644 --- a/tests/gem_ctx_switch.c +++ b/tests/gem_ctx_switch.c @@ -66,14 +66,14 @@ static double elapsed(const struct timespec *start, const struct timespec *end) static void single(int fd, uint32_t handle, const struct intel_execution_engine *e, - unsigned flags) + unsigned flags, + const int ncpus) { struct drm_i915_gem_execbuffer2 execbuf; struct drm_i915_gem_exec_object2 obj; struct drm_i915_gem_relocation_entry reloc; - struct timespec start, now; uint32_t contexts[64]; - unsigned int count = 0; + int child; int n; gem_require_ring(fd, e->exec_id | e->flags); @@ -111,24 +111,30 @@ static void single(int fd, uint32_t handle, } gem_sync(fd, handle); - clock_gettime(CLOCK_MONOTONIC, &start); - do { - igt_interruptible(flags & INTERRUPTIBLE) { - for (int loop = 0; loop < 1024; loop++) { - execbuf.rsvd1 = contexts[loop % 64]; - reloc.presumed_offset = 0; - gem_execbuf(fd, &execbuf); + igt_fork(child, ncpus) { + struct timespec start, now; + unsigned int count = 0; + + clock_gettime(CLOCK_MONOTONIC, &start); + do { + igt_interruptible(flags & INTERRUPTIBLE) { + for (int loop = 0; loop < 1024; loop++) { + execbuf.rsvd1 = contexts[loop % 64]; + reloc.presumed_offset = 0; + gem_execbuf(fd, &execbuf); + } + count += 1024; } - count += 1024; - } + clock_gettime(CLOCK_MONOTONIC, &now); + } while (elapsed(&start, &now) < 20.); + gem_sync(fd, handle); clock_gettime(CLOCK_MONOTONIC, &now); - } while (elapsed(&start, &now) < 20.); - gem_sync(fd, handle); - clock_gettime(CLOCK_MONOTONIC, &now); - igt_info("%s: %'u cycles: %.3fus%s\n", - e->name, count, elapsed(&start, &now)*1e6 / count, - flags & INTERRUPTIBLE ? " (interruptible)" : ""); + igt_info("[%d] %s: %'u cycles: %.3fus%s\n", + child, e->name, count, elapsed(&start, &now)*1e6 / count, + flags & INTERRUPTIBLE ? " (interruptible)" : ""); + } + igt_waitchildren(); for (n = 0; n < 64; n++) gem_context_destroy(fd, contexts[n]); @@ -136,6 +142,7 @@ static void single(int fd, uint32_t handle, igt_main { + const int ncpus = sysconf(_SC_NPROCESSORS_ONLN); const struct intel_execution_engine *e; uint32_t handle = 0; int fd = -1; @@ -152,9 +159,13 @@ igt_main for (e = intel_execution_engines; e->name; e++) { igt_subtest_f("%s%s", e->exec_id == 0 ? "basic-" : "", e->name) - single(fd, handle, e, 0); + single(fd, handle, e, 0, 1); igt_subtest_f("%s-interruptible", e->name) - single(fd, handle, e, INTERRUPTIBLE); + single(fd, handle, e, INTERRUPTIBLE, 1); + igt_subtest_f("forked-%s", e->name) + single(fd, handle, e, 0, ncpus); + igt_subtest_f("forked-%s-interruptible", e->name) + single(fd, handle, e, INTERRUPTIBLE, ncpus); } igt_stop_hang_detector(); diff --git a/tests/gem_exec_create.c b/tests/gem_exec_create.c index d5e11037..5cd9302f 100644 --- a/tests/gem_exec_create.c +++ b/tests/gem_exec_create.c @@ -67,17 +67,15 @@ static bool ignore_engine(int fd, unsigned engine) #define LEAK 0x1 -static void all(int fd, unsigned flags, int timeout) +static void all(int fd, unsigned flags, int timeout, int ncpus) { const uint32_t bbe = MI_BATCH_BUFFER_END; struct drm_i915_gem_execbuffer2 execbuf; struct drm_i915_gem_exec_object2 obj; - struct timespec start, now; unsigned engines[16]; unsigned nengine; unsigned engine; - unsigned long count; - double time; + int child; nengine = 0; for_each_engine(fd, engine) { @@ -104,35 +102,51 @@ static void all(int fd, unsigned flags, int timeout) gem_sync(fd, obj.handle); gem_close(fd, obj.handle); - count = 0; - clock_gettime(CLOCK_MONOTONIC, &start); - do { - for (int loop = 0; loop < 1024; loop++) { - for (int n = 0; n < nengine; n++) { - obj.handle = gem_create(fd, 4096); - gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); - execbuf.flags &= ~ENGINE_FLAGS; - execbuf.flags |= engines[n]; - gem_execbuf(fd, &execbuf); - if (flags & LEAK) - gem_madvise(fd, obj.handle, I915_MADV_DONTNEED); - else - gem_close(fd, obj.handle); + igt_fork(child, ncpus) { + struct timespec start, now; + unsigned long count; + double time; + + count = 0; + clock_gettime(CLOCK_MONOTONIC, &start); + do { + for (int loop = 0; loop < 1024; loop++) { + for (int n = 0; n < nengine; n++) { + obj.handle = gem_create(fd, 4096); + gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); + execbuf.flags &= ~ENGINE_FLAGS; + execbuf.flags |= engines[n]; + gem_execbuf(fd, &execbuf); + if (flags & LEAK) + gem_madvise(fd, obj.handle, I915_MADV_DONTNEED); + else + gem_close(fd, obj.handle); + } } + count += nengine * 1024; + clock_gettime(CLOCK_MONOTONIC, &now); + } while (elapsed(&start, &now) < timeout); /* Hang detection ~120s */ + obj.handle = gem_create(fd, 4096); + gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); + for (int n = 0; n < nengine; n++) { + execbuf.flags &= ~ENGINE_FLAGS; + execbuf.flags |= engines[n]; + gem_execbuf(fd, &execbuf); } - count += nengine * 1024; + gem_sync(fd, obj.handle); + gem_close(fd, obj.handle); clock_gettime(CLOCK_MONOTONIC, &now); - } while (elapsed(&start, &now) < timeout); /* Hang detection ~120s */ - gem_quiescent_gpu(fd); - clock_gettime(CLOCK_MONOTONIC, &now); - time = elapsed(&start, &now) / count; - igt_info("All (%d engines): %'lu cycles, average %.3fus per cycle\n", - nengine, count, 1e6*time); + time = elapsed(&start, &now) / count; + igt_info("[%d] All (%d engines): %'lu cycles, average %.3fus per cycle\n", + child, nengine, count, 1e6*time); + } + igt_waitchildren(); } igt_main { + const int ncpus = sysconf(_SC_NPROCESSORS_ONLN); int device = -1; igt_fixture @@ -141,10 +155,12 @@ igt_main igt_fork_hang_detector(device); igt_subtest("basic") - all(device, 0, 20); + all(device, 0, 20, 1); + igt_subtest("forked") + all(device, 0, 20, ncpus); igt_subtest("madvise") - all(device, LEAK, 20); + all(device, LEAK, 20, 1); igt_stop_hang_detector(); |