summaryrefslogtreecommitdiff
path: root/tests/perf_pmu.c
diff options
context:
space:
mode:
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>2018-02-05 15:01:52 +0000
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>2018-02-05 18:02:36 +0000
commit3ffa916d8b26cbcd3449a6e942d94a0257e4a208 (patch)
treee4d68720aac8dcd87c2ab08fbddd475a92cd9bb9 /tests/perf_pmu.c
parent6e1b9cc7d20af93654f4bd13bd3eb1ddc36556f5 (diff)
tests/perf_pmu: PMU enable race test
Test that the PMU can be safely enabled in face of interrupt-heavy load on an engine. The test is probabilistic so run it for ten seconds in a loop to increase the odds of hitting the race. v2: Repeat the test a few times, until a timeout. (Chris Wilson) v3: Added note in code and commit about probabilistic nature of the test. (Chris Wilson) Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/perf_pmu.c')
-rw-r--r--tests/perf_pmu.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index 5c7eb28a..9559cc30 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -1222,6 +1222,60 @@ test_rc6(int gem_fd)
assert_within_epsilon(busy - prev, 0.0, tolerance);
}
+static void
+test_enable_race(int gem_fd, const struct intel_execution_engine2 *e)
+{
+ uint64_t config = I915_PMU_ENGINE_BUSY(e->class, e->instance);
+ struct igt_helper_process engine_load = { };
+ const uint32_t bbend = MI_BATCH_BUFFER_END;
+ struct drm_i915_gem_exec_object2 obj = { };
+ struct drm_i915_gem_execbuffer2 eb = { };
+ int fd;
+
+ igt_require(gem_has_execlists(gem_fd));
+ igt_require(gem_has_engine(gem_fd, e->class, e->instance));
+
+ obj.handle = gem_create(gem_fd, 4096);
+ gem_write(gem_fd, obj.handle, 0, &bbend, sizeof(bbend));
+
+ eb.buffer_count = 1;
+ eb.buffers_ptr = to_user_pointer(&obj);
+ eb.flags = e2ring(gem_fd, e);
+
+ /*
+ * This test is probabilistic so run in a few times to increase the
+ * chance of hitting the race.
+ */
+ igt_until_timeout(10) {
+ /*
+ * Defeat the busy stats delayed disable, we need to guarantee
+ * we are the first PMU user.
+ */
+ gem_quiescent_gpu(gem_fd);
+ sleep(2);
+
+ /* Apply interrupt-heavy load on the engine. */
+ igt_fork_helper(&engine_load) {
+ for (;;)
+ gem_execbuf(gem_fd, &eb);
+ }
+
+ /* Wait a bit to allow engine load to start. */
+ usleep(500e3);
+
+ /* Enable the PMU. */
+ fd = open_pmu(config);
+
+ /* Stop load and close the PMU. */
+ igt_stop_helper(&engine_load);
+ close(fd);
+ }
+
+ /* Cleanup. */
+ gem_close(gem_fd, obj.handle);
+ gem_quiescent_gpu(gem_fd);
+}
+
igt_main
{
const unsigned int num_other_metrics =
@@ -1344,6 +1398,13 @@ igt_main
*/
igt_subtest_f("busy-double-start-%s", e->name)
busy_double_start(fd, e);
+
+ /**
+ * Check that the PMU can be safely enabled in face of
+ * interrupt-heavy engine load.
+ */
+ igt_subtest_f("enable-race-%s", e->name)
+ test_enable_race(fd, e);
}
/**