Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tursulin@ursulin.net>
To: Intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t 2/2] tests/perf_pmu: Exercise busy stats and lite-restore
Date: Tue,  9 Jan 2018 16:16:21 +0000	[thread overview]
Message-ID: <20180109161621.17787-2-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <20180109161621.17787-1-tvrtko.ursulin@linux.intel.com>

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

While developing a fix for an accounting hole in busy stats we realized
lite-restore is a potential edge case which would be interesting to check
is properly handled.

It is unfortnately quite timing sensitive to hit lite-restore in the
fashion test needs, so downside of this test is that it sufferes from a
high rate of false negatives.

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

diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index e1f449d48808..7db5059d202e 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -192,6 +192,84 @@ busy_start(int gem_fd, const struct intel_execution_engine2 *e)
 	gem_quiescent_gpu(gem_fd);
 }
 
+/*
+ * This test has a potentially low rate of catching the issue it is trying to
+ * catch. Or in other words, quite high rate of false negative successes. We
+ * will depend on the CI systems running it a lot to detect issues.
+ */
+static void
+busy_double_start(int gem_fd, const struct intel_execution_engine2 *e)
+{
+	unsigned long slept;
+	igt_spin_t *spin[2];
+	uint64_t val, val2;
+	bool execlists;
+	uint32_t ctx;
+	int fd;
+
+	ctx = gem_context_create(gem_fd);
+
+	if (gem_has_execlists(gem_fd)) {
+		/*
+		 * Defeat the busy stats delayed disable, we need to guarantee
+		 * we are the first user.
+		 */
+		execlists = true;
+		sleep(2);
+	} else {
+		execlists = false;
+	}
+
+	/*
+	 * Submit two contexts, with a pause in between targeting the ELSP
+	 * re-submission in execlists mode. Make sure busyness is correctly
+	 * reported with the engine busy, and after the engine went idle.
+	 */
+	spin[0] = __igt_spin_batch_new(gem_fd, 0, e2ring(gem_fd, e), 0);
+	usleep(500000);
+	spin[1] = __igt_spin_batch_new(gem_fd, ctx, e2ring(gem_fd, e), 0);
+
+	/*
+	 * Open PMU as fast as possible after the second spin batch in attempt
+	 * to be faster than the driver handling lite-restore.
+	 */
+	fd = open_pmu(I915_PMU_ENGINE_BUSY(e->class, e->instance));
+
+	slept = measured_usleep(batch_duration_ns / 1000);
+	val = pmu_read_single(fd);
+
+	igt_spin_batch_end(spin[0]);
+	igt_spin_batch_end(spin[1]);
+
+	gem_sync(gem_fd, spin[0]->handle);
+	gem_sync(gem_fd, spin[1]->handle);
+
+	/* Wait for context complete to avoid accounting residual busyness. */
+	if (execlists)
+		usleep(100000);
+
+	val2 = pmu_read_single(fd);
+	usleep(batch_duration_ns / 1000);
+	val2 = pmu_read_single(fd) - val2;
+
+	igt_info("busy=%lu idle=%lu\n", val, val2);
+
+	igt_spin_batch_free(gem_fd, spin[0]);
+	igt_spin_batch_free(gem_fd, spin[1]);
+
+	close(fd);
+
+	gem_context_destroy(gem_fd, ctx);
+
+	assert_within_epsilon(val, slept, tolerance);
+	if (execlists)
+		igt_assert_eq(val2, 0);
+	else
+		assert_within_epsilon(val2, 0.0, tolerance);
+
+	gem_quiescent_gpu(gem_fd);
+}
+
 static void log_busy(int fd, unsigned int num_engines, uint64_t *val)
 {
 	char buf[1024];
@@ -1206,6 +1284,13 @@ igt_main
 		 */
 		igt_subtest_f("busy-start-%s", e->name)
 			busy_start(fd, e);
+
+		/**
+		 * Check that reported usage is correct when PMU is enabled
+		 * after two batches are running.
+		 */
+		igt_subtest_f("busy-double-start-%s", e->name)
+			busy_double_start(fd, e);
 	}
 
 	/**
-- 
2.14.1

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

  reply	other threads:[~2018-01-09 16:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-09 16:16 [PATCH i-g-t 1/2] tests/perf_pmu: Verify busyness when PMU is enabled after engine got busy Tvrtko Ursulin
2018-01-09 16:16 ` Tvrtko Ursulin [this message]
2018-01-09 21:39   ` [PATCH i-g-t 2/2] tests/perf_pmu: Exercise busy stats and lite-restore Chris Wilson
2018-01-10 10:37     ` Tvrtko Ursulin
2018-01-10 13:45       ` Chris Wilson
2018-01-11  8:46         ` [PATCH i-g-t v2 " Tvrtko Ursulin
2018-01-09 16:59 ` ✓ Fi.CI.BAT: success for series starting with [1/2] tests/perf_pmu: Verify busyness when PMU is enabled after engine got busy Patchwork
2018-01-09 18:57 ` ✗ Fi.CI.IGT: warning " Patchwork
2018-01-09 21:28 ` [PATCH i-g-t 1/2] " Chris Wilson
2018-01-10 10:42   ` Tvrtko Ursulin
2018-01-10 13:38     ` Chris Wilson
2018-01-11  8:46       ` [PATCH i-g-t v2 " Tvrtko Ursulin
2018-01-11 13:21 ` ✗ Fi.CI.BAT: failure for series starting with [v2,1/2] tests/perf_pmu: Verify busyness when PMU is enabled after engine got busy (rev3) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180109161621.17787-2-tvrtko.ursulin@linux.intel.com \
    --to=tursulin@ursulin.net \
    --cc=Intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox