[igt-dev] [PATCH i-g-t v3] igt/gem_measure_ring_size_inflight: Measure smallest inflight ring size
Antonio Argenziano
antonio.argenziano at intel.com
Wed Mar 21 21:08:28 UTC 2018
Some tests measure the render's ring size but are actually meant to
measure the smallest across all engines. This patch adds measuring the
smallest size in gem_measure_ring_size_inflight() given the appropriate
parameter.
v2:
- Only expose high level API. (Chris)
v3:
- Use ALL_ENGINES macro.
Suggested-by: Chris Wilson <chris at chris-wilson.co.uk>
Signed-off-by: Antonio Argenziano <antonio.argenziano at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk> #2
---
lib/i915/gem_ring.c | 53 +++++++++++++++++++++++++++++++++---------------
tests/gem_busy.c | 2 +-
tests/gem_exec_await.c | 2 +-
tests/gem_exec_fence.c | 2 +-
tests/gem_exec_latency.c | 2 +-
tests/gem_ringfill.c | 2 +-
6 files changed, 42 insertions(+), 21 deletions(-)
diff --git a/lib/i915/gem_ring.c b/lib/i915/gem_ring.c
index df92e620..10d2f2cd 100644
--- a/lib/i915/gem_ring.c
+++ b/lib/i915/gem_ring.c
@@ -30,6 +30,7 @@
#include "drmtest.h"
#include "ioctl_wrappers.h"
#include "igt_dummyload.h"
+#include "igt_gt.h"
static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
{
@@ -47,22 +48,8 @@ static void alarm_handler(int sig)
{
}
-/**
- * gem_measure_ring_inflight:
- * @fd: open i915 drm file descriptor
- * @engine: execbuf engine flag
- * @flags: flags to affect measurement:
- * - MEASURE_RING_NEW_CTX: use a new context to account for the space
- * used by the lrc init.
- *
- * This function calculates the maximum number of batches that can be inserted
- * at the same time in the ring on the selected engine.
- *
- * Returns:
- * Number of batches that fit in the ring
- */
-unsigned int
-gem_measure_ring_inflight(int fd, unsigned int engine, enum measure_ring_flags flags)
+static unsigned int
+__gem_measure_ring_inflight(int fd, unsigned int engine, enum measure_ring_flags flags)
{
struct sigaction old_sa, sa = { .sa_handler = alarm_handler };
struct drm_i915_gem_exec_object2 obj[2];
@@ -129,3 +116,37 @@ gem_measure_ring_inflight(int fd, unsigned int engine, enum measure_ring_flags f
return count;
}
+
+/**
+ * gem_measure_ring_inflight:
+ * @fd: open i915 drm file descriptor
+ * @engine: execbuf engine flag. Use macro ALL_ENGINES to get the minimum
+ * size across all physical engines.
+ * @flags: flags to affect measurement:
+ * - MEASURE_RING_NEW_CTX: use a new context to account for the space
+ * used by the lrc init.
+ *
+ * This function calculates the maximum number of batches that can be inserted
+ * at the same time in the ring on the selected engine.
+ *
+ * Returns:
+ * Number of batches that fit in the ring
+ */
+unsigned int
+gem_measure_ring_inflight(int fd, unsigned int engine, enum measure_ring_flags flags)
+{
+ if (engine == ALL_ENGINES) {
+ unsigned int global_min = ~0u;
+
+ for_each_physical_engine(fd, engine) {
+ unsigned int engine_min = __gem_measure_ring_inflight(fd, engine, flags);
+
+ if (engine_min < global_min)
+ global_min = engine_min;
+ }
+
+ return global_min;
+ }
+
+ return __gem_measure_ring_inflight(fd, engine, flags);
+}
diff --git a/tests/gem_busy.c b/tests/gem_busy.c
index fcff51a2..f564651b 100644
--- a/tests/gem_busy.c
+++ b/tests/gem_busy.c
@@ -301,7 +301,7 @@ static void xchg_u32(void *array, unsigned i, unsigned j)
static void close_race(int fd)
{
const unsigned int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
- const unsigned int nhandles = gem_measure_ring_inflight(fd, 0, 0) / 2;
+ const unsigned int nhandles = gem_measure_ring_inflight(fd, ALL_ENGINES, 0) / 2;
unsigned int engines[16], nengine;
unsigned long *control;
uint32_t *handles;
diff --git a/tests/gem_exec_await.c b/tests/gem_exec_await.c
index 2ff180b0..b0d5c904 100644
--- a/tests/gem_exec_await.c
+++ b/tests/gem_exec_await.c
@@ -234,7 +234,7 @@ igt_main
igt_require_gem(device);
gem_submission_print_method(device);
- ring_size = gem_measure_ring_inflight(device, 0, 0) - 10;
+ ring_size = gem_measure_ring_inflight(device, ALL_ENGINES, 0) - 10;
if (!gem_has_execlists(device))
ring_size /= 2;
igt_info("Ring size: %d batches\n", ring_size);
diff --git a/tests/gem_exec_fence.c b/tests/gem_exec_fence.c
index 26bde788..60f80b0d 100644
--- a/tests/gem_exec_fence.c
+++ b/tests/gem_exec_fence.c
@@ -1537,7 +1537,7 @@ igt_main
long ring_size = 0;
igt_fixture {
- ring_size = gem_measure_ring_inflight(i915, 0, 0) - 1;
+ ring_size = gem_measure_ring_inflight(i915, ALL_ENGINES, 0) - 1;
igt_info("Ring size: %ld batches\n", ring_size);
igt_require(ring_size);
diff --git a/tests/gem_exec_latency.c b/tests/gem_exec_latency.c
index f0e13419..9498c092 100644
--- a/tests/gem_exec_latency.c
+++ b/tests/gem_exec_latency.c
@@ -363,7 +363,7 @@ igt_main
gem_submission_print_method(device);
- ring_size = gem_measure_ring_inflight(device, 0, 0);
+ ring_size = gem_measure_ring_inflight(device, ALL_ENGINES, 0);
igt_info("Ring size: %d batches\n", ring_size);
igt_require(ring_size > 8);
ring_size -= 8; /* leave some spare */
diff --git a/tests/gem_ringfill.c b/tests/gem_ringfill.c
index eea1d403..c728e1cd 100644
--- a/tests/gem_ringfill.c
+++ b/tests/gem_ringfill.c
@@ -272,7 +272,7 @@ igt_main
master = true;
}
- ring_size = gem_measure_ring_inflight(fd, 0, 0);
+ ring_size = gem_measure_ring_inflight(fd, ALL_ENGINES, 0);
igt_info("Ring size: %d batches\n", ring_size);
igt_require(ring_size);
}
--
2.16.2
More information about the igt-dev
mailing list