All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] igt/gem_mocs_settings: Use i915_pmu to measure rc6 residency
@ 2018-07-26 20:30 Chris Wilson
  2018-07-26 20:33 ` Chris Wilson
  2018-07-27 10:36 ` [PATCH i-g-t v2] " Chris Wilson
  0 siblings, 2 replies; 4+ messages in thread
From: Chris Wilson @ 2018-07-26 20:30 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev

Use the perf pmu interface for lowlevel rc6 measurement, hopefully for
greater stability.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/Makefile.am         |  1 +
 tests/gem_mocs_settings.c | 45 +++++++++++++++++++++++++++------------
 tests/meson.build         |  8 ++++++-
 3 files changed, 39 insertions(+), 15 deletions(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8712eb169..ee5a7c5e8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -115,6 +115,7 @@ gem_fence_upload_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_fence_upload_LDADD = $(LDADD) -lpthread
 gem_flink_race_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_flink_race_LDADD = $(LDADD) -lpthread
+gem_mocs_settings_LDADD = $(LDADD) $(top_builddir)/lib/libigt_perf.la
 gem_mmap_gtt_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_mmap_gtt_LDADD = $(LDADD) -lpthread
 gem_mmap_wc_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
diff --git a/tests/gem_mocs_settings.c b/tests/gem_mocs_settings.c
index 9705fbfde..eccbf7852 100644
--- a/tests/gem_mocs_settings.c
+++ b/tests/gem_mocs_settings.c
@@ -29,6 +29,7 @@
 
 #include "igt.h"
 #include "igt_gt.h"
+#include "igt_perf.h"
 #include "igt_sysfs.h"
 
 #define MAX_NUMBER_MOCS_REGISTERS	(64)
@@ -329,23 +330,39 @@ static void check_l3cc_registers(int fd,
 }
 
 
-static uint32_t rc6_residency(int dir)
+static bool rc6_wait(int i915)
 {
-	return igt_sysfs_get_u32(dir, "power/rc6_residency_ms");
-}
-
-static void rc6_wait(int fd)
-{
-	int sysfs;
-	uint32_t residency;
+	uint64_t start[2], now[2], prev;
+	bool rc6 = false;
+	int fd;
+
+	fd = perf_i915_open(I915_PMU_RC6_RESIDENCY);
+
+	/* First wait for roughly an RC6 Evaluation Interval */
+	gem_quiescent_gpu(i915);
+	usleep(320e3);
+
+	/* Then poll for RC6 to start ticking */
+	igt_assert_eq(read(fd, start, sizeof(start)), sizeof(start));
+	prev = start[1];
+	do {
+		usleep(5e3);
+		igt_assert_eq(read(fd, now, sizeof(now)), sizeof(now));
+		if (now[1] - prev > 1e6) {
+			rc6 = true;
+			break;
+		}
+		prev = now[1];
+	} while (now[0] - start[0] > 1e9);
 
-	sysfs = igt_sysfs_open(fd, NULL);
-	igt_assert_lte(0, sysfs);
+	close(fd);
 
-	residency = rc6_residency(sysfs);
-	igt_require(igt_wait(rc6_residency(sysfs) != residency, 10000, 2));
+	igt_debug("rc6 residency %.2fms (delta %.1fms over 5ms), elapsed %.2fms\n",
+		  1e-6 * (now[1] - start[1]),
+		  1e-6 * (now[1] - prev),
+		  1e-6 * (now[0] - start[0]));
 
-	close(sysfs);
+	return rc6;
 }
 
 static void check_mocs_values(int fd, unsigned engine, uint32_t ctx_id, bool dirty)
@@ -397,7 +414,7 @@ static void run_test(int fd, unsigned engine, unsigned flags, unsigned mode)
 						      SUSPEND_TEST_NONE); break;
 	case HIBERNATE:	igt_system_suspend_autoresume(SUSPEND_STATE_DISK,
 						      SUSPEND_TEST_NONE); break;
-	case RC6:	rc6_wait(fd);			break;
+	case RC6:	igt_require(rc6_wait(fd));	break;
 	}
 
 	check_mocs_values(fd, engine, ctx_id, false);
