Start the spinner first; before starting the measurement, and sleep for a known duration. In particular, CI once saw a measurement for busyness greater than the intended batch_duration! Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104241 Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> Cc: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> --- tests/perf_pmu.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c index db7696115..93df4520b 100644 --- a/tests/perf_pmu.c +++ b/tests/perf_pmu.c @@ -133,30 +133,24 @@ static unsigned int e2ring(int gem_fd, const struct intel_execution_engine2 *e) static void single(int gem_fd, const struct intel_execution_engine2 *e, bool busy) { - double ref = busy ? batch_duration_ns : 0.0f; + unsigned long slept; igt_spin_t *spin; uint64_t val; int fd; - fd = open_pmu(I915_PMU_ENGINE_BUSY(e->class, e->instance)); - - if (busy) { - spin = igt_spin_batch_new(gem_fd, 0, e2ring(gem_fd, e), 0); - igt_spin_batch_set_timeout(spin, batch_duration_ns); - } else { - usleep(batch_duration_ns / 1000); - } - if (busy) - gem_sync(gem_fd, spin->handle); + spin = igt_spin_batch_new(gem_fd, 0, e2ring(gem_fd, e), 0); + else + spin = NULL; + fd = open_pmu(I915_PMU_ENGINE_BUSY(e->class, e->instance)); + slept = measured_usleep(batch_duration_ns / 1000); val = pmu_read_single(fd); - if (busy) - igt_spin_batch_free(gem_fd, spin); + igt_spin_batch_free(gem_fd, spin); close(fd); - assert_within_epsilon(val, ref, tolerance); + assert_within_epsilon(val, busy ? slept : 0.f, tolerance); } static void log_busy(int fd, unsigned int num_engines, uint64_t *val) -- 2.15.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx