From patchwork Wed Aug 15 11:15:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10566501 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BE92E139A for ; Wed, 15 Aug 2018 11:16:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF19929DCF for ; Wed, 15 Aug 2018 11:16:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2F2629DDA; Wed, 15 Aug 2018 11:16:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 601E929DCF for ; Wed, 15 Aug 2018 11:16:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C56DC6E332; Wed, 15 Aug 2018 11:16:01 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 39D876E332; Wed, 15 Aug 2018 11:16:00 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 12922557-1500050 for multiple; Wed, 15 Aug 2018 12:15:56 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Wed, 15 Aug 2018 12:15:53 +0100 Message-Id: <20180815111553.11906-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.18.0 Subject: [Intel-gfx] [PATCH i-g-t] igt/gem_ctx_switch: Show the combined ctx-switch latency X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Mika Kuoppala --- 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)