All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH i-g-t] i915/pm_rc6_residency: Trigger waitboosts on intermittent workloads
@ 2020-03-23 18:14 ` Chris Wilson
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Wilson @ 2020-03-23 18:14 UTC (permalink / raw
  To: intel-gfx; +Cc: igt-dev

Use gem_sync() to trigger the waitboost, currrently we use a busywait to
avoid the frequency boost, to create a new test to make sure that our
waitboost does not impact upon idling.

We can use this test to demonstrate the impact of forgetting to cancel
the waitboost due to sleeping regularly.

References: https://gitlab.freedesktop.org/drm/intel/issues/1500
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/i915/i915_pm_rc6_residency.c | 118 ++++++++++++++++++++---------
 1 file changed, 84 insertions(+), 34 deletions(-)

diff --git a/tests/i915/i915_pm_rc6_residency.c b/tests/i915/i915_pm_rc6_residency.c
index 6a714cab8..93f4bb10a 100644
--- a/tests/i915/i915_pm_rc6_residency.c
+++ b/tests/i915/i915_pm_rc6_residency.c
@@ -34,6 +34,7 @@
 
 #include "igt.h"
 #include "igt_perf.h"
+#include "igt_rapl.h"
 #include "igt_sysfs.h"
 
 #define SLEEP_DURATION 3 /* in seconds */
@@ -280,67 +281,116 @@ static int open_pmu(int i915, uint64_t config)
 	return fd;
 }
 
+#define WAITBOOST 0x1
+#define ONCE 0x2
+
+static void bg_load(int i915, unsigned int flags, unsigned long *ctl)
+{
+	struct drm_i915_gem_exec_object2 obj = {
+		.handle = batch_create(i915),
+	};
+	struct drm_i915_gem_execbuffer2 execbuf = {
+		.buffers_ptr = to_user_pointer(&obj),
+		.buffer_count = 1,
+	};
+
+	do {
+		struct timespec tv = {};
+
+		igt_nsec_elapsed(&tv);
+
+		gem_execbuf(i915, &execbuf);
+		if (flags & WAITBOOST) {
+			gem_sync(i915, obj.handle);
+			if (flags & ONCE)
+				flags &= ~WAITBOOST;
+		} else  {
+			while (gem_bo_busy(i915, obj.handle))
+				usleep(0);
+		}
+		ctl[1]++;
+
+		usleep(igt_nsec_elapsed(&tv) / 10); /* => 1% busy */
+	} while (!READ_ONCE(*ctl));
+}
+
 static void rc6_idle(int i915)
 {
 	const int64_t duration_ns = SLEEP_DURATION * (int64_t)NSEC_PER_SEC;
 	const int tolerance = 20; /* Some RC6 is better than none! */
+	struct {
+		const char *name;
+		unsigned int flags;
+		double power;
+	} phases[] = {
+		{ "normal", 0 },
+		{ "boost", WAITBOOST },
+		{ "once", WAITBOOST | ONCE },
+	};
+	struct power_sample sample[2];
 	unsigned long slept, cycles;
 	unsigned long *done;
 	uint64_t rc6, ts[2];
+	struct rapl rapl;
+	double idle = 0;
 	int fd;
 
 	fd = open_pmu(i915, I915_PMU_RC6_RESIDENCY);
 	igt_require(__pmu_wait_for_rc6(fd));
+	gpu_power_open(&rapl);
 
 	/* While idle check full RC6. */
+	rapl_read(&rapl, &sample[0]);
 	rc6 = -__pmu_read_single(fd, &ts[0]);
 	slept = measured_usleep(duration_ns / 1000);
 	rc6 += __pmu_read_single(fd, &ts[1]);
 	igt_debug("slept=%lu perf=%"PRIu64", rc6=%"PRIu64"\n",
 		  slept, ts[1] - ts[0], rc6);
+	if (rapl_read(&rapl, &sample[1]))  {
+		idle = power_J(&rapl, &sample[0], &sample[1]);
+		igt_info("Total energy used while idle: %.1fmJ\n", idle * 1e3);
+		igt_assert(idle < 1e-3);
+	}
 	assert_within_epsilon(rc6, ts[1] - ts[0], 5);
 
-	/* Setup up a very light load */
 	done = mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
-	igt_fork(child, 1) {
-		struct drm_i915_gem_exec_object2 obj = {
-			.handle = batch_create(i915),
-		};
-		struct drm_i915_gem_execbuffer2 execbuf = {
-			.buffers_ptr = to_user_pointer(&obj),
-			.buffer_count = 1,
-		};
-
-		do {
-			struct timespec tv = {};
-
-			igt_nsec_elapsed(&tv);
-
-			gem_execbuf(i915, &execbuf);
-			while (gem_bo_busy(i915, obj.handle))
-				usleep(0);
-			done[1]++;
 
-			usleep(igt_nsec_elapsed(&tv) / 10); /* => 1% busy */
-		} while (!READ_ONCE(*done));
+	for (int p = 0; p < ARRAY_SIZE(phases); p++) {
+		memset(done, 0, 2 * sizeof(*done));
+		igt_fork(child, 1) /* Setup up a very light load */
+			bg_load(i915, phases[p].flags, done);
+
+		rapl_read(&rapl, &sample[0]);
+		cycles = -READ_ONCE(done[1]);
+		rc6 = -__pmu_read_single(fd, &ts[0]);
+		slept = measured_usleep(duration_ns / 1000);
+		rc6 += __pmu_read_single(fd, &ts[1]);
+		cycles += READ_ONCE(done[1]);
+		igt_debug("%s: slept=%lu perf=%"PRIu64", cycles=%lu, rc6=%"PRIu64"\n",
+			  phases[p].name, slept, ts[1] - ts[0], cycles, rc6);
+		if (rapl_read(&rapl, &sample[1]))  {
+			phases[p].power = power_J(&rapl, &sample[0], &sample[1]);
+			igt_info("Total energy used for %s: %.1fmJ\n",
+				 phases[p].name,  phases[p].power * 1e3);
+		}
+
+		*done = 1;
+		igt_waitchildren();
+
+		/* At least one wakeup/s needed for a reasonable test */
+		igt_assert(cycles >= SLEEP_DURATION);
+
+		/* While very nearly idle, expect full RC6 */
+		assert_within_epsilon(rc6, ts[1] - ts[0], tolerance);
 	}
 
-	/* While very nearly idle (idle to within tolerance), expect full RC6 */
-	cycles = -READ_ONCE(done[1]);
-	rc6 = -__pmu_read_single(fd, &ts[0]);
-	slept = measured_usleep(duration_ns / 1000);
-	rc6 += __pmu_read_single(fd, &ts[1]);
-	cycles += READ_ONCE(done[1]);
-	igt_debug("slept=%lu perf=%"PRIu64", cycles=%lu, rc6=%"PRIu64"\n",
-		  slept, ts[1] - ts[0], cycles, rc6);
-
-	*done = 1;
-	igt_waitchildren();
 	munmap(done, 4096);
 	close(fd);
 
-	igt_assert(cycles >= SLEEP_DURATION); /* At least one wakeup/s needed */
-	assert_within_epsilon(rc6, ts[1] - ts[0], tolerance);
+	rapl_close(&rapl);
+
+	igt_assert_f(2 * phases[2].power - phases[0].power <= phases[1].power,
+		     "Exceeded energy expectations for single busy wait load\n");
 }
 
 igt_main
-- 
2.26.0.rc2

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

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

* [igt-dev] [PATCH i-g-t] i915/pm_rc6_residency: Trigger waitboosts on intermittent workloads
@ 2020-03-23 18:14 ` Chris Wilson
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Wilson @ 2020-03-23 18:14 UTC (permalink / raw
  To: intel-gfx; +Cc: igt-dev

Use gem_sync() to trigger the waitboost, currrently we use a busywait to
avoid the frequency boost, to create a new test to make sure that our
waitboost does not impact upon idling.

We can use this test to demonstrate the impact of forgetting to cancel
the waitboost due to sleeping regularly.

References: https://gitlab.freedesktop.org/drm/intel/issues/1500
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/i915/i915_pm_rc6_residency.c | 118 ++++++++++++++++++++---------
 1 file changed, 84 insertions(+), 34 deletions(-)

diff --git a/tests/i915/i915_pm_rc6_residency.c b/tests/i915/i915_pm_rc6_residency.c
index 6a714cab8..93f4bb10a 100644
--- a/tests/i915/i915_pm_rc6_residency.c
+++ b/tests/i915/i915_pm_rc6_residency.c
@@ -34,6 +34,7 @@
 
 #include "igt.h"
 #include "igt_perf.h"
+#include "igt_rapl.h"
 #include "igt_sysfs.h"
 
 #define SLEEP_DURATION 3 /* in seconds */
@@ -280,67 +281,116 @@ static int open_pmu(int i915, uint64_t config)
 	return fd;
 }
 
