igt-dev.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] igt/gem_ctx_switch: Show the combined ctx-switch latency
@ 2018-08-15 11:15 Chris Wilson
  2018-08-15 11:19 ` Chris Wilson
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Chris Wilson @ 2018-08-15 11:15 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev

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(+)

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)
-- 
2.18.0

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

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

end of thread, other threads:[~2018-08-15 21:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-15 11:15 [igt-dev] [PATCH i-g-t] igt/gem_ctx_switch: Show the combined ctx-switch latency Chris Wilson
2018-08-15 11:19 ` Chris Wilson
2018-08-15 12:19   ` [igt-dev] [Intel-gfx] " Mika Kuoppala
2018-08-15 16:28 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-08-15 21:31 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).