From patchwork Wed Sep 5 13:49:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10588885 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9665915E9 for ; Wed, 5 Sep 2018 13:50:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85D8E2A1DA for ; Wed, 5 Sep 2018 13:50:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A6B32A1EA; Wed, 5 Sep 2018 13:50:00 +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 0B2522A1DA for ; Wed, 5 Sep 2018 13:50:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9B07A6E49C; Wed, 5 Sep 2018 13:49:57 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by gabe.freedesktop.org (Postfix) with ESMTPS id A0C626E4A4 for ; Wed, 5 Sep 2018 13:49:53 +0000 (UTC) Received: by mail-wr1-x42b.google.com with SMTP id z96-v6so7747492wrb.8 for ; Wed, 05 Sep 2018 06:49:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Nt9+Xrt3EbtMAHFZKTodaXtQ2ahViJV0kXMpOYztJxA=; b=WcT3vjrxJhahdTLOe86RATBId9d9sZpgAuB34pso6IBhm9dHIYEPoSCmESpIdZ4SN5 C+2XitOZMY6MZKQ+LRXSrpI262p5rVMnmUoWZZXqX8/NJbWCwuIliHgM60SjEEQt58tT JcLjMSwHKLzknSgRbPLnkp06PPhHbOyln7ziOJ1BPFEJ+WqJUpNiGHoSmFq6tqdoTpP2 GL4tIJSPCtYCXkqENEa309GQFW7OgZ8OIXxyySFxArvO2c7YGlwLteEcFAPVDf8fP3yz RhJ9gRNybjSAqe5GQbdU1rOnnGeIga3bekINHnmVrJIOs1YTmN2UMfCfs40aDuMgTwYF JrsQ== X-Gm-Message-State: APzg51B8ibKki3xzaSs3TUN+ZxEO7NKgmtjoKxo4gV2QZGodXoye1GjK C8+Otr2IuFS3/eygI+PzkzEXb4mHdho= X-Google-Smtp-Source: ANB0VdblC0KUj+vC9rB7Zk5z8AaZ7tfK6fxj5ApnNeK+Ze//yCUH9yd6/TiMCO7f1esIGqxQJ+oQlQ== X-Received: by 2002:a5d:5248:: with SMTP id p8-v6mr26730543wrv.198.1536155392151; Wed, 05 Sep 2018 06:49:52 -0700 (PDT) Received: from localhost.localdomain ([95.144.165.37]) by smtp.gmail.com with ESMTPSA id j66-v6sm2701639wrj.28.2018.09.05.06.49.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Sep 2018 06:49:51 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Wed, 5 Sep 2018 14:49:34 +0100 Message-Id: <20180905134939.2942-9-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180905134939.2942-1-tvrtko.ursulin@linux.intel.com> References: <20180905134939.2942-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATH i-g-t 08/13] gem_wsim: Per context preemption point control 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: Intel-gfx@lists.freedesktop.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin Allow workloads to specify frequency of preemption points per context. New workload command ('X') is added to allow this. Signed-off-by: Tvrtko Ursulin Reviewed-by: Chris Wilson Acked-by: Chris Wilson --- benchmarks/gem_wsim.c | 84 ++++++++++++++++++++++++++++++++++++++++-- benchmarks/wsim/README | 18 ++++++++- 2 files changed, 98 insertions(+), 4 deletions(-) diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c index 7f2d0c83a0e7..6b128a1e9d57 100644 --- a/benchmarks/gem_wsim.c +++ b/benchmarks/gem_wsim.c @@ -83,7 +83,8 @@ enum w_type QD_THROTTLE, SW_FENCE, SW_FENCE_SIGNAL, - CTX_PRIORITY + CTX_PRIORITY, + PREEMPTION }; struct deps @@ -122,6 +123,7 @@ struct w_step unsigned int idx; struct igt_list rq_link; unsigned int request; + unsigned int preempt_us; struct drm_i915_gem_execbuffer2 eb; struct drm_i915_gem_exec_object2 *obj; @@ -443,6 +445,42 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) } else if (!strcmp(field, "f")) { step.type = SW_FENCE; goto add_step; + } else if (!strcmp(field, "X")) { + unsigned int nr = 0; + while ((field = strtok_r(fstart, ".", &fctx)) != + NULL) { + tmp = atoi(field); + if (tmp <= 0 && nr == 0) { + if (verbose) + fprintf(stderr, + "Invalid context at step %u!\n", + nr_steps); + return NULL; + } else if (tmp < 0 && nr == 1) { + if (verbose) + fprintf(stderr, + "Invalid preemption period at step %u!\n", + nr_steps); + return NULL; + } + + if (nr == 0) { + step.context = tmp; + } else if (nr == 1) { + step.period = tmp; + } else { + if (verbose) + fprintf(stderr, + "Invalid preemption format at step %u!\n", + nr_steps); + return NULL; + } + + nr++; + } + + step.type = PREEMPTION; + goto add_step; } tmp = atoi(field); @@ -688,11 +726,14 @@ static unsigned long get_bb_sz(unsigned int duration) static void init_bb(struct w_step *w, unsigned int flags) { - /* Preemption point every 100us. */ - const unsigned int arb_period = get_bb_sz(100) / sizeof(uint32_t); + const unsigned int arb_period = + get_bb_sz(w->preempt_us) / sizeof(uint32_t); unsigned int i; uint32_t *ptr; + if (!arb_period) + return; + gem_set_domain(fd, w->bb_handle, I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_WC); @@ -968,6 +1009,41 @@ prepare_workload(unsigned int id, struct workload *wrk, unsigned int flags) } } + /* Record default preemption. */ + for (i = 0, w = wrk->steps; i < wrk->nr_steps; i++, w++) { + if (w->type == BATCH) + w->preempt_us = 100; + } + + /* + * Scan for contexts with modified preemption config and record their + * preemption period for the following steps belonging to the same + * context. + */ + for (i = 0, w = wrk->steps; i < wrk->nr_steps; i++, w++) { + struct w_step *w2; + int j; + + if (w->type != PREEMPTION) + continue; + + for (j = i + 1; j < wrk->nr_steps; j++) { + w2 = &wrk->steps[j]; + + if (w2->context != w->context) + continue; + else if (w2->type == PREEMPTION) + break; + else if (w2->type != BATCH) + continue; + + w2->preempt_us = w->period; + } + } + + /* + * Allocate batch buffers. + */ for (i = 0, w = wrk->steps; i < wrk->nr_steps; i++, w++) { unsigned int _flags = flags; enum intel_engine_id engine = w->engine; @@ -1872,6 +1948,8 @@ static void *run_workload(void *data) w->priority; } continue; + } else if (w->type == PREEMPTION) { + continue; } if (do_sleep || w->type == PERIOD) { diff --git a/benchmarks/wsim/README b/benchmarks/wsim/README index fd9bff3401af..205cd6c93afb 100644 --- a/benchmarks/wsim/README +++ b/benchmarks/wsim/README @@ -3,7 +3,7 @@ Workload descriptor format ctx.engine.duration_us.dependency.wait,... ..[-].[/][...].<0|1>,... -P.. +P|X.. d|p|s|t|q|a.,... f @@ -24,6 +24,7 @@ Additional workload steps are also supported: 'f' - Create a sync fence. 'a' - Advance the previously created sync fence. 'P' - Context priority. + 'X' - Context preemption control. Engine ids: RCS, BCS, VCS, VCS1, VCS2, VECS @@ -128,3 +129,18 @@ is submitted against it which depends on the batch from context 1. Context priority command is executed at workload runtime and is valid until overriden by another (optional) same context priority change. Actual driver ioctls are executed only if the priority level has changed for the context. + +Context preemption control +-------------------------- + + X.1.0 + 1.RCS.1000.0.0 + X.1.500 + 1.RCS.1000.0.0 + +Context 1 is marked as non-preemptable batches and a batch is sent against 1. +The same context is then marked to have batches which can be preempted every +500us and another batch is submitted. + +Same as with context priority, context preemption commands are valid until +optionally overriden by another preemption control change on the same context.