From: Tvrtko Ursulin <tursulin@ursulin.net>
To: igt-dev@lists.freedesktop.org
Cc: Intel-gfx@lists.freedesktop.org
Subject: [PATH i-g-t 08/13] gem_wsim: Per context preemption point control
Date: Wed, 5 Sep 2018 14:49:34 +0100 [thread overview]
Message-ID: <20180905134939.2942-9-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <20180905134939.2942-1-tvrtko.ursulin@linux.intel.com>
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Allow workloads to specify frequency of preemption points per context.
New workload command ('X') is added to allow this.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
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,...
<uint>.<str>.<uint>[-<uint>].<int <= 0>[/<int <= 0>][...].<0|1>,...
-P.<uint>.<int>
+P|X.<uint>.<int>
d|p|s|t|q|a.<int>,...
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.
--
2.17.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2018-09-05 13:49 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-05 13:49 [PATH i-g-t 00/13] Tracing & workload simulation misc patches Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 01/13] trace.pl: Fix frequency timeline Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 02/13] trace.pl: Use undocumented -o to perf record to allow tee Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 03/13] gem_wsim: Fix BCS usage under VCS2 remap warning Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 04/13] gem_wsim: Check sleep times Tvrtko Ursulin
2018-09-05 14:09 ` [igt-dev] " Ville Syrjälä
2018-09-07 8:37 ` Tvrtko Ursulin
2018-09-07 8:45 ` Chris Wilson
2018-09-07 14:13 ` Ville Syrjälä
2018-09-07 16:00 ` Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 05/13] gem_wsim: Make workload commands case sensitive Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 06/13] gem_wsim: Context priority support Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 07/13] gem_wsim: Make batches preemptable by default Tvrtko Ursulin
2018-09-07 8:48 ` [igt-dev] " Chris Wilson
2018-09-05 13:49 ` Tvrtko Ursulin [this message]
2018-09-07 8:49 ` [igt-dev] [PATH i-g-t 08/13] gem_wsim: Per context preemption point control Chris Wilson
2018-09-07 8:51 ` Chris Wilson
2018-09-05 13:49 ` [PATH i-g-t 09/13] media-bench: Update for engine=class:instance tracepoints Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 10/13] media-bench: Protect against incorrect -b syntax Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 11/13] media-bench: Fix tracing of direct workloads Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 12/13] media-bench: Write out trace files directly Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 13/13] media-bench: Add mixed mode evaluation Tvrtko Ursulin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180905134939.2942-9-tvrtko.ursulin@linux.intel.com \
--to=tursulin@ursulin.net \
--cc=Intel-gfx@lists.freedesktop.org \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox