summaryrefslogtreecommitdiff
path: root/tests/gem_ctx_switch.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-05-07 21:06:50 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2016-05-07 22:06:57 +0100
commit4b0f3bfc2edd4228ec469327ab9fe53e8b9722e9 (patch)
tree31a60b8218be8ef3f87ff43a67e9c2e2b13f6841 /tests/gem_ctx_switch.c
parentb1083e59bd90b212d85d8fc34f5715c10cefe88e (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>
Diffstat (limited to 'tests/gem_ctx_switch.c')
-rw-r--r--tests/gem_ctx_switch.c51
1 files changed, 31 insertions, 20 deletions
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();