summaryrefslogtreecommitdiff
path: root/tests/gem_ctx_create.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-07-29 18:29:45 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2016-08-01 11:57:58 +0100
commitb8ea7ad8c43bcbb0e1d69e29eb4637be5ba10db8 (patch)
treece275af40d9689bf474b6ea0a823f3986d0285f8 /tests/gem_ctx_create.c
parent53b4dfdf157b38e459f5c0a6d30a3356b158a127 (diff)
igt/gem_ctx_create: Watch context creation versus memory hogs
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/gem_ctx_create.c')
-rw-r--r--tests/gem_ctx_create.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/tests/gem_ctx_create.c b/tests/gem_ctx_create.c
index 021cfa24..e92ec925 100644
--- a/tests/gem_ctx_create.c
+++ b/tests/gem_ctx_create.c
@@ -96,14 +96,18 @@ static void files(int core, int timeout, const int ncpus)
gem_close(core, batch);
}
-static void active(int fd, unsigned engine, int timeout, const int ncpus)
+static void active(int fd, unsigned engine, 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;
+ unsigned *shared;
gem_require_ring(fd, engine);
+ shared = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+ igt_assert(shared != MAP_FAILED);
+
memset(&obj, 0, sizeof(obj));
obj.handle = gem_create(fd, 4096);
gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
@@ -113,6 +117,29 @@ static void active(int fd, unsigned engine, int timeout, const int ncpus)
execbuf.buffer_count = 1;
execbuf.flags = engine;
+ if (ncpus < 0) {
+ igt_fork(child, ppgtt_nengine) {
+ unsigned long count = 0;
+
+ if (ppgtt_engines[child] == engine)
+ continue;
+
+ execbuf.flags = ppgtt_engines[child];
+
+ while (!*(volatile unsigned *)shared) {
+ obj.handle = gem_create(fd, 4096 << 10);
+ gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
+
+ gem_execbuf(fd, &execbuf);
+ gem_close(fd, obj.handle);
+ count++;
+ }
+
+ igt_debug("hog[%d]: cycles=%lu\n", child, count);
+ }
+ ncpus = -ncpus;
+ }
+
igt_fork(child, ncpus) {
struct timespec start, end;
unsigned count = 0;
@@ -131,10 +158,13 @@ static void active(int fd, unsigned engine, int timeout, const int ncpus)
clock_gettime(CLOCK_MONOTONIC, &end);
igt_info("[%d] Context creation + execution: %.3f us\n",
child, elapsed(&start, &end) / count *1e6);
+
+ shared[0] = 1;
}
igt_waitchildren();
gem_close(fd, obj.handle);
+ munmap(shared, 4096);
}
igt_main
@@ -191,6 +221,10 @@ igt_main
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);
+ if (e->exec_id) {
+ igt_subtest_f("hog-%s", e->name)
+ active(fd, e->exec_id | e->flags, 20, -1);
+ }
}
igt_fixture {