[igt-dev] [PATCH i-g-t 1/3] tests/perf_pmu: Use perf timestamps in a few more places
Tvrtko Ursulin
tursulin at ursulin.net
Thu Feb 8 08:01:29 UTC 2018
From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Use perf timestamps in more places where possible.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
tests/perf_pmu.c | 48 +++++++++++++++++++++++-------------------------
1 file changed, 23 insertions(+), 25 deletions(-)
diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index a27a8a81ec89..70fb6bd55e53 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -203,9 +203,8 @@ single(int gem_fd, const struct intel_execution_engine2 *e, unsigned int flags)
static void
busy_start(int gem_fd, const struct intel_execution_engine2 *e)
{
- unsigned long slept;
+ uint64_t val, ts[2];
igt_spin_t *spin;
- uint64_t val;
int fd;
/*
@@ -224,14 +223,14 @@ busy_start(int gem_fd, const struct intel_execution_engine2 *e)
fd = open_pmu(I915_PMU_ENGINE_BUSY(e->class, e->instance));
- val = pmu_read_single(fd);
- slept = measured_usleep(batch_duration_ns / 1000);
- val = pmu_read_single(fd) - val;
+ val = __pmu_read_single(fd, &ts[0]);
+ measured_usleep(batch_duration_ns / 1000);
+ val = __pmu_read_single(fd, &ts[1]) - val;
igt_spin_batch_free(gem_fd, spin);
close(fd);
- assert_within_epsilon(val, slept, tolerance);
+ assert_within_epsilon(val, ts[1] - ts[0], tolerance);
gem_quiescent_gpu(gem_fd);
}
@@ -243,9 +242,8 @@ busy_start(int gem_fd, const struct intel_execution_engine2 *e)
static void
busy_double_start(int gem_fd, const struct intel_execution_engine2 *e)
{
- unsigned long slept;
+ uint64_t val, val2, ts[2];
igt_spin_t *spin[2];
- uint64_t val, val2;
uint32_t ctx;
int fd;
@@ -272,9 +270,9 @@ busy_double_start(int gem_fd, const struct intel_execution_engine2 *e)
*/
fd = open_pmu(I915_PMU_ENGINE_BUSY(e->class, e->instance));
- val = pmu_read_single(fd);
- slept = measured_usleep(batch_duration_ns / 1000);
- val = pmu_read_single(fd) - val;
+ val = __pmu_read_single(fd, &ts[0]);
+ measured_usleep(batch_duration_ns / 1000);
+ val = __pmu_read_single(fd, &ts[1]) - val;
igt_spin_batch_end(spin[0]);
igt_spin_batch_end(spin[1]);
@@ -295,7 +293,7 @@ busy_double_start(int gem_fd, const struct intel_execution_engine2 *e)
gem_context_destroy(gem_fd, ctx);
- assert_within_epsilon(val, slept, tolerance);
+ assert_within_epsilon(val, ts[1] - ts[0], tolerance);
igt_assert_eq(val2, 0);
gem_quiescent_gpu(gem_fd);
@@ -821,9 +819,8 @@ static void
multi_client(int gem_fd, const struct intel_execution_engine2 *e)
{
uint64_t config = I915_PMU_ENGINE_BUSY(e->class, e->instance);
- unsigned int slept[2];
+ uint64_t val[2], ts[2], slept[2];
igt_spin_t *spin;
- uint64_t val[2];
int fd[2];
gem_quiescent_gpu(gem_fd);
@@ -839,13 +836,15 @@ multi_client(int gem_fd, const struct intel_execution_engine2 *e)
spin = igt_spin_batch_new(gem_fd, 0, e2ring(gem_fd, e), 0);
- val[0] = val[1] = pmu_read_single(fd[0]);
- slept[1] = measured_usleep(batch_duration_ns / 1000);
- val[1] = pmu_read_single(fd[1]) - val[1];
+ val[0] = val[1] = __pmu_read_single(fd[0], &ts[0]);
+ measured_usleep(batch_duration_ns / 1000);
+ val[1] = __pmu_read_single(fd[1], &ts[1]) - val[1];
+ slept[1] = ts[1] - ts[0];
close(fd[1]);
- slept[0] = measured_usleep(batch_duration_ns / 1000) + slept[1];
- val[0] = pmu_read_single(fd[0]) - val[0];
+ measured_usleep(batch_duration_ns / 1000);
+ val[0] = __pmu_read_single(fd[0], &ts[1]) - val[0];
+ slept[0] = ts[1] - ts[0];
igt_spin_batch_end(spin);
gem_sync(gem_fd, spin->handle);
@@ -1252,8 +1251,7 @@ static void
test_rc6(int gem_fd, unsigned int flags)
{
int64_t duration_ns = 2e9;
- uint64_t idle, busy, prev;
- unsigned int slept;
+ uint64_t idle, busy, prev, ts[2];
int fd, fw;
gem_quiescent_gpu(gem_fd);
@@ -1288,11 +1286,11 @@ test_rc6(int gem_fd, unsigned int flags)
igt_require(wait_for_rc6(fd));
/* While idle check full RC6. */
- prev = pmu_read_single(fd);
- slept = measured_usleep(duration_ns / 1000);
- idle = pmu_read_single(fd);
+ prev = __pmu_read_single(fd, &ts[0]);
+ measured_usleep(duration_ns / 1000);
+ idle = __pmu_read_single(fd, &ts[1]);
- assert_within_epsilon(idle - prev, slept, tolerance);
+ assert_within_epsilon(idle - prev, ts[1] - ts[0], tolerance);
/* Wake up device and check no RC6. */
fw = igt_open_forcewake_handle(gem_fd);
--
2.14.1
More information about the igt-dev
mailing list