From patchwork Tue Feb 20 16:53:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10230515 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 016E0601E7 for ; Tue, 20 Feb 2018 16:53:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4E4128748 for ; Tue, 20 Feb 2018 16:53:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D833D2878F; Tue, 20 Feb 2018 16:53:31 +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 5F5DE287B6 for ; Tue, 20 Feb 2018 16:53:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 109F16E8C4; Tue, 20 Feb 2018 16:53:30 +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 8C2156E8C6; Tue, 20 Feb 2018 16:53:28 +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 10754153-1500050 for multiple; Tue, 20 Feb 2018 16:53:21 +0000 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Tue, 20 Feb 2018 16:53:20 +0000 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Tue, 20 Feb 2018 16:53:18 +0000 Message-Id: <20180220165320.796-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.16.1 X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Subject: [Intel-gfx] [igt CI 1/3] igt/gem_exec_schedule: Trim max number of contexts used 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 icl offers a much reduced context space, and in its simplest setup we cannot allocate one context per priority level, so trim the number and reuse the same context for multiple priority requests. v2: Bump the MAX to 1024 (still lower than the ~4096 previously in use) v3: Also limit NCTX to MAX_CONTEXTS for wide-* Signed-off-by: Chris Wilson Acked-by: Antonio Argenziano Reviewed-by: Joonas Lahtinen --- tests/gem_exec_schedule.c | 58 ++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/tests/gem_exec_schedule.c b/tests/gem_exec_schedule.c index 05f7ae38..1fc7c697 100644 --- a/tests/gem_exec_schedule.c +++ b/tests/gem_exec_schedule.c @@ -43,6 +43,8 @@ #define BUSY_QLEN 8 #define MAX_ELSP_QLEN 16 +#define MAX_CONTEXTS 1024 + IGT_TEST_DESCRIPTION("Check that we can control the order of execution"); static void store_dword(int fd, uint32_t ctx, unsigned ring, @@ -556,8 +558,8 @@ static void preemptive_hang(int fd, unsigned ring) static void deep(int fd, unsigned ring) { #define XS 8 - const unsigned int nctx = MAX_PRIO - MIN_PRIO; - const unsigned size = ALIGN(4*nctx, 4096); + const unsigned int nreq = MAX_PRIO - MIN_PRIO; + const unsigned size = ALIGN(4*nreq, 4096); struct timespec tv = {}; struct cork cork; uint32_t result, dep[XS]; @@ -565,10 +567,9 @@ static void deep(int fd, unsigned ring) uint32_t *ptr; uint32_t *ctx; - ctx = malloc(sizeof(*ctx) * nctx); - for (int n = 0; n < nctx; n++) { + ctx = malloc(sizeof(*ctx) * MAX_CONTEXTS); + for (int n = 0; n < MAX_CONTEXTS; n++) { ctx[n] = gem_context_create(fd); - gem_context_set_priority(fd, ctx[n], MAX_PRIO - nctx + n); } result = gem_create(fd, size); @@ -592,7 +593,7 @@ static void deep(int fd, unsigned ring) execbuf.buffers_ptr = to_user_pointer(obj); execbuf.buffer_count = XS + 2; execbuf.flags = ring; - for (int n = 0; n < nctx; n++) { + for (int n = 0; n < MAX_CONTEXTS; n++) { execbuf.rsvd1 = ctx[n]; gem_execbuf(fd, &execbuf); } @@ -603,22 +604,29 @@ static void deep(int fd, unsigned ring) plug(fd, &cork); /* Create a deep dependency chain, with a few branches */ - for (int n = 0; n < nctx && igt_seconds_elapsed(&tv) < 8; n++) + for (int n = 0; n < nreq && igt_seconds_elapsed(&tv) < 8; n++) { + uint32_t context = ctx[n % MAX_CONTEXTS]; + gem_context_set_priority(fd, context, MAX_PRIO - nreq + n); + for (int m = 0; m < XS; m++) - store_dword(fd, ctx[n], ring, dep[m], 4*n, ctx[n], cork.handle, I915_GEM_DOMAIN_INSTRUCTION); + store_dword(fd, context, ring, dep[m], 4*n, context, cork.handle, I915_GEM_DOMAIN_INSTRUCTION); + } + + for (int n = 0; n < nreq && igt_seconds_elapsed(&tv) < 6; n++) { + uint32_t context = ctx[n % MAX_CONTEXTS]; + gem_context_set_priority(fd, context, MAX_PRIO - nreq + n); - for (int n = 0; n < nctx && igt_seconds_elapsed(&tv) < 6; n++) { for (int m = 0; m < XS; m++) { - store_dword(fd, ctx[n], ring, result, 4*n, ctx[n], dep[m], 0); - store_dword(fd, ctx[n], ring, result, 4*m, ctx[n], 0, I915_GEM_DOMAIN_INSTRUCTION); + store_dword(fd, context, ring, result, 4*n, context, dep[m], 0); + store_dword(fd, context, ring, result, 4*m, context, 0, I915_GEM_DOMAIN_INSTRUCTION); } - expected = ctx[n]; + expected = context; } unplug_show_queue(fd, &cork, ring); igt_require(expected); /* too slow */ - for (int n = 0; n < nctx; n++) + for (int n = 0; n < MAX_CONTEXTS; n++) gem_context_destroy(fd, ctx[n]); for (int m = 0; m < XS; m++) { @@ -627,8 +635,8 @@ static void deep(int fd, unsigned ring) I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); gem_close(fd, dep[m]); - for (int n = 0; n < nctx; n++) - igt_assert_eq_u32(ptr[n], ctx[n]); + for (int n = 0; n < nreq; n++) + igt_assert_eq_u32(ptr[n], ctx[n % MAX_CONTEXTS]); munmap(ptr, size); } @@ -719,7 +727,6 @@ static unsigned int measure_ring_size(int fd, unsigned int ring) static void wide(int fd, unsigned ring) { -#define NCTX 4096 struct timespec tv = {}; unsigned int ring_size = measure_ring_size(fd, ring); @@ -729,11 +736,11 @@ static void wide(int fd, unsigned ring) uint32_t *ctx; unsigned int count; - ctx = malloc(sizeof(*ctx)*NCTX); - for (int n = 0; n < NCTX; n++) + ctx = malloc(sizeof(*ctx)*MAX_CONTEXTS); + for (int n = 0; n < MAX_CONTEXTS; n++) ctx[n] = gem_context_create(fd); - result = gem_create(fd, 4*NCTX); + result = gem_create(fd, 4*MAX_CONTEXTS); plug(fd, &cork); @@ -741,28 +748,27 @@ static void wide(int fd, unsigned ring) for (count = 0; igt_seconds_elapsed(&tv) < 5 && count < ring_size; count++) { - for (int n = 0; n < NCTX; n++) { + for (int n = 0; n < MAX_CONTEXTS; n++) { store_dword(fd, ctx[n], ring, result, 4*n, ctx[n], cork.handle, I915_GEM_DOMAIN_INSTRUCTION); } } igt_info("Submitted %d requests over %d contexts in %.1fms\n", - count, NCTX, igt_nsec_elapsed(&tv) * 1e-6); + count, MAX_CONTEXTS, igt_nsec_elapsed(&tv) * 1e-6); unplug_show_queue(fd, &cork, ring); - for (int n = 0; n < NCTX; n++) + for (int n = 0; n < MAX_CONTEXTS; n++) gem_context_destroy(fd, ctx[n]); - ptr = gem_mmap__gtt(fd, result, 4*NCTX, PROT_READ); + ptr = gem_mmap__gtt(fd, result, 4*MAX_CONTEXTS, PROT_READ); gem_set_domain(fd, result, /* no write hazard lies! */ I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); - for (int n = 0; n < NCTX; n++) + for (int n = 0; n < MAX_CONTEXTS; n++) igt_assert_eq_u32(ptr[n], ctx[n]); - munmap(ptr, 4*NCTX); + munmap(ptr, 4*MAX_CONTEXTS); gem_close(fd, result); free(ctx); -#undef NCTX } static void reorder_wide(int fd, unsigned ring)