diff mbox series

[PATH,i-g-t,07/13] gem_wsim: Make batches preemptable by default

Message ID 20180905134939.2942-8-tvrtko.ursulin@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series Tracing & workload simulation misc patches | expand

Commit Message

Tvrtko Ursulin Sept. 5, 2018, 1:49 p.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

MI_NOOP cannot be preempted which means up to now gem_wsim workloads were
preemptable on batch buffer granularity only.

Add MI_ARB_CHK every 100us so the new default is mid-batch preemption.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 benchmarks/gem_wsim.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Chris Wilson Sept. 7, 2018, 8:48 a.m. UTC | #1
Quoting Tvrtko Ursulin (2018-09-05 14:49:33)
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> MI_NOOP cannot be preempted which means up to now gem_wsim workloads were
> preemptable on batch buffer granularity only.
> 
> Add MI_ARB_CHK every 100us so the new default is mid-batch preemption.

Sure you don't want this configurable to adjust between different
worklods? I'm just thinking that some of the fixed function stuff may
have vastly different preemption granularity.
-Chris
diff mbox series

Patch

diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
index 0c52ec567430..7f2d0c83a0e7 100644
--- a/benchmarks/gem_wsim.c
+++ b/benchmarks/gem_wsim.c
@@ -685,6 +685,25 @@  static unsigned long get_bb_sz(unsigned int duration)
 		     nop_calibration_us, sizeof(uint32_t));
 }
 
+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);
+	unsigned int i;
+	uint32_t *ptr;
+
+	gem_set_domain(fd, w->bb_handle,
+		       I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_WC);
+
+	ptr = gem_mmap__wc(fd, w->bb_handle, 0, w->bb_sz, PROT_WRITE);
+
+	for (i = arb_period; i < w->bb_sz / sizeof(uint32_t); i += arb_period)
+		ptr[i] = 0x5 << 23; /* MI_ARB_CHK */
+
+	munmap(ptr, w->bb_sz);
+}
+
 static void
 terminate_bb(struct w_step *w, unsigned int flags)
 {
@@ -839,6 +858,7 @@  alloc_step_batch(struct workload *wrk, struct w_step *w, unsigned int flags)
 
 	w->bb_sz = get_bb_sz(w->duration.max);
 	w->bb_handle = w->obj[j].handle = gem_create(fd, w->bb_sz);
+	init_bb(w, flags);
 	terminate_bb(w, flags);
 
 	if (flags & SEQNO) {