From patchwork Tue May 26 13:00:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 11570525 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0039C90 for ; Tue, 26 May 2020 13:00:31 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD0862086A for ; Tue, 26 May 2020 13:00:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD0862086A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=chris-wilson.co.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6FD586E1BA; Tue, 26 May 2020 13:00: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 1FD9C6E1BA; Tue, 26 May 2020 13:00: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 21297248-1500050 for multiple; Tue, 26 May 2020 14:00:20 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Tue, 26 May 2020 14:00:18 +0100 Message-Id: <20200526130018.20163-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.27.0.rc0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] lib: Randomise spinner location to reduce relocation risk X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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, Chris Wilson Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Randomise the position of the spinner to reduce the number of relocations we might require. Signed-off-by: Chris Wilson --- lib/igt_dummyload.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c index a733bd674..776e97baa 100644 --- a/lib/igt_dummyload.c +++ b/lib/igt_dummyload.c @@ -82,8 +82,21 @@ emit_recursive_batch(igt_spin_t *spin, unsigned int nengine; int fence_fd = -1; uint32_t *cs, *batch; + uint32_t addr; int i; + /* + * Pick a random location for our spinner et al. + * + * If available, the kernel will place our objects in our hinted + * locations and we will avoid having to perform any relocations. + * + * It must be a valid location (or else the kernel will be forced + * to select one for us) and so must be within the GTT and suitably + * aligned. For simplicity, stick to the low 32bit addresses. + */ + addr = (random() % 1024 + 1024) << 12; + nengine = 0; if (opts->engine == ALL_ENGINES) { struct intel_execution_engine2 *engine; @@ -114,6 +127,9 @@ emit_recursive_batch(igt_spin_t *spin, execbuf->buffer_count++; cs = batch; + obj[BATCH].offset = addr; + addr += BATCH_SIZE; + if (opts->dependency) { igt_assert(!(opts->flags & IGT_SPIN_POLL_RUN)); @@ -152,11 +168,13 @@ emit_recursive_batch(igt_spin_t *spin, spin->poll_handle, 0, 4096, PROT_READ | PROT_WRITE); + addr += 4096; /* guard page */ + obj[SCRATCH].offset = addr; + addr += 4096; igt_assert_eq(spin->poll[SPIN_POLL_START_IDX], 0); - /* batch is first */ - r->presumed_offset = 4096; + r->presumed_offset = obj[SCRATCH].offset; r->target_handle = obj[SCRATCH].handle; r->offset = sizeof(uint32_t) * 1; r->delta = sizeof(uint32_t) * SPIN_POLL_START_IDX; @@ -231,7 +249,7 @@ emit_recursive_batch(igt_spin_t *spin, spin->condition[0] = 0xffffffff; spin->condition[1] = 0xffffffff; - r->presumed_offset = 0; + r->presumed_offset = obj[BATCH].offset; r->target_handle = obj[BATCH].handle; r->offset = (cs + 2 - batch) * sizeof(*cs); r->read_domains = I915_GEM_DOMAIN_COMMAND; @@ -239,28 +257,29 @@ emit_recursive_batch(igt_spin_t *spin, *cs++ = MI_COND_BATCH_BUFFER_END | MI_DO_COMPARE | 2; *cs++ = MI_BATCH_BUFFER_END; - *cs++ = r->delta; + *cs++ = r->presumed_offset + r->delta; *cs++ = 0; } /* recurse */ r = &relocs[obj[BATCH].relocation_count++]; r->target_handle = obj[BATCH].handle; + r->presumed_offset = obj[BATCH].offset; r->offset = (cs + 1 - batch) * sizeof(*cs); r->read_domains = I915_GEM_DOMAIN_COMMAND; r->delta = LOOP_START_OFFSET; if (gen >= 8) { *cs++ = MI_BATCH_BUFFER_START | 1 << 8 | 1; - *cs++ = r->delta; + *cs++ = r->presumed_offset + r->delta; *cs++ = 0; } else if (gen >= 6) { *cs++ = MI_BATCH_BUFFER_START | 1 << 8; - *cs++ = r->delta; + *cs++ = r->presumed_offset + r->delta; } else { *cs++ = MI_BATCH_BUFFER_START | 2 << 6; if (gen < 4) r->delta |= 1; - *cs = r->delta; + *cs = r->presumed_offset + r->delta; cs++; } obj[BATCH].relocs_ptr = to_user_pointer(relocs);