diff mbox series

[i-g-t] igt/gem_ctx_switch: Show the combined ctx-switch latency

Message ID 20180815111553.11906-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [i-g-t] igt/gem_ctx_switch: Show the combined ctx-switch latency | expand

Commit Message

Chris Wilson Aug. 15, 2018, 11:15 a.m. UTC
Since we submit from several processes to the same engine for the forked
tests, the total number of context switches is the sum of each process
and needs to be combined together to compute the individual cs latency.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/gem_ctx_switch.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Chris Wilson Aug. 15, 2018, 11:19 a.m. UTC | #1
Quoting Chris Wilson (2018-08-15 12:15:53)
> +       if (ncpus > 1) {
> +               unsigned long total;

Imagine the hidden = 0 here.
-Chris
Mika Kuoppala Aug. 15, 2018, 12:19 p.m. UTC | #2
Chris Wilson <chris@chris-wilson.co.uk> writes:

> Quoting Chris Wilson (2018-08-15 12:15:53)
>> +       if (ncpus > 1) {
>> +               unsigned long total;
>
> Imagine the hidden = 0 here.

I did. With imagination realized,

Perhaps on some rainy day someone will move elapsed into lib.

Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>

-Mika
diff mbox series

Patch

diff --git a/tests/gem_ctx_switch.c b/tests/gem_ctx_switch.c
index 6770e001f..58b9bfd3e 100644
--- a/tests/gem_ctx_switch.c
+++ b/tests/gem_ctx_switch.c
@@ -94,8 +94,15 @@  static void single(int fd, uint32_t handle,
 	struct drm_i915_gem_exec_object2 obj;
 	struct drm_i915_gem_relocation_entry reloc;
 	uint32_t contexts[64];
+	struct {
+		double elapsed;
+		unsigned long count;
+	} *shared;
 	int n;
 
+	shared = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+	igt_assert(shared != MAP_FAILED);
+
 	gem_require_ring(fd, e->exec_id | e->flags);
 
 	for (n = 0; n < 64; n++) {
@@ -163,11 +170,31 @@  static void single(int fd, uint32_t handle,
 		igt_info("[%d] %s: %'u cycles: %.3fus%s\n",
 			 child, e->name, count, elapsed(&start, &now)*1e6 / count,
 			 flags & INTERRUPTIBLE ? " (interruptible)" : "");
+
+		shared[child].elapsed = elapsed(&start, &now);
+		shared[child].count = count;
 	}
 	igt_waitchildren();
 
+	if (ncpus > 1) {
+		unsigned long total;
+		double max = 0;
+
+		for (n = 0; n < ncpus; n++) {
+			total += shared[n].count;
+			if (shared[n].elapsed > max)
+				max = shared[n].elapsed;
+		}
+
+		igt_info("Total %s: %'lu cycles: %.3fus%s\n",
+			 e->name, total, max*1e6 / total,
+			 flags & INTERRUPTIBLE ? " (interruptible)" : "");
+	}
+
 	for (n = 0; n < 64; n++)
 		gem_context_destroy(fd, contexts[n]);
+
+	munmap(shared, 4096);
 }
 
 static void all(int fd, uint32_t handle, unsigned flags, int timeout)