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 04/22] drm/i915: Hold a ref to the ring while retiring
Date: Mon, 18 Mar 2019 13:25:37 +0000	[thread overview]
Message-ID: <e5a03dfb-f77d-605b-4deb-c852ca9159ac@linux.intel.com> (raw)
In-Reply-To: <155290659007.4168.7317835572037859614@skylake-alporthouse-com>


On 18/03/2019 10:56, Chris Wilson wrote:
> Quoting Tvrtko Ursulin (2019-03-18 10:46:28)
>>
>> On 18/03/2019 10:37, Chris Wilson wrote:
>>> Quoting Tvrtko Ursulin (2019-03-18 10:31:57)
>>>>
>>>> On 18/03/2019 09:51, Chris Wilson wrote:
>>>>> As the final request on a ring may hold the reference to this ring (via
>>>>> retiring the last pinned context), we may find ourselves chasing a
>>>>> dangling pointer on completion of the list.
>>>>>
>>>>> A quick solution is to hold a reference to the ring itself as we retire
>>>>> along it so that we only free it after we stop dereferencing it.
>>>>
>>>> Is there a guilty commit to reference as Fixes: ?
>>>
>>> It only becomes a problem with veng as we gain an immediate free path,
>>> whereas at the moment, context frees are deferred until they can acquire
>>> the struct_mutex. We cannot hit this path at the moment, but that we had
>>> to use the safe iterator implies that we were aware that the ring itself
>>> could disappear. If you wanted to pin it on something,
>>>
>>> References: b887d6154624 ("drm/i915: Retire requests along rings")
>>>
>>>>> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
>>>>> ---
>>>>>     drivers/gpu/drm/i915/i915_request.c          |  6 +++++-
>>>>>     drivers/gpu/drm/i915/intel_engine_types.h    |  2 ++
>>>>>     drivers/gpu/drm/i915/intel_lrc.c             |  4 ++--
>>>>>     drivers/gpu/drm/i915/intel_ringbuffer.c      |  9 +++++----
>>>>>     drivers/gpu/drm/i915/intel_ringbuffer.h      | 13 ++++++++++++-
>>>>>     drivers/gpu/drm/i915/selftests/mock_engine.c |  1 +
>>>>>     6 files changed, 27 insertions(+), 8 deletions(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
>>>>> index 9533a85cb0b3..0a3d94517d0a 100644
>>>>> --- a/drivers/gpu/drm/i915/i915_request.c
>>>>> +++ b/drivers/gpu/drm/i915/i915_request.c
>>>>> @@ -1332,8 +1332,12 @@ void i915_retire_requests(struct drm_i915_private *i915)
>>>>>         if (!i915->gt.active_requests)
>>>>>                 return;
>>>>>     
>>>>> -     list_for_each_entry_safe(ring, tmp, &i915->gt.active_rings, active_link)
>>>>> +     list_for_each_entry_safe(ring, tmp,
>>>>> +                              &i915->gt.active_rings, active_link) {
>>>>> +             intel_ring_get(ring); /* last rq holds reference! */
>>>>>                 ring_retire_requests(ring);
>>>>> +             intel_ring_put(ring);
>>>>> +     }
>>>>
>>>> Where does it chase a dangling pointer? It used the safe iterator already.
>>>
>>> Inside ring_retire_requests(); the use of _safe here actually implies we
>>> met this problem already :)
>>
>> I get it, the issue is during ring->request_list iteration in
>> ring_retire_requests. How about move ring pinning in there so it is clearer?
> 
> It's only this path that is affected. That maye becomes clearer when we
> retire along timelines and not rings, which is the patchset I wanted to
> land to fix this, but figured this was a tiny fix for now.

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