+#define WAITBOOST 0x1
+#define ONCE 0x2
+
+static void bg_load(int i915, unsigned int flags, unsigned long *ctl)
+{
+	struct drm_i915_gem_exec_object2 obj = {
+		.handle = batch_create(i915),
+	};
+	struct drm_i915_gem_execbuffer2 execbuf = {
+		.buffers_ptr = to_user_pointer(&obj),
+		.buffer_count = 1,
+	};
+
+	do {
+		struct timespec tv = {};
+
+		igt_nsec_elapsed(&tv);
+
+		gem_execbuf(i915, &execbuf);
+		if (flags & WAITBOOST) {
+			gem_sync(i915, obj.handle);
+			if (flags & ONCE)
+				flags &= ~WAITBOOST;
+		} else  {
+			while (gem_bo_busy(i915, obj.handle))
+				usleep(0);
+		}
+		ctl[1]++;
+
+		usleep(igt_nsec_elapsed(&tv) / 10); /* => 1% busy */
+	} while (!READ_ONCE(*ctl));
+}
+
 static void rc6_idle(int i915)
 {
 	const int64_t duration_ns = SLEEP_DURATION * (int64_t)NSEC_PER_SEC;
 	const int tolerance = 20; /* Some RC6 is better than none! */
+	struct {
+		const char *name;
+		unsigned int flags;
+		double power;
+	} phases[] = {
+		{ "normal", 0 },
+		{ "boost", WAITBOOST },
+		{ "once", WAITBOOST | ONCE },
+	};
+	struct power_sample sample[2];
 	unsigned long slept, cycles;
 	unsigned long *done;
 	uint64_t rc6, ts[2];
+	struct rapl rapl;
+	double idle = 0;
 	int fd;
 
 	fd = open_pmu(i915, I915_PMU_RC6_RESIDENCY);
 	igt_require(__pmu_wait_for_rc6(fd));
+	gpu_power_open(&rapl);
 
 	/* While idle check full RC6. */
+	rapl_read(&rapl, &sample[0]);
 	rc6 = -__pmu_read_single(fd, &ts[0]);
 	slept = measured_usleep(duration_ns / 1000);
 	rc6 += __pmu_read_single(fd, &ts[1]);
 	igt_debug("slept=%lu perf=%"PRIu64", rc6=%"PRIu64"\n",
 		  slept, ts[1] - ts[0], rc6);
+	if (rapl_read(&rapl, &sample[1]))  {
+		idle = power_J(&rapl, &sample[0], &sample[1]);
+		igt_info("Total energy used while idle: %.1fmJ\n", idle * 1e3);
+		igt_assert(idle < 1e-3);
+	}
 	assert_within_epsilon(rc6, ts[1] - ts[0], 5);
 
-	/* Setup up a very light load */
 	done = mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
-	igt_fork(child, 1) {
-		struct drm_i915_gem_exec_object2 obj = {
-			.handle = batch_create(i915),
-		};
-		struct drm_i915_gem_execbuffer2 execbuf = {
-			.buffers_ptr = to_user_pointer(&obj),
-			.buffer_count = 1,
-		};
-
-		do {
-			struct timespec tv = {};
-
-			igt_nsec_elapsed(&tv);
-
-			gem_execbuf(i915, &execbuf);
-			while (gem_bo_busy(i915, obj.handle))
-				usleep(0);
-			done[1]++;
 
-			usleep(igt_nsec_elapsed(&tv) / 10); /* => 1% busy */
-		} while (!READ_ONCE(*done));
+	for (int p = 0; p < ARRAY_SIZE(phases); p++) {
+		memset(done, 0, 2 * sizeof(*done));
+		igt_fork(child, 1) /* Setup up a very light load */
+			bg_load(i915, phases[p].flags, done);
+
+		rapl_read(&rapl, &sample[0]);
+		cycles = -READ_ONCE(done[1]);
+		rc6 = -__pmu_read_single(fd, &ts[0]);
+		slept = measured_usleep(duration_ns / 1000);
+		rc6 += __pmu_read_single(fd, &ts[1]);
+		cycles += READ_ONCE(done[1]);
+		igt_debug("%s: slept=%lu perf=%"PRIu64", cycles=%lu, rc6=%"PRIu64"\n",
+			  phases[p].name, slept, ts[1] - ts[0], cycles, rc6);
+		if (rapl_read(&rapl, &sample[1]))  {
+			phases[p].power = power_J(&rapl, &sample[0], &sample[1]);
+			igt_info("Total energy used for %s: %.1fmJ\n",
+				 phases[p].name,  phases[p].power * 1e3);
+		}
+
+		*done = 1;
+		igt_waitchildren();
+
+		/* At least one wakeup/s needed for a reasonable test */
+		igt_assert(cycles >= SLEEP_DURATION);
+
+		/* While very nearly idle, expect full RC6 */
+		assert_within_epsilon(rc6, ts[1] - ts[0], tolerance);
 	}
 
-	/* While very nearly idle (idle to within tolerance), expect full RC6 */
-	cycles = -READ_ONCE(done[1]);
-	rc6 = -__pmu_read_single(fd, &ts[0]);
-	slept = measured_usleep(duration_ns / 1000);
-	rc6 += __pmu_read_single(fd, &ts[1]);
-	cycles += READ_ONCE(done[1]);
-	igt_debug("slept=%lu perf=%"PRIu64", cycles=%lu, rc6=%"PRIu64"\n",
-		  slept, ts[1] - ts[0], cycles, rc6);
-
-	*done = 1;
-	igt_waitchildren();
 	munmap(done, 4096);
 	close(fd);
 
-	igt_assert(cycles >= SLEEP_DURATION); /* At least one wakeup/s needed */
-	assert_within_epsilon(rc6, ts[1] - ts[0], tolerance);
+	rapl_close(&rapl);
+
+	igt_assert_f(2 * phases[2].power - phases[0].power <= phases[1].power,
+		     "Exceeded energy expectations for single busy wait load\n");
 }
 
 igt_main
-- 
2.26.0.rc2

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] ✗ Fi.CI.BAT: failure for i915/pm_rc6_residency: Trigger waitboosts on intermittent workloads
  2020-03-23 18:14 ` [igt-dev] " Chris Wilson
  (?)
@ 2020-03-23 18:55 ` Patchwork
  -1 siblings, 0 replies; 3+ messages in thread
