igt-dev.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t] igt/gem_ctx_switch: Show the combined ctx-switch latency
Date: Wed, 15 Aug 2018 12:15:53 +0100	[thread overview]
Message-ID: <20180815111553.11906-1-chris@chris-wilson.co.uk> (raw)

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

             reply	other threads:[~2018-08-15 11:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-15 11:15 Chris Wilson [this message]
2018-08-15 11:19 ` [igt-dev] [PATCH i-g-t] igt/gem_ctx_switch: Show the combined ctx-switch latency 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180815111553.11906-1-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).