I failed to find a short and clear suggestion for making the comment 
more precise.

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-03-18 13:25 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-18  9:51 [PATCH 01/22] drm/i915: Flush pages on acquisition Chris Wilson
2019-03-18  9:51 ` [PATCH 02/22] drm/i915: Move intel_engine_mask_t around for use by i915_request_types.h Chris Wilson
2019-03-18 10:21   ` Tvrtko Ursulin
2019-03-18 10:40     ` Chris Wilson
2019-03-18 10:48       ` Tvrtko Ursulin
2019-03-18 13:57         ` Chris Wilson
2019-03-18  9:51 ` [PATCH 03/22] drm/i915: Sanity check mmap length against object size Chris Wilson
2019-03-25  0:38   ` Sasha Levin
2019-03-18  9:51 ` [PATCH 04/22] drm/i915: Hold a ref to the ring while retiring Chris Wilson
2019-03-18 10:31   ` Tvrtko Ursulin
2019-03-18 10:37     ` Chris Wilson
2019-03-18 10:46       ` Tvrtko Ursulin
2019-03-18 10:56         ` Chris Wilson
2019-03-18 13:25           ` Tvrtko Ursulin [this message]
2019-03-18  9:51 ` [PATCH 05/22] drm/i915: Lock the gem_context->active_list while dropping the link Chris Wilson
2019-03-18 10:39   ` Tvrtko Ursulin
2019-03-18 10:45     ` Chris Wilson
2019-03-18 10:50       ` Tvrtko Ursulin
2019-03-18 10:54   ` Chris Wilson
2019-03-18  9:51 ` [PATCH 06/22] drm/i915: Hold a reference to the active HW context Chris Wilson
2019-03-18 12:54   ` Tvrtko Ursulin
2019-03-18 12:56     ` Chris Wilson
2019-03-18 12:57       ` Chris Wilson
2019-03-18 13:29         ` Tvrtko Ursulin
2019-03-18  9:51 ` [PATCH 07/22] drm/i915: Stop needlessly acquiring wakeref for debugfs/drop_caches_set Chris Wilson
2019-03-18 13:08   ` Tvrtko Ursulin
2019-03-18  9:51 ` [PATCH 08/22] drm/i915/selftests: Provide stub reset functions Chris Wilson
2019-03-18  9:51 ` [PATCH 09/22] drm/i915: Switch to use HWS indices rather than addresses Chris Wilson
2019-03-18 13:21   ` Tvrtko Ursulin
2019-03-18  9:51 ` [PATCH 10/22] drm/i915: Separate GEM context construction and registration to userspace Chris Wilson
2019-03-18 16:22   ` Tvrtko Ursulin
2019-03-18 16:30     ` Chris Wilson
2019-03-18 16:32       ` Chris Wilson
2019-03-18 16:46         ` Tvrtko Ursulin
2019-03-18  9:51 ` [PATCH 11/22] drm/i915: Introduce a mutex for file_priv->context_idr Chris Wilson
2019-03-18 16:28   ` Tvrtko Ursulin
2019-03-18 16:35     ` Chris Wilson
2019-03-18 16:45       ` Tvrtko Ursulin
2019-03-18 21:10         ` Chris Wilson
2019-03-18  9:51 ` [PATCH 12/22] drm/i915: Introduce the i915_user_extension_method Chris Wilson
2019-03-18  9:51 ` [PATCH 13/22] drm/i915: Create/destroy VM (ppGTT) for use with contexts Chris Wilson
2019-03-18  9:51 ` [PATCH 14/22] drm/i915: Extend CONTEXT_CREATE to set parameters upon construction Chris Wilson
2019-03-18  9:51 ` [PATCH 15/22] drm/i915: Allow contexts to share a single timeline across all engines Chris Wilson
2019-03-18  9:51 ` [PATCH 16/22] drm/i915: Allow userspace to clone contexts on creation Chris Wilson
2019-03-18  9:51 ` [PATCH 17/22] drm/i915: Allow a context to define its set of engines Chris Wilson
2019-03-18  9:52 ` [PATCH 18/22] drm/i915: Extend I915_CONTEXT_PARAM_SSEU to support local ctx->engine[] Chris Wilson
2019-03-18  9:52 ` [PATCH 19/22] drm/i915: Load balancing across a virtual engine Chris Wilson
2019-03-18  9:52 ` [PATCH 20/22] drm/i915: Extend execution fence to support a callback Chris Wilson
2019-03-18  9:52 ` [PATCH 21/22] drm/i915/execlists: Virtual engine bonding Chris Wilson
2019-03-18  9:52 ` [PATCH 22/22] drm/i915: Allow specification of parallel execbuf Chris Wilson
2019-03-18 17:10 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/22] drm/i915: Flush pages on acquisition Patchwork
2019-03-18 17:20 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-03-18 17:36 ` ✗ Fi.CI.BAT: failure " 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=e5a03dfb-f77d-605b-4deb-c852ca9159ac@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.