From: Patchwork @ 2020-03-23 18:55 UTC (permalink / raw
  To: Chris Wilson; +Cc: igt-dev

== Series Details ==

Series: i915/pm_rc6_residency: Trigger waitboosts on intermittent workloads
URL   : https://patchwork.freedesktop.org/series/74983/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_8180 -> IGTPW_4342
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with IGTPW_4342 absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_4342, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4342/index.html

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in IGTPW_4342:

### IGT changes ###

#### Possible regressions ####

  * igt@i915_selftest@live@gt_contexts:
    - fi-pnv-d510:        [PASS][1] -> [DMESG-FAIL][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-pnv-d510/igt@i915_selftest@live@gt_contexts.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4342/fi-pnv-d510/igt@i915_selftest@live@gt_contexts.html

  
Known issues
------------

  Here are the changes found in IGTPW_4342 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@i915_selftest@live@gem_contexts:
    - fi-cml-s:           [PASS][3] -> [DMESG-FAIL][4] ([i915#877])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cml-s/igt@i915_selftest@live@gem_contexts.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4342/fi-cml-s/igt@i915_selftest@live@gem_contexts.html

  * igt@kms_chamelium@dp-edid-read:
    - fi-cml-u2:          [PASS][5] -> [FAIL][6] ([i915#976])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cml-u2/igt@kms_chamelium@dp-edid-read.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4342/fi-cml-u2/igt@kms_chamelium@dp-edid-read.html

  
#### Possible fixes ####

  * igt@i915_selftest@live@execlists:
    - fi-bxt-dsi:         [INCOMPLETE][7] ([fdo#103927] / [i915#656]) -> [PASS][8]
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-bxt-dsi/igt@i915_selftest@live@execlists.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4342/fi-bxt-dsi/igt@i915_selftest@live@execlists.html

  
#### Warnings ####

  * igt@i915_selftest@live@gem_contexts:
    - fi-cfl-8700k:       [DMESG-FAIL][9] ([i915#481]) -> [INCOMPLETE][10] ([i915#424])
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cfl-8700k/igt@i915_selftest@live@gem_contexts.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4342/fi-cfl-8700k/igt@i915_selftest@live@gem_contexts.html

  * igt@kms_chamelium@vga-hpd-fast:
    - fi-cml-u2:          [SKIP][11] ([fdo#109309]) -> [FAIL][12] ([i915#217])
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8180/fi-cml-u2/igt@kms_chamelium@vga-hpd-fast.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4342/fi-cml-u2/igt@kms_chamelium@vga-hpd-fast.html

  
  [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
  [fdo#109309]: https://bugs.freedesktop.org/show_bug.cgi?id=109309
  [i915#217]: https://gitlab.freedesktop.org/drm/intel/issues/217
  [i915#424]: https://gitlab.freedesktop.org/drm/intel/issues/424
  [i915#481]: https://gitlab.freedesktop.org/drm/intel/issues/481
  [i915#656]: https://gitlab.freedesktop.org/drm/intel/issues/656
  [i915#877]: https://gitlab.freedesktop.org/drm/intel/issues/877
  [i915#976]: https://gitlab.freedesktop.org/drm/intel/issues/976


Participating hosts (40 -> 39)
------------------------------

  Additional (10): fi-bdw-5557u fi-hsw-peppy fi-kbl-7500u fi-gdg-551 fi-elk-e7500 fi-skl-lmem fi-blb-e6850 fi-bsw-nick fi-skl-6600u fi-snb-2600 
  Missing    (11): fi-kbl-soraka fi-hsw-4770r fi-skl-6770hq fi-byt-squawks fi-icl-u2 fi-bsw-cyan fi-ctg-p8600 fi-bsw-kefka fi-bdw-samus fi-byt-clapper fi-skl-6700k2 


Build changes
-------------

  * CI: CI-20190529 -> None
  * IGT: IGT_5530 -> IGTPW_4342

  CI-20190529: 20190529
  CI_DRM_8180: 257af0ddcea3a234dcb79579600f971edd47353f @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_4342: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4342/index.html
  IGT_5530: 2020d743940f06294d06006bb737be43fcd2881e @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4342/index.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

end of thread, other threads:[~2020-03-23 18:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-23 18:14 [Intel-gfx] [PATCH i-g-t] i915/pm_rc6_residency: Trigger waitboosts on intermittent workloads Chris Wilson
2020-03-23 18:14 ` [igt-dev] " Chris Wilson
2020-03-23 18:55 ` [igt-dev] ✗ Fi.CI.BAT: failure for " 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.