All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 3/8] drm/i915/execlists: Suppress redundant preemption
Date: Tue, 29 Jan 2019 11:15:35 +0000	[thread overview]
Message-ID: <96d3e40b-a276-01ff-e260-e878ff4ac6d4@linux.intel.com> (raw)
In-Reply-To: <20190129085824.12620-3-chris@chris-wilson.co.uk>


On 29/01/2019 08:58, Chris Wilson wrote:
> On unwinding the active request we give it a small (limited to internal
> priority levels) boost to prevent it from being gazumped a second time.
> However, this means that it can be promoted to above the request that
> triggered the preemption request, causing a preempt-to-idle cycle for no

How can it go higher? Only because I915_PRIORITY_NEWCLIENT is higher 
than I915_PRIORITY_WAIT? In that case would re-ordering those help? I 
don't remember if there was a reason for the current order.

> change. We can avoid this if we take the boost into account when
> checking if the preemption request is valid.
> 
> v2: After preemption the active request will be after the preemptee if
> they end up with equal priority.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>   drivers/gpu/drm/i915/intel_lrc.c | 39 ++++++++++++++++++++++++++++----
>   1 file changed, 35 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
> index b8cddef5aed8..f4b0be81c6db 100644
> --- a/drivers/gpu/drm/i915/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/intel_lrc.c
> @@ -164,6 +164,8 @@
>   #define WA_TAIL_DWORDS 2
>   #define WA_TAIL_BYTES (sizeof(u32) * WA_TAIL_DWORDS)
>   
> +#define ACTIVE_PRIORITY (I915_PRIORITY_NEWCLIENT)
> +
>   static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,
>   					    struct intel_engine_cs *engine,
>   					    struct intel_context *ce);
> @@ -188,6 +190,34 @@ static inline int rq_prio(const struct i915_request *rq)
>   	return rq->sched.attr.priority;
>   }
>   
> +static inline int active_prio(const struct i915_request *rq)
> +{
> +	int prio = rq_prio(rq);
> +
> +	/*
> +	 * On unwinding the active request, we give it a priority bump
> +	 * equivalent to a freshly submitted request. This protects it from
> +	 * being gazumped again, but it would be preferable if we didn't
> +	 * let it be gazumped in the first place!
> +	 *
> +	 * See __unwind_incomplete_requests()
> +	 */
> +	if ((prio & ACTIVE_PRIORITY) != ACTIVE_PRIORITY &&

if (!(prio & ACTIVE_PRIORITY) && ? It is a single bit.

> +	    i915_request_started(rq)) {
> +		/*
> +		 * After preemption, we insert the active request at the
> +		 * end of the new priority level. This means that we will be

Side question - why do we not move it to the head of the new priority 
level? It was preempted, so it sounds fair that it would go to the head.

> +		 * _lower_ priority than the preemptee all things equal (and
> +		 * so the preemption is valid), so adjust our comparison
> +		 * accordingly.
> +		 */
> +		prio |= ACTIVE_PRIORITY;
> +		prio--;

So any running request not marked with NEWCLIENT/ACTIVE_PRIORITY will 
get it here, minus one, which effectively means applying 
I915_PRIORITY_WAIT to it. Or just keeping NEWCLIENT if it had WAIT already.

So kind of like a micro priority bump, only if the request is running. 
Do you view it as end of the context stream so make preemption less 
likely on the very end of the stream? But what if it is a long batch, 
why we wouldn't want to preempt it?

Regards,

Tvrtko

> +	}
> +
> +	return prio;
> +}
> +
>   static int queue_prio(const struct intel_engine_execlists *execlists)
>   {
>   	struct i915_priolist *p;
> @@ -208,7 +238,7 @@ static int queue_prio(const struct intel_engine_execlists *execlists)
>   static inline bool need_preempt(const struct intel_engine_cs *engine,
>   				const struct i915_request *rq)
>   {
> -	const int last_prio = rq_prio(rq);
> +	int last_prio;
>   
>   	if (!intel_engine_has_preemption(engine))
>   		return false;
> @@ -228,6 +258,7 @@ static inline bool need_preempt(const struct intel_engine_cs *engine,
>   	 * preempt. If that hint is stale or we may be trying to preempt
>   	 * ourselves, ignore the request.
>   	 */
> +	last_prio = active_prio(rq);
>   	if (!__execlists_need_preempt(engine->execlists.preempt_priority_hint,
>   				      last_prio))
>   		return false;
> @@ -353,7 +384,7 @@ __unwind_incomplete_requests(struct intel_engine_cs *engine)
>   {
>   	struct i915_request *rq, *rn, *active = NULL;
>   	struct list_head *uninitialized_var(pl);
> -	int prio = I915_PRIORITY_INVALID | I915_PRIORITY_NEWCLIENT;
> +	int prio = I915_PRIORITY_INVALID | ACTIVE_PRIORITY;
>   
>   	lockdep_assert_held(&engine->timeline.lock);
>   
> @@ -385,8 +416,8 @@ __unwind_incomplete_requests(struct intel_engine_cs *engine)
>   	 * stream, so give it the equivalent small priority bump to prevent
>   	 * it being gazumped a second time by another peer.
>   	 */
> -	if (!(prio & I915_PRIORITY_NEWCLIENT)) {
> -		prio |= I915_PRIORITY_NEWCLIENT;
> +	if ((prio & ACTIVE_PRIORITY) != ACTIVE_PRIORITY) {
> +		prio |= ACTIVE_PRIORITY;
>   		active->sched.attr.priority = prio;
>   		list_move_tail(&active->sched.link,
>   			       i915_sched_lookup_priolist(engine, prio));
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-01-29 11:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29  8:58 [PATCH 1/8] drm/i915: Rename execlists->queue_priority to preempt_priority_hint Chris Wilson
2019-01-29  8:58 ` [PATCH 2/8] drm/i915/execlists: Suppress preempting self Chris Wilson
2019-01-29 10:13   ` Tvrtko Ursulin
2019-01-29 10:22     ` Chris Wilson
2019-01-29  8:58 ` [PATCH 3/8] drm/i915/execlists: Suppress redundant preemption Chris Wilson
2019-01-29 11:15   ` Tvrtko Ursulin [this message]
2019-01-29 11:21     ` Chris Wilson
2019-01-29 12:26       ` Tvrtko Ursulin
2019-01-29 12:34         ` Chris Wilson
2019-01-29 15:27   ` [PATCH] " Chris Wilson
2019-01-29  8:58 ` [PATCH 4/8] drm/i915/selftests: Exercise some AB...BA preemption chains Chris Wilson
2019-01-29  8:58 ` [PATCH 5/8] drm/i915: Identify active requests Chris Wilson
2019-01-29  8:58 ` [PATCH 6/8] drm/i915: Remove the intel_engine_notify tracepoint Chris Wilson
2019-01-29  8:58 ` [PATCH 7/8] drm/i915: Replace global breadcrumbs with per-context interrupt tracking Chris Wilson
2019-01-29  8:58 ` [PATCH 8/8] drm/i915: Drop fake breadcrumb irq Chris Wilson
2019-01-29  9:40 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/8] drm/i915: Rename execlists->queue_priority to preempt_priority_hint Patchwork
2019-01-29  9:44 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-01-29  9:58 ` ✓ Fi.CI.BAT: success " Patchwork
2019-01-29 10:14 ` [PATCH 1/8] " Tvrtko Ursulin
2019-01-29 10:24   ` Chris Wilson
2019-01-29 10:41     ` Tvrtko Ursulin
2019-01-29 11:33 ` ✓ Fi.CI.IGT: success for series starting with [1/8] " Patchwork
2019-01-29 16:29 ` ✗ Fi.CI.BAT: failure for series starting with [1/8] drm/i915: Rename execlists->queue_priority to preempt_priority_hint (rev2) Patchwork

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=96d3e40b-a276-01ff-e260-e878ff4ac6d4@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.