From patchwork Mon Jun 18 20:49:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10472677 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 3DE24600CC for ; Mon, 18 Jun 2018 20:49:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EDDE289EE for ; Mon, 18 Jun 2018 20:49:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2396528A0A; Mon, 18 Jun 2018 20:49:44 +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 2FB24289EE for ; Mon, 18 Jun 2018 20:49:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 843E86E184; Mon, 18 Jun 2018 20:49:42 +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 74D276E172; Mon, 18 Jun 2018 20:49:40 +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 12086374-1500050 for multiple; Mon, 18 Jun 2018 21:49:31 +0100 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Mon, 18 Jun 2018 21:49:30 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Mon, 18 Jun 2018 21:49:28 +0100 Message-Id: <20180618204929.5211-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.17.1 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 1/2] 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 c4579e55b..3327fe079 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, @@ -591,6 +636,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 |