From patchwork Tue Jun 19 10:49:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10474031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8946B6029B for ; Tue, 19 Jun 2018 10:49:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72190286C1 for ; Tue, 19 Jun 2018 10:49:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6731B28A69; Tue, 19 Jun 2018 10:49:42 +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 27454286C1 for ; Tue, 19 Jun 2018 10:49:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A1B956E514; Tue, 19 Jun 2018 10:49:41 +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 5B6246E514; Tue, 19 Jun 2018 10:49:39 +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 12091683-1500050 for multiple; Tue, 19 Jun 2018 11:49:33 +0100 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Tue, 19 Jun 2018 11:49:32 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Tue, 19 Jun 2018 11:49:20 +0100 Message-Id: <20180619104920.17528-6-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.18.0.rc2 In-Reply-To: <20180619104920.17528-1-chris@chris-wilson.co.uk> References: <20180619104920.17528-1-chris@chris-wilson.co.uk> X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Subject: [Intel-gfx] [PATCH i-g-t 6/6] igt/gem_exec_latency: Measure polling latency between batches 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 Signed-off-by: Chris Wilson --- tests/gem_exec_latency.c | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/gem_exec_latency.c b/tests/gem_exec_latency.c index d64dd73ab..ea2e4c681 100644 --- a/tests/gem_exec_latency.c +++ b/tests/gem_exec_latency.c @@ -60,6 +60,51 @@ static unsigned int ring_size; +static void +poll_ring(int fd, unsigned ring, const char *name) +{ + struct timespec tv = {}; + unsigned long cycles; + igt_spin_t *spin[2]; + uint64_t elapsed; + uint32_t cmd; + + gem_require_ring(fd, ring); + igt_require(gem_can_store_dword(fd, ring)); + + spin[0] = __igt_spin_batch_new_poll(fd, 0, ring); + igt_assert(spin[0]->running); + cmd = *spin[0]->batch; + + spin[1] = __igt_spin_batch_new_poll(fd, 0, ring); + igt_assert(spin[1]->running); + igt_assert(cmd == *spin[1]->batch); + + igt_spin_batch_end(spin[0]); + while (!READ_ONCE(*spin[1]->running)) + ; + igt_assert(!gem_bo_busy(fd, spin[0]->handle)); + + cycles = 0; + while ((elapsed = igt_nsec_elapsed(&tv)) < 2ull << 30) { + unsigned int idx = cycles++ & 1; + + *spin[idx]->batch = cmd; + *spin[idx]->running = 0; + gem_execbuf(fd, &spin[idx]->execbuf); + + igt_spin_batch_end(spin[!idx]); + while (!READ_ONCE(*spin[idx]->running)) + ; + } + + igt_info("%s completed %ld cycles: %.3f us\n", + name, cycles, elapsed*1e-3/cycles); + + igt_spin_batch_free(fd, spin[1]); + igt_spin_batch_free(fd, spin[0]); +} + #define RCS_TIMESTAMP (0x2000 + 0x358) static void latency_on_ring(int fd, unsigned ring, const char *name, @@ -611,6 +656,11 @@ igt_main e->exec_id | e->flags, e->name, 0); + igt_subtest_f("%s-poll", e->name) + poll_ring(device, + e->exec_id | e->flags, + e->name); + igt_subtest_f("%s-rtidle-submit", e->name) rthog_latency_on_ring(device, e->exec_id |