diff --git a/tests/meson.build b/tests/meson.build
index 32c2156c6..8f9ead8c3 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -82,7 +82,6 @@ test_progs = [
 	'gem_mmap_gtt',
 	'gem_mmap_offset_exhaustion',
 	'gem_mmap_wc',
-	'gem_mocs_settings',
 	'gem_partial_pwrite_pread',
 	'gem_persistent_relocs',
 	'gem_pipe_control_store_loop',
@@ -279,6 +278,13 @@ test_executables += executable('gem_eio', 'gem_eio.c',
 	   install : true)
 test_progs += 'gem_eio'
 
+test_executables += executable('gem_mocs_settings', 'gem_mocs_settings.c',
+	   dependencies : test_deps + [ lib_igt_perf ],
+	   install_dir : libexecdir,
+	   install_rpath : rpathdir,
+	   install : true)
+test_progs += 'gem_mocs_settings'
+
 test_executables += executable('perf_pmu', 'perf_pmu.c',
 	   dependencies : test_deps + [ lib_igt_perf ],
 	   install_dir : libexecdir,
-- 
2.18.0

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

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

* [PATCH i-g-t] igt/gem_mocs_settings: Use i915_pmu to measure rc6 residency
  2018-07-26 20:30 [PATCH i-g-t] igt/gem_mocs_settings: Use i915_pmu to measure rc6 residency Chris Wilson
@ 2018-07-26 20:33 ` Chris Wilson
  2018-07-27 10:36 ` [PATCH i-g-t v2] " Chris Wilson
  1 sibling, 0 replies; 4+ messages in thread
From: Chris Wilson @ 2018-07-26 20:33 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev

Use the perf pmu interface for lowlevel rc6 measurement, hopefully for
greater stability.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/Makefile.am         |  1 +
 tests/gem_mocs_settings.c | 47 ++++++++++++++++++++++++++-------------
 tests/meson.build         |  8 ++++++-
 3 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8712eb169..ee5a7c5e8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -115,6 +115,7 @@ gem_fence_upload_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_fence_upload_LDADD = $(LDADD) -lpthread
 gem_flink_race_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_flink_race_LDADD = $(LDADD) -lpthread
+gem_mocs_settings_LDADD = $(LDADD) $(top_builddir)/lib/libigt_perf.la
 gem_mmap_gtt_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_mmap_gtt_LDADD = $(LDADD) -lpthread
 gem_mmap_wc_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
diff --git a/tests/gem_mocs_settings.c b/tests/gem_mocs_settings.c
index 9705fbfde..a1ef73304 100644
--- a/tests/gem_mocs_settings.c
+++ b/tests/gem_mocs_settings.c
@@ -29,6 +29,7 @@
 
 #include "igt.h"
 #include "igt_gt.h"
+#include "igt_perf.h"
 #include "igt_sysfs.h"
 
 #define MAX_NUMBER_MOCS_REGISTERS	(64)
@@ -329,23 +330,39 @@ static void check_l3cc_registers(int fd,
 }
 
 
-static uint32_t rc6_residency(int dir)
+static void rc6_wait(int i915)
 {
-	return igt_sysfs_get_u32(dir, "power/rc6_residency_ms");
-}
-
-static void rc6_wait(int fd)
-{
-	int sysfs;
-	uint32_t residency;
-
-	sysfs = igt_sysfs_open(fd, NULL);
-	igt_assert_lte(0, sysfs);
+	uint64_t start[2], now[2], prev;
+	bool rc6 = false;
+	int fd;
+
+	fd = perf_i915_open(I915_PMU_RC6_RESIDENCY);
+	igt_require(fd != -1);
+
+	/* First wait for roughly an RC6 Evaluation Interval */
+	gem_quiescent_gpu(i915);
+	usleep(320e3);
+
+	/* Then poll for RC6 to start ticking */
+	igt_assert_eq(read(fd, start, sizeof(start)), sizeof(start));
+	prev = start[1];
+	do {
+		usleep(5e3);
+		igt_assert_eq(read(fd, now, sizeof(now)), sizeof(now));
+		if (now[1] - prev > 1e6) {
+			rc6 = true;
+			break;
+		}
+		prev = now[1];
+	} while (now[0] - start[0] > 1e9);
 
-	residency = rc6_residency(sysfs);
-	igt_require(igt_wait(rc6_residency(sysfs) != residency, 10000, 2));
+	close(fd);
 
-	close(sysfs);
+	igt_debug("rc6 residency %.2fms (delta %.1fms over 5ms), elapsed %.2fms\n",
+		  1e-6 * (now[1] - start[1]),
+		  1e-6 * (now[1] - prev),
+		  1e-6 * (now[0] - start[0]));
+	igt_require(rc6);
 }
 
 static void check_mocs_values(int fd, unsigned engine, uint32_t ctx_id, bool dirty)
@@ -397,7 +414,7 @@ static void run_test(int fd, unsigned engine, unsigned flags, unsigned mode)
 						      SUSPEND_TEST_NONE); break;
 	case HIBERNATE:	igt_system_suspend_autoresume(SUSPEND_STATE_DISK,
 						      SUSPEND_TEST_NONE); break;
-	case RC6:	rc6_wait(fd);			break;
+	case RC6:	rc6_wait(fd);	break;
 	}
 
 	check_mocs_values(fd, engine, ctx_id, false);
diff --git a/tests/meson.build b/tests/meson.build
index 32c2156c6..8f9ead8c3 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -82,7 +82,6 @@ test_progs = [
 	'gem_mmap_gtt',
 	'gem_mmap_offset_exhaustion',
 	'gem_mmap_wc',
-	'gem_mocs_settings',
 	'gem_partial_pwrite_pread',
 	'gem_persistent_relocs',
 	'gem_pipe_control_store_loop',
@@ -279,6 +278,13 @@ test_executables += executable('gem_eio', 'gem_eio.c',
 	   install : true)
 test_progs += 'gem_eio'
 
+test_executables += executable('gem_mocs_settings', 'gem_mocs_settings.c',
+	   dependencies : test_deps + [ lib_igt_perf ],
+	   install_dir : libexecdir,
+	   install_rpath : rpathdir,
+	   install : true)
+test_progs += 'gem_mocs_settings'
+
 test_executables += executable('perf_pmu', 'perf_pmu.c',
 	   dependencies : test_deps + [ lib_igt_perf ],
 	   install_dir : libexecdir,
-- 
2.18.0

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

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

* [PATCH i-g-t v2] igt/gem_mocs_settings: Use i915_pmu to measure rc6 residency
  2018-07-26 20:30 [PATCH i-g-t] igt/gem_mocs_settings: Use i915_pmu to measure rc6 residency Chris Wilson
  2018-07-26 20:33 ` Chris Wilson
@ 2018-07-27 10:36 ` Chris Wilson
  2018-07-27 12:01   ` Matthew Auld
  1 sibling, 1 reply; 4+ messages in thread
From: Chris Wilson @ 2018-07-27 10:36 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev

Use the perf pmu interface for lowlevel rc6 measurement, hopefully for
greater stability.

v2: Fix timeout to run for 1s, not one pass!

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/Makefile.am         |  1 +
 tests/gem_mocs_settings.c | 46 ++++++++++++++++++++++++++-------------
 tests/meson.build         |  8 ++++++-
 3 files changed, 39 insertions(+), 16 deletions(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8712eb169..ee5a7c5e8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -115,6 +115,7 @@ gem_fence_upload_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_fence_upload_LDADD = $(LDADD) -lpthread
 gem_flink_race_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_flink_race_LDADD = $(LDADD) -lpthread
+gem_mocs_settings_LDADD = $(LDADD) $(top_builddir)/lib/libigt_perf.la
 gem_mmap_gtt_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_mmap_gtt_LDADD = $(LDADD) -lpthread
 gem_mmap_wc_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
diff --git a/tests/gem_mocs_settings.c b/tests/gem_mocs_settings.c
index 9705fbfde..967223f1b 100644
--- a/tests/gem_mocs_settings.c
+++ b/tests/gem_mocs_settings.c
@@ -29,6 +29,7 @@
 
 #include "igt.h"
 #include "igt_gt.h"
+#include "igt_perf.h"
 #include "igt_sysfs.h"
 
 #define MAX_NUMBER_MOCS_REGISTERS	(64)
@@ -328,24 +329,39 @@ static void check_l3cc_registers(int fd,
 	gem_close(fd, dst_handle);
 }
 
-
-static uint32_t rc6_residency(int dir)
-{
-	return igt_sysfs_get_u32(dir, "power/rc6_residency_ms");
-}
-
-static void rc6_wait(int fd)
+static void rc6_wait(int i915)
 {
-	int sysfs;
-	uint32_t residency;
-
-	sysfs = igt_sysfs_open(fd, NULL);
-	igt_assert_lte(0, sysfs);
+	uint64_t start[2], now[2], prev;
+	bool rc6 = false;
+	int fd;
+
+	fd = perf_i915_open(I915_PMU_RC6_RESIDENCY);
+	igt_require(fd != -1);
+
+	/* First wait for roughly an RC6 Evaluation Interval */
+	gem_quiescent_gpu(i915);
+	usleep(320e3);
+
+	/* Then poll for RC6 to start ticking */
+	igt_assert_eq(read(fd, start, sizeof(start)), sizeof(start));
+	prev = start[1];
+	do {
+		usleep(5e3);
+		igt_assert_eq(read(fd, now, sizeof(now)), sizeof(now));
+		if (now[1] - prev > 1e6) {
+			rc6 = true;
+			break;
+		}
+		prev = now[1];
+	} while (now[0] - start[0] < 1e9);
 
-	residency = rc6_residency(sysfs);
-	igt_require(igt_wait(rc6_residency(sysfs) != residency, 10000, 2));
+	close(fd);
 
-	close(sysfs);
+	igt_debug("rc6 residency %.2fms (delta %.1fms over 5ms), elapsed %.2fms\n",
+		  1e-6 * (now[1] - start[1]),
+		  1e-6 * (now[1] - prev),
+		  1e-6 * (now[0] - start[0]));
+	igt_require(rc6);
 }
 
 static void check_mocs_values(int fd, unsigned engine, uint32_t ctx_id, bool dirty)
diff --git a/tests/meson.build b/tests/meson.build
index 32c2156c6..8f9ead8c3 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -82,7 +82,6 @@ test_progs = [
 	'gem_mmap_gtt',
 	'gem_mmap_offset_exhaustion',
 	'gem_mmap_wc',
-	'gem_mocs_settings',
 	'gem_partial_pwrite_pread',
 	'gem_persistent_relocs',
 	'gem_pipe_control_store_loop',
@@ -279,6 +278,13 @@ test_executables += executable('gem_eio', 'gem_eio.c',
 	   install : true)
 test_progs += 'gem_eio'
 
+test_executables += executable('gem_mocs_settings', 'gem_mocs_settings.c',
+	   dependencies : test_deps + [ lib_igt_perf ],
+	   install_dir : libexecdir,
+	   install_rpath : rpathdir,
+	   install : true)
+test_progs += 'gem_mocs_settings'
+
 test_executables += executable('perf_pmu', 'perf_pmu.c',
 	   dependencies : test_deps + [ lib_igt_perf ],
 	   install_dir : libexecdir,
-- 
2.18.0

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

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

* Re: [PATCH i-g-t v2] igt/gem_mocs_settings: Use i915_pmu to measure rc6 residency
  2018-07-27 10:36 ` [PATCH i-g-t v2] " Chris Wilson
@ 2018-07-27 12:01   ` Matthew Auld
  0 siblings, 0 replies; 4+ messages in thread
From: Matthew Auld @ 2018-07-27 12:01 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev, Intel Graphics Development

On 27 July 2018 at 11:36, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> Use the perf pmu interface for lowlevel rc6 measurement, hopefully for
> greater stability.
>
> v2: Fix timeout to run for 1s, not one pass!
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2018-07-27 12:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-26 20:30 [PATCH i-g-t] igt/gem_mocs_settings: Use i915_pmu to measure rc6 residency Chris Wilson
2018-07-26 20:33 ` Chris Wilson
2018-07-27 10:36 ` [PATCH i-g-t v2] " Chris Wilson
2018-07-27 12:01   ` Matthew Auld

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.