From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 29/32] drm/i915: Apply an execution_mask to the virtual_engine
Date: Wed, 17 Apr 2019 12:43:49 +0100 [thread overview]
Message-ID: <bc55dad4-949a-95ce-7896-576f253dc0ca@linux.intel.com> (raw)
In-Reply-To: <20190417075657.19456-29-chris@chris-wilson.co.uk>
On 17/04/2019 08:56, Chris Wilson wrote:
> Allow the user to direct which physical engines of the virtual engine
> they wish to execute one, as sometimes it is necessary to override the
> load balancing algorithm.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/gt/intel_lrc.c | 58 +++++++++++
> drivers/gpu/drm/i915/gt/selftest_lrc.c | 131 +++++++++++++++++++++++++
> drivers/gpu/drm/i915/i915_request.c | 1 +
> drivers/gpu/drm/i915/i915_request.h | 3 +
> 4 files changed, 193 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
> index d6efd6aa67cb..560a18bb4cbb 100644
> --- a/drivers/gpu/drm/i915/gt/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
> @@ -552,6 +552,18 @@ execlists_context_schedule_out(struct i915_request *rq, unsigned long status)
> intel_engine_context_out(rq->engine);
> execlists_context_status_change(rq, status);
> trace_i915_request_out(rq);
> +
> + /*
> + * If this is part of a virtual engine, its next request may have
> + * been blocked waiting for access to the active context. We have
> + * to kick all the siblings again in case we need to switch (e.g.
> + * the next request is not runnable on this engine). Hopefully,
> + * we will already have submitted the next request before the
> + * tasklet runs and do not need to rebuild each virtual tree
> + * and kick everyone again.
> + */
> + if (rq->engine != rq->hw_context->engine)
> + tasklet_schedule(&rq->hw_context->engine->execlists.tasklet);
Is this needed only for non-default execution_mask? If so it would be
good to limit it to avoid tasklet storm with plain veng.
> }
>
> static u64 execlists_update_context(struct i915_request *rq)
> @@ -779,6 +791,9 @@ static bool virtual_matches(const struct virtual_engine *ve,
> {
> const struct intel_engine_cs *active;
>
> + if (!(rq->execution_mask & engine->mask)) /* We peeked too soon! */
> + return false;
> +
> /*
> * We track when the HW has completed saving the context image
> * (i.e. when we have seen the final CS event switching out of
> @@ -3139,12 +3154,44 @@ static const struct intel_context_ops virtual_context_ops = {
> .destroy = virtual_context_destroy,
> };
>
> +static intel_engine_mask_t virtual_submission_mask(struct virtual_engine *ve)
> +{
> + struct i915_request *rq;
> + intel_engine_mask_t mask;
intel_engine_mask_t throughout is the wrong type for this, even if we
disallowed duplicate siblings, and even more so if we don't.
Either way it seems like the 64 sibling limit needs to be back. Or maybe
only in the bonding case?
> +
> + rq = READ_ONCE(ve->request);
> + if (!rq)
> + return 0;
> +
> + /* The rq is ready for submission; rq->execution_mask is now stable. */
> + mask = rq->execution_mask;
> + if (unlikely(!mask)) {
> + /* Invalid selection, submit to a random engine in error */
> + i915_request_skip(rq, -ENODEV);
When can this happen? It looks like if it can happen we should reject it
earlier. Or if it can't then just assert.
> + mask = ve->siblings[0]->mask;
> + }
> +
> + GEM_TRACE("%s: rq=%llx:%lld, mask=%x, prio=%d\n",
> + ve->base.name,
> + rq->fence.context, rq->fence.seqno,
> + mask, ve->base.execlists.queue_priority_hint);
> +
> + return mask;
> +}
> +
> static void virtual_submission_tasklet(unsigned long data)
> {
> struct virtual_engine * const ve = (struct virtual_engine *)data;
> const int prio = ve->base.execlists.queue_priority_hint;
> + intel_engine_mask_t mask;
> unsigned int n;
>
> + rcu_read_lock();
> + mask = virtual_submission_mask(ve);
> + rcu_read_unlock();
What is the RCU for?
> + if (unlikely(!mask))
> + return;
> +
> local_irq_disable();
> for (n = 0; READ_ONCE(ve->request) && n < ve->num_siblings; n++) {
> struct intel_engine_cs *sibling = ve->siblings[n];
> @@ -3152,6 +3199,17 @@ static void virtual_submission_tasklet(unsigned long data)
> struct rb_node **parent, *rb;
> bool first;
>
> + if (unlikely(!(mask & sibling->mask))) {
> + if (!RB_EMPTY_NODE(&node->rb)) {
> + spin_lock(&sibling->timeline.lock);
> + rb_erase_cached(&node->rb,
> + &sibling->execlists.virtual);
> + RB_CLEAR_NODE(&node->rb);
> + spin_unlock(&sibling->timeline.lock);
> + }
> + continue;
> + }
> +
> spin_lock(&sibling->timeline.lock);
>
> if (!RB_EMPTY_NODE(&node->rb)) {
> diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c
> index f34aa9e042a3..209e51ef13e6 100644
> --- a/drivers/gpu/drm/i915/gt/selftest_lrc.c
> +++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c
> @@ -1480,6 +1480,136 @@ static int live_virtual_engine(void *arg)
> return err;
> }
>
> +static int mask_virtual_engine(struct drm_i915_private *i915,
> + struct intel_engine_cs **siblings,
> + unsigned int nsibling)
> +{
> + struct i915_request *request[MAX_ENGINE_INSTANCE + 1];
> + struct i915_gem_context *ctx;
> + struct intel_context *ve;
> + struct igt_live_test t;
> + unsigned int n;
> + int err;
> +
> + /*
> + * Check that by setting the execution mask on a request, we can
> + * restrict it to our desired engine within the virtual engine.
> + */
> +
> + ctx = kernel_context(i915);
> + if (!ctx)
> + return -ENOMEM;
> +
> + ve = intel_execlists_create_virtual(ctx, siblings, nsibling);
> + if (IS_ERR(ve)) {
> + err = PTR_ERR(ve);
> + goto out_close;
> + }
> +
> + err = intel_context_pin(ve);
> + if (err)
> + goto out_put;
> +
> + err = igt_live_test_begin(&t, i915, __func__, ve->engine->name);
> + if (err)
> + goto out_unpin;
> +
> + for (n = 0; n < nsibling; n++) {
> + request[n] = i915_request_create(ve);
> + if (IS_ERR(request)) {
> + err = PTR_ERR(request);
> + nsibling = n;
> + goto out;
> + }
> +
> + /* Reverse order as it's more likely to be unnatural */
> + request[n]->execution_mask = siblings[nsibling - n - 1]->mask;
> +
> + i915_request_get(request[n]);
> + i915_request_add(request[n]);
> + }
> +
> + for (n = 0; n < nsibling; n++) {
> + if (i915_request_wait(request[n], I915_WAIT_LOCKED, HZ / 10) < 0) {
> + pr_err("%s(%s): wait for %llx:%lld timed out\n",
> + __func__, ve->engine->name,
> + request[n]->fence.context,
> + request[n]->fence.seqno);
> +
> + GEM_TRACE("%s(%s) failed at request %llx:%lld\n",
> + __func__, ve->engine->name,
> + request[n]->fence.context,
> + request[n]->fence.seqno);
> + GEM_TRACE_DUMP();
> + i915_gem_set_wedged(i915);
> + err = -EIO;
> + goto out;
> + }
> +
> + if (request[n]->engine != siblings[nsibling - n - 1]) {
> + pr_err("Executed on wrong sibling '%s', expected '%s'\n",
> + request[n]->engine->name,
> + siblings[nsibling - n - 1]->name);
> + err = -EINVAL;
> + goto out;
> + }
> + }
> +
> + err = igt_live_test_end(&t);
> + if (err)
> + goto out;
> +
> +out:
> + if (igt_flush_test(i915, I915_WAIT_LOCKED))
> + err = -EIO;
> +
> + for (n = 0; n < nsibling; n++)
> + i915_request_put(request[n]);
> +
> +out_unpin:
> + intel_context_unpin(ve);
> +out_put:
> + intel_context_put(ve);
> +out_close:
> + kernel_context_close(ctx);
> + return err;
> +}
> +
> +static int live_virtual_mask(void *arg)
> +{
> + struct drm_i915_private *i915 = arg;
> + struct intel_engine_cs *siblings[MAX_ENGINE_INSTANCE + 1];
> + unsigned int class, inst;
> + int err = 0;
> +
> + if (USES_GUC_SUBMISSION(i915))
> + return 0;
> +
> + mutex_lock(&i915->drm.struct_mutex);
> +
> + for (class = 0; class <= MAX_ENGINE_CLASS; class++) {
> + unsigned int nsibling;
> +
> + nsibling = 0;
> + for (inst = 0; inst <= MAX_ENGINE_INSTANCE; inst++) {
> + if (!i915->engine_class[class][inst])
> + break;
> +
> + siblings[nsibling++] = i915->engine_class[class][inst];
> + }
> + if (nsibling < 2)
> + continue;
> +
> + err = mask_virtual_engine(i915, siblings, nsibling);
> + if (err)
> + goto out_unlock;
> + }
> +
> +out_unlock:
> + mutex_unlock(&i915->drm.struct_mutex);
> + return err;
> +}
> +
> int intel_execlists_live_selftests(struct drm_i915_private *i915)
> {
> static const struct i915_subtest tests[] = {
> @@ -1493,6 +1623,7 @@ int intel_execlists_live_selftests(struct drm_i915_private *i915)
> SUBTEST(live_preempt_hang),
> SUBTEST(live_preempt_smoke),
> SUBTEST(live_virtual_engine),
> + SUBTEST(live_virtual_mask),
> };
>
> if (!HAS_EXECLISTS(i915))
> diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
> index 46f4fc2a8840..78c07e131521 100644
> --- a/drivers/gpu/drm/i915/i915_request.c
> +++ b/drivers/gpu/drm/i915/i915_request.c
> @@ -688,6 +688,7 @@ __i915_request_create(struct intel_context *ce, gfp_t gfp)
> rq->batch = NULL;
> rq->capture_list = NULL;
> rq->waitboost = false;
> + rq->execution_mask = ALL_ENGINES;
>
> INIT_LIST_HEAD(&rq->active_list);
> INIT_LIST_HEAD(&rq->execute_cb);
> diff --git a/drivers/gpu/drm/i915/i915_request.h b/drivers/gpu/drm/i915/i915_request.h
> index 8025a89b5999..d7f9b2194568 100644
> --- a/drivers/gpu/drm/i915/i915_request.h
> +++ b/drivers/gpu/drm/i915/i915_request.h
> @@ -28,6 +28,8 @@
> #include <linux/dma-fence.h>
> #include <linux/lockdep.h>
>
> +#include "gt/intel_engine_types.h"
> +
> #include "i915_gem.h"
> #include "i915_scheduler.h"
> #include "i915_selftest.h"
> @@ -156,6 +158,7 @@ struct i915_request {
> */
> struct i915_sched_node sched;
> struct i915_dependency dep;
> + intel_engine_mask_t execution_mask;
>
> /*
> * A convenience pointer to the current breadcrumb value stored in
>
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-04-17 11:43 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-17 7:56 [PATCH 01/32] drm/i915: Seal races between async GPU cancellation, retirement and signaling Chris Wilson
2019-04-17 7:56 ` [PATCH 02/32] drm/i915: Verify workarounds immediately after application Chris Wilson
2019-04-17 7:56 ` [PATCH 03/32] drm/i915: Verify the engine workarounds stick on application Chris Wilson
2019-04-17 7:56 ` [PATCH 04/32] drm/i915: Make workaround verification *optional* Chris Wilson
2019-04-17 9:37 ` Tvrtko Ursulin
2019-04-17 7:56 ` [PATCH 05/32] drm/i915/selftests: Verify whitelist of context registers Chris Wilson
2019-04-17 7:56 ` [PATCH 06/32] drm/i915: Store the default sseu setup on the engine Chris Wilson
2019-04-17 9:40 ` Tvrtko Ursulin
2019-04-24 9:45 ` Chris Wilson
2019-04-17 7:56 ` [PATCH 07/32] drm/i915: Move GraphicsTechnology files under gt/ Chris Wilson
2019-04-17 9:42 ` Tvrtko Ursulin
2019-04-18 12:04 ` Joonas Lahtinen
2019-04-23 8:57 ` Joonas Lahtinen
2019-04-23 9:40 ` Jani Nikula
2019-04-23 16:46 ` Rodrigo Vivi
2019-04-17 7:56 ` [PATCH 08/32] drm/i915: Introduce struct intel_wakeref Chris Wilson
2019-04-17 9:45 ` Tvrtko Ursulin
2019-04-17 7:56 ` [PATCH 09/32] drm/i915: Pull the GEM powermangement coupling into its own file Chris Wilson
2019-04-17 7:56 ` [PATCH 10/32] drm/i915: Introduce context->enter() and context->exit() Chris Wilson
2019-04-17 7:56 ` [PATCH 11/32] drm/i915: Pass intel_context to i915_request_create() Chris Wilson
2019-04-17 7:56 ` [PATCH 12/32] drm/i915: Invert the GEM wakeref hierarchy Chris Wilson
2019-04-18 12:42 ` Tvrtko Ursulin
2019-04-18 13:07 ` Chris Wilson
2019-04-18 13:22 ` Chris Wilson
2019-04-23 13:02 ` Tvrtko Ursulin
2019-04-17 7:56 ` [PATCH 13/32] drm/i915/gvt: Pin the per-engine GVT shadow contexts Chris Wilson
2019-04-17 7:56 ` [PATCH 14/32] drm/i915: Explicitly pin the logical context for execbuf Chris Wilson
2019-04-17 7:56 ` [PATCH 15/32] drm/i915: Export intel_context_instance() Chris Wilson
2019-04-17 7:56 ` [PATCH 16/32] drm/i915/selftests: Use the real kernel context for sseu isolation tests Chris Wilson
2019-04-17 7:56 ` [PATCH 17/32] drm/i915/selftests: Pass around intel_context for sseu Chris Wilson
2019-04-17 7:56 ` [PATCH 18/32] drm/i915: Pass intel_context to intel_context_pin_lock() Chris Wilson
2019-04-17 7:56 ` [PATCH 19/32] drm/i915: Split engine setup/init into two phases Chris Wilson
2019-04-17 7:56 ` [PATCH 20/32] drm/i915: Switch back to an array of logical per-engine HW contexts Chris Wilson
2019-04-17 7:56 ` [PATCH 21/32] drm/i915: Remove intel_context.active_link Chris Wilson
2019-04-17 9:47 ` Tvrtko Ursulin
2019-04-17 7:56 ` [PATCH 22/32] drm/i915: Move i915_request_alloc into selftests/ Chris Wilson
2019-04-17 7:56 ` [PATCH 23/32] drm/i915: Allow multiple user handles to the same VM Chris Wilson
2019-04-17 7:56 ` [PATCH 24/32] drm/i915: Restore control over ppgtt for context creation ABI Chris Wilson
2019-04-17 7:56 ` [PATCH 25/32] drm/i915: Allow a context to define its set of engines Chris Wilson
2019-04-17 9:50 ` Tvrtko Ursulin
2019-04-17 7:56 ` [PATCH 26/32] drm/i915: Re-expose SINGLE_TIMELINE flags for context creation Chris Wilson
2019-04-17 7:56 ` [PATCH 27/32] drm/i915: Allow userspace to clone contexts on creation Chris Wilson
2019-04-17 9:50 ` Tvrtko Ursulin
2019-04-17 7:56 ` [PATCH 28/32] drm/i915: Load balancing across a virtual engine Chris Wilson
2019-04-17 11:26 ` Tvrtko Ursulin
2019-04-17 13:51 ` Chris Wilson
2019-04-17 7:56 ` [PATCH 29/32] drm/i915: Apply an execution_mask to the virtual_engine Chris Wilson
2019-04-17 11:43 ` Tvrtko Ursulin [this message]
2019-04-17 11:57 ` Chris Wilson
2019-04-17 12:35 ` Tvrtko Ursulin
2019-04-17 12:46 ` Chris Wilson
2019-04-17 13:32 ` Tvrtko Ursulin
2019-04-18 7:24 ` Chris Wilson
2019-04-17 7:56 ` [PATCH 30/32] drm/i915: Extend execution fence to support a callback Chris Wilson
2019-04-17 7:56 ` [PATCH 31/32] drm/i915/execlists: Virtual engine bonding Chris Wilson
2019-04-18 6:47 ` Tvrtko Ursulin
2019-04-18 6:57 ` Chris Wilson
2019-04-18 8:57 ` Tvrtko Ursulin
2019-04-18 9:13 ` Chris Wilson
2019-04-18 9:50 ` Tvrtko Ursulin
2019-04-18 9:59 ` Chris Wilson
2019-04-18 10:24 ` Tvrtko Ursulin
2019-04-17 7:56 ` [PATCH 32/32] drm/i915: Allow specification of parallel execbuf Chris Wilson
2019-04-17 8:46 ` [PATCH 01/32] drm/i915: Seal races between async GPU cancellation, retirement and signaling Chris Wilson
2019-04-17 11:33 ` ✗ Fi.CI.BAT: failure for series starting with [01/32] " Patchwork
2019-04-18 10:32 ` [PATCH 01/32] " Tvrtko Ursulin
2019-04-18 10:40 ` Chris Wilson
2019-04-23 12:59 ` 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=bc55dad4-949a-95ce-7896-576f253dc0ca@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=intel-gfx@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.