From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org Subject: Re: [PATCH 1/5] drm/i915/gt: Wait for new requests in intel_gt_retire_requests() Date: Fri, 15 Nov 2019 12:45:52 +0000 [thread overview] Message-ID: <273f2ba3-02d5-f99b-03ba-f55868ea5259@linux.intel.com> (raw) In-Reply-To: <20191114225736.616885-1-chris@chris-wilson.co.uk> On 14/11/2019 22:57, Chris Wilson wrote: > Our callers fall into two categories, those passing timeout=0 who just > want to flush request retirements and those passing a timeout that need > to wait for submission completion (e.g. intel_gt_wait_for_idle()). > Currently, we only wait for a snapshot of timelines at the start of the > wait (but there was an expection that new requests would cause timelines expectation? exception? > to appear at the end). However, our callers, such as > intel_gt_wait_for_idle() before suspend, do require us to wait for the > power management requests emitted by retirement as well. If we don't, > then it takes an extra second or two for the background worker to flush > the queue and mark the GT as idle. So with this change wait_for_idle waits for the kernel context to get retired as well. And you say that's faster by a second or two? Which flush gets so much slower, I mean from where, if we don't wait here? Regards, Tvrtko > > Fixes: 7e8057626640 ("drm/i915: Drop struct_mutex from around i915_retire_requests()") > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> > --- > drivers/gpu/drm/i915/gt/intel_gt_requests.c | 11 +++-------- > 1 file changed, 3 insertions(+), 8 deletions(-) > > diff --git a/drivers/gpu/drm/i915/gt/intel_gt_requests.c b/drivers/gpu/drm/i915/gt/intel_gt_requests.c > index b73229a84d85..ccbddddbbd52 100644 > --- a/drivers/gpu/drm/i915/gt/intel_gt_requests.c > +++ b/drivers/gpu/drm/i915/gt/intel_gt_requests.c > @@ -33,7 +33,6 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout) > { > struct intel_gt_timelines *timelines = >->timelines; > struct intel_timeline *tl, *tn; > - unsigned long active_count = 0; > unsigned long flags; > bool interruptible; > LIST_HEAD(free); > @@ -46,10 +45,8 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout) > > spin_lock_irqsave(&timelines->lock, flags); > list_for_each_entry_safe(tl, tn, &timelines->active_list, link) { > - if (!mutex_trylock(&tl->mutex)) { > - active_count++; /* report busy to caller, try again? */ > + if (!mutex_trylock(&tl->mutex)) > continue; > - } > > intel_timeline_get(tl); > GEM_BUG_ON(!tl->active_count); > @@ -74,9 +71,7 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout) > > /* Resume iteration after dropping lock */ > list_safe_reset_next(tl, tn, link); > - if (--tl->active_count) > - active_count += !!rcu_access_pointer(tl->last_request.fence); > - else > + if (!--tl->active_count) > list_del(&tl->link); > > mutex_unlock(&tl->mutex); > @@ -92,7 +87,7 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout) > list_for_each_entry_safe(tl, tn, &free, link) > __intel_timeline_free(&tl->kref); > > - return active_count ? timeout : 0; > + return list_empty(&timelines->active_list) ? 0 : timeout; > } > > int intel_gt_wait_for_idle(struct intel_gt *gt, long timeout) > _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
WARNING: multiple messages have this Message-ID (diff)
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org Subject: Re: [Intel-gfx] [PATCH 1/5] drm/i915/gt: Wait for new requests in intel_gt_retire_requests() Date: Fri, 15 Nov 2019 12:45:52 +0000 [thread overview] Message-ID: <273f2ba3-02d5-f99b-03ba-f55868ea5259@linux.intel.com> (raw) Message-ID: <20191115124552.0T-nvbYHtOAQDO-OFjAFH15wtgXZeFz2ob36Sab5854@z> (raw) In-Reply-To: <20191114225736.616885-1-chris@chris-wilson.co.uk> On 14/11/2019 22:57, Chris Wilson wrote: > Our callers fall into two categories, those passing timeout=0 who just > want to flush request retirements and those passing a timeout that need > to wait for submission completion (e.g. intel_gt_wait_for_idle()). > Currently, we only wait for a snapshot of timelines at the start of the > wait (but there was an expection that new requests would cause timelines expectation? exception? > to appear at the end). However, our callers, such as > intel_gt_wait_for_idle() before suspend, do require us to wait for the > power management requests emitted by retirement as well. If we don't, > then it takes an extra second or two for the background worker to flush > the queue and mark the GT as idle. So with this change wait_for_idle waits for the kernel context to get retired as well. And you say that's faster by a second or two? Which flush gets so much slower, I mean from where, if we don't wait here? Regards, Tvrtko > > Fixes: 7e8057626640 ("drm/i915: Drop struct_mutex from around i915_retire_requests()") > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> > --- > drivers/gpu/drm/i915/gt/intel_gt_requests.c | 11 +++-------- > 1 file changed, 3 insertions(+), 8 deletions(-) > > diff --git a/drivers/gpu/drm/i915/gt/intel_gt_requests.c b/drivers/gpu/drm/i915/gt/intel_gt_requests.c > index b73229a84d85..ccbddddbbd52 100644 > --- a/drivers/gpu/drm/i915/gt/intel_gt_requests.c > +++ b/drivers/gpu/drm/i915/gt/intel_gt_requests.c > @@ -33,7 +33,6 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout) > { > struct intel_gt_timelines *timelines = >->timelines; > struct intel_timeline *tl, *tn; > - unsigned long active_count = 0; > unsigned long flags; > bool interruptible; > LIST_HEAD(free); > @@ -46,10 +45,8 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout) > > spin_lock_irqsave(&timelines->lock, flags); > list_for_each_entry_safe(tl, tn, &timelines->active_list, link) { > - if (!mutex_trylock(&tl->mutex)) { > - active_count++; /* report busy to caller, try again? */ > + if (!mutex_trylock(&tl->mutex)) > continue; > - } > > intel_timeline_get(tl); > GEM_BUG_ON(!tl->active_count); > @@ -74,9 +71,7 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout) > > /* Resume iteration after dropping lock */ > list_safe_reset_next(tl, tn, link); > - if (--tl->active_count) > - active_count += !!rcu_access_pointer(tl->last_request.fence); > - else > + if (!--tl->active_count) > list_del(&tl->link); > > mutex_unlock(&tl->mutex); > @@ -92,7 +87,7 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout) > list_for_each_entry_safe(tl, tn, &free, link) > __intel_timeline_free(&tl->kref); > > - return active_count ? timeout : 0; > + return list_empty(&timelines->active_list) ? 0 : timeout; > } > > int intel_gt_wait_for_idle(struct intel_gt *gt, long timeout) > _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-11-15 12:45 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-11-14 22:57 [PATCH 1/5] drm/i915/gt: Wait for new requests in intel_gt_retire_requests() Chris Wilson 2019-11-14 22:57 ` [Intel-gfx] " Chris Wilson 2019-11-14 22:57 ` [PATCH 2/5] drm/i915/selftests: Exercise rc6 handling Chris Wilson 2019-11-14 22:57 ` [Intel-gfx] " Chris Wilson 2019-11-14 22:57 ` [PATCH 3/5] drm/i915/selftests: Be explicit in ERR_PTR handling Chris Wilson 2019-11-14 22:57 ` [Intel-gfx] " Chris Wilson 2019-11-15 12:47 ` Tvrtko Ursulin 2019-11-15 12:47 ` [Intel-gfx] " Tvrtko Ursulin 2019-11-15 12:55 ` [PATCH] " Chris Wilson 2019-11-15 12:55 ` [Intel-gfx] " Chris Wilson 2019-11-14 22:57 ` [PATCH 4/5] drm/i915/selftests: Exercise long preemption chains Chris Wilson 2019-11-14 22:57 ` [Intel-gfx] " Chris Wilson 2019-11-15 12:50 ` Tvrtko Ursulin 2019-11-15 12:50 ` [Intel-gfx] " Tvrtko Ursulin 2019-11-14 22:57 ` [PATCH 5/5] drm/i915/gem: Silence sparse for RCU protection inside the constructor Chris Wilson 2019-11-14 22:57 ` [Intel-gfx] " Chris Wilson 2019-11-15 12:55 ` Tvrtko Ursulin 2019-11-15 12:55 ` [Intel-gfx] " Tvrtko Ursulin 2019-11-15 0:12 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/5] drm/i915/gt: Wait for new requests in intel_gt_retire_requests() Patchwork 2019-11-15 0:12 ` [Intel-gfx] " Patchwork 2019-11-15 0:34 ` ✓ Fi.CI.BAT: success " Patchwork 2019-11-15 0:34 ` [Intel-gfx] " Patchwork 2019-11-15 12:45 ` Tvrtko Ursulin [this message] 2019-11-15 12:45 ` [Intel-gfx] [PATCH 1/5] " Tvrtko Ursulin 2019-11-15 12:49 ` Chris Wilson 2019-11-15 12:49 ` [Intel-gfx] " Chris Wilson 2019-11-15 12:56 ` Tvrtko Ursulin 2019-11-15 12:56 ` [Intel-gfx] " Tvrtko Ursulin 2019-11-15 17:18 ` ✗ Fi.CI.BUILD: failure for series starting with [1/5] drm/i915/gt: Wait for new requests in intel_gt_retire_requests() (rev2) Patchwork 2019-11-15 17:18 ` [Intel-gfx] " 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=273f2ba3-02d5-f99b-03ba-f55868ea5259@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: linkBe 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.