From patchwork Fri Mar 16 16:03:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10288869 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 3E92A602C2 for ; Fri, 16 Mar 2018 16:03:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EE821FFE4 for ; Fri, 16 Mar 2018 16:03:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 231E428FA9; Fri, 16 Mar 2018 16:03:39 +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=-4.2 required=2.0 tests=BAYES_00, 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 ECF921FFE4 for ; Fri, 16 Mar 2018 16:03:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0BE266EBAD; Fri, 16 Mar 2018 16:03:36 +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 9FF0C6EBA7 for ; Fri, 16 Mar 2018 16:03:33 +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 11056351-1500050 for multiple; Fri, 16 Mar 2018 16:03:26 +0000 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Fri, 16 Mar 2018 16:03:26 +0000 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Fri, 16 Mar 2018 16:03:25 +0000 Message-Id: <20180316160325.15554-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.16.2 X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Subject: [Intel-gfx] [PATCH igt] igt/gem_ctx_switch: Measure qlen for timing loops 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Some platforms may execute the heavy workload very slowly, such that using a batch of 1024 takes tens of seconds and immediately overrunning the 5s timeout on a pass. Added up over a few dozen passes, this turns a 120 second test into 10 minutes. Counter this by doing a warmup loop to estimate the appropriate queue len for timing. Signed-off-by: Chris Wilson Reviewed-by: Joonas Lahtinen --- tests/gem_ctx_switch.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/tests/gem_ctx_switch.c b/tests/gem_ctx_switch.c index 4efece14..8d164398 100644 --- a/tests/gem_ctx_switch.c +++ b/tests/gem_ctx_switch.c @@ -141,7 +141,7 @@ static void all(int fd, uint32_t handle, unsigned flags, int timeout) const char *name[16]; uint32_t contexts[65]; unsigned int nengine; - int n; + int n, qlen; nengine = 0; for_each_physical_engine(fd, e) { @@ -165,6 +165,25 @@ static void all(int fd, uint32_t handle, unsigned flags, int timeout) execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC; igt_require(__gem_execbuf(fd, &execbuf) == 0); gem_sync(fd, handle); + + qlen = 64; + for (n = 0; n < nengine; n++) { + uint64_t saved = execbuf.flags; + struct timespec tv = {}; + + execbuf.flags |= engine[n]; + + igt_nsec_elapsed(&tv); + for (int loop = 0; loop < qlen; loop++) + gem_execbuf(fd, &execbuf); + gem_sync(fd, handle); + + execbuf.flags = saved; + + qlen = qlen * timeout * 1e9 / igt_nsec_elapsed(&tv) / 8 + 1; + } + igt_info("Using timing depth of %d batches\n", qlen); + execbuf.buffers_ptr = to_user_pointer(obj); execbuf.buffer_count = 2; @@ -184,11 +203,12 @@ static void all(int fd, uint32_t handle, unsigned flags, int timeout) clock_gettime(CLOCK_MONOTONIC, &start); do { - for (int loop = 0; loop < 1024; loop++) { + for (int loop = 0; loop < qlen; loop++) { execbuf.rsvd1 = contexts[loop % nctx]; gem_execbuf(fd, &execbuf); } - count += 1024; + count += qlen; + gem_sync(fd, obj[0].handle); clock_gettime(CLOCK_MONOTONIC, &now); } while (elapsed(&start, &now) < timeout); gem_sync(fd, obj[0].handle);