All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] tests/perf_pmu: Test busyness reporting in face of GPU hangs
@ 2018-02-19 19:12 ` Tvrtko Ursulin
  0 siblings, 0 replies; 22+ messages in thread
From: Tvrtko Ursulin @ 2018-02-19 19:12 UTC (permalink / raw)
  To: igt-dev; +Cc: Intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Verify that the reported busyness is in line with what would we expect
from a batch which causes a hang and gets kicked out from the engine.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 tests/perf_pmu.c | 41 +++++++++++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 6 deletions(-)

diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index 7fab73e22c2d..90b6ec4db32d 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -168,6 +168,7 @@ static unsigned int e2ring(int gem_fd, const struct intel_execution_engine2 *e)
 #define TEST_TRAILING_IDLE (4)
 #define TEST_RUNTIME_PM (8)
 #define FLAG_LONG (16)
+#define FLAG_HANG (32)
 
 static void end_spin(int fd, igt_spin_t *spin, unsigned int flags)
 {
@@ -186,11 +187,15 @@ static void end_spin(int fd, igt_spin_t *spin, unsigned int flags)
 static void
 single(int gem_fd, const struct intel_execution_engine2 *e, unsigned int flags)
 {
+	const unsigned int hang_us = 10e6;
 	unsigned long slept;
 	igt_spin_t *spin;
-	uint64_t val;
+	uint64_t val[2], ts[2];
 	int fd;
 
+	if (flags & FLAG_HANG)
+		gem_quiescent_gpu(gem_fd);
+
 	fd = open_pmu(I915_PMU_ENGINE_BUSY(e->class, e->instance));
 
 	if (flags & TEST_BUSY)
@@ -198,17 +203,36 @@ single(int gem_fd, const struct intel_execution_engine2 *e, unsigned int flags)
 	else
 		spin = NULL;
 
-	val = pmu_read_single(fd);
-	slept = measured_usleep(batch_duration_ns / 1000);
+	val[0] = __pmu_read_single(fd, &ts[0]);
+	slept = measured_usleep(flags & FLAG_HANG ?
+				hang_us : batch_duration_ns / 1000);
 	if (flags & TEST_TRAILING_IDLE)
 		end_spin(gem_fd, spin, flags);
-	val = pmu_read_single(fd) - val;
+	val[1] = pmu_read_single(fd);
 
 	end_spin(gem_fd, spin, FLAG_SYNC);
 	igt_spin_batch_free(gem_fd, spin);
-	close(fd);
 
-	assert_within_epsilon(val, flags & TEST_BUSY ? slept : 0.f, tolerance);
+	if ((flags & TEST_BUSY) && (flags & FLAG_HANG)) {
+		val[1] = __pmu_read_single(fd, &ts[1]);
+		close(fd);
+		igt_info("sampled with hang %.3fms / %.3fms\n",
+			 (val[1] - val[0]) / 1e6, (ts[1] - ts[0]) / 1e6);
+		/* Check that some busyness was reported. */
+		igt_assert(val[1] - val[0] > 0);
+		/*
+		 * But not more than some reasonable value before which we
+		 * expected the spinner to be kicked out.
+		 */
+		igt_assert((val[1] - val[0]) / 1e3 < (double)hang_us * 0.75);
+		__assert_within_epsilon(val[1] - val[0], hang_us * 1e3,
+					0.02f, 10.0f);
+	} else {
+		close(fd);
+		assert_within_epsilon(val[1] - val[0],
+				      flags & TEST_BUSY ?
+				      slept : 0.f, tolerance);
+	}
 	gem_quiescent_gpu(gem_fd);
 }
 
@@ -1695,6 +1719,11 @@ igt_main
 					      pct[i], e->name)
 					accuracy(fd, e, pct[i]);
 			}
+
+			igt_subtest_f("busy-hang-%s", e->name) {
+				single(fd, e, TEST_BUSY | FLAG_HANG);
+				single(fd, e, TEST_BUSY | FLAG_HANG);
+			}
 		}
 
 		/**
-- 
2.14.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2018-03-01 13:21 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-19 19:12 [PATCH i-g-t] tests/perf_pmu: Test busyness reporting in face of GPU hangs Tvrtko Ursulin
2018-02-19 19:12 ` [Intel-gfx] " Tvrtko Ursulin
2018-02-19 19:21 ` [igt-dev] " Chris Wilson
2018-02-19 19:21   ` Chris Wilson
2018-02-19 19:26   ` Tvrtko Ursulin
2018-02-19 19:26     ` [igt-dev] [Intel-gfx] " Tvrtko Ursulin
2018-02-28 17:15   ` [PATCH i-g-t v2] " Tvrtko Ursulin
2018-02-28 17:15     ` [Intel-gfx] " Tvrtko Ursulin
2018-03-01  8:08     ` Chris Wilson
2018-03-01  8:08       ` [Intel-gfx] " Chris Wilson
2018-03-01  9:21       ` Tvrtko Ursulin
2018-03-01  9:21         ` [igt-dev] [Intel-gfx] " Tvrtko Ursulin
2018-03-01  9:27         ` Chris Wilson
2018-03-01  9:27           ` [Intel-gfx] " Chris Wilson
2018-03-01  9:38           ` [PATCH i-g-t v3] " Tvrtko Ursulin
2018-03-01  9:38             ` [igt-dev] " Tvrtko Ursulin
2018-02-19 19:34 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-02-19 22:47 ` [igt-dev] ✗ Fi.CI.IGT: warning " Patchwork
2018-02-28 18:11 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/perf_pmu: Test busyness reporting in face of GPU hangs (rev2) Patchwork
2018-02-28 22:47 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-03-01  9:59 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/perf_pmu: Test busyness reporting in face of GPU hangs (rev3) Patchwork
2018-03-01 13:21 ` [igt-dev] ✗ Fi.CI.IGT: warning " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.