All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH i-g-t] tests/i915/perf_pmu: Subtest to measure sampling error for 100% busy
@ 2021-02-16 10:50 ` Tvrtko Ursulin
  0 siblings, 0 replies; 13+ messages in thread
From: Tvrtko Ursulin @ 2021-02-16 10:50 UTC (permalink / raw)
  To: igt-dev; +Cc: Intel-gfx

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

Test that periodic reads of engine busyness against a constant 100% load
are within the 5000ppm tolerance when comparing perf timestamp versus
counter values.

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

diff --git a/tests/i915/perf_pmu.c b/tests/i915/perf_pmu.c
index 50b5c82bc472..728312be5293 100644
--- a/tests/i915/perf_pmu.c
+++ b/tests/i915/perf_pmu.c
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <fcntl.h>
+#include <float.h>
 #include <inttypes.h>
 #include <errno.h>
 #include <signal.h>
@@ -46,6 +47,7 @@
 #include "igt_perf.h"
 #include "igt_sysfs.h"
 #include "igt_pm.h"
+#include "igt_stats.h"
 #include "sw_sync.h"
 
 IGT_TEST_DESCRIPTION("Test the i915 pmu perf interface");
@@ -278,8 +280,11 @@ 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)
 {
+	unsigned int loops = flags & FLAG_LONG ? 20 : 1;
+	double err_min = DBL_MAX, err_max = -DBL_MAX;
 	unsigned long slept;
 	igt_spin_t *spin;
+	igt_stats_t s;
 	uint64_t val;
 	int fd;
 
@@ -290,11 +295,40 @@ 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);
-	if (flags & TEST_TRAILING_IDLE)
-		end_spin(gem_fd, spin, flags);
-	val = pmu_read_single(fd) - val;
+	igt_stats_init_with_size(&s, loops);
+
+	while (--loops) {
+		uint64_t ts[2];
+
+		val = __pmu_read_single(fd, &ts[0]);
+		slept = measured_usleep(batch_duration_ns / 1000);
+		if (flags & TEST_TRAILING_IDLE)
+			end_spin(gem_fd, spin, flags);
+		val = __pmu_read_single(fd, &ts[1]) - val;
+
+		if (flags & FLAG_LONG) {
+			unsigned long t = ts[1] - ts[0];
+			double err = (double)((long)val - (long)t) / t * 1e6;
+
+			igt_debug("time=%lu busy=%"PRIu64" error=%.2fppm\n",
+				  t, val, err);
+
+			igt_assert_f(fabs(err) <= 5000, "Error=%.2fppm\n", err);
+
+			if (err > err_max)
+				err_max = err;
+			if (err < err_min)
+				err_min = err;
+
+			igt_stats_push_float(&s, err);
+		}
+	}
+
+	if (flags & FLAG_LONG)
+		igt_info("error min=%.2fppm avg=%.2fppm max=%.2fppm\n",
+			 err_min, igt_stats_get_mean(&s), err_max);
+
+	igt_stats_fini(&s);
 
 	if (flags & FLAG_HANG)
 		igt_force_gpu_reset(gem_fd);
@@ -2126,6 +2160,8 @@ igt_main
 	 */
 	test_each_engine("busy", fd, e)
 		single(fd, e, TEST_BUSY);
+	test_each_engine("busy-accuracy", fd, e)
+		single(fd, e, TEST_BUSY | FLAG_LONG);
 	test_each_engine("busy-idle", fd, e)
 		single(fd, e, TEST_BUSY | TEST_TRAILING_IDLE);
 
-- 
2.27.0

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

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

end of thread, other threads:[~2021-02-16 17:53 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-16 10:50 [Intel-gfx] [PATCH i-g-t] tests/i915/perf_pmu: Subtest to measure sampling error for 100% busy Tvrtko Ursulin
2021-02-16 10:50 ` [igt-dev] " Tvrtko Ursulin
2021-02-16 11:39 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2021-02-16 11:44 ` [Intel-gfx] [PATCH i-g-t] " Chris Wilson
2021-02-16 11:44   ` [igt-dev] " Chris Wilson
2021-02-16 12:40 ` [igt-dev] ✗ Fi.CI.IGT: failure for " Patchwork
2021-02-16 12:47 ` [Intel-gfx] [PATCH i-g-t] " Chris Wilson
2021-02-16 12:47   ` [igt-dev] " Chris Wilson
2021-02-16 12:49 ` Chris Wilson
2021-02-16 12:49   ` [igt-dev] " Chris Wilson
2021-02-16 15:59   ` Tvrtko Ursulin
2021-02-16 15:59     ` [igt-dev] " Tvrtko Ursulin
2021-02-16 17:53     ` Chris Wilson

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.