From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 1/3] drm/i915: Mark i915_request.timeline as a volatile, rcu pointer
Date: Fri, 20 Sep 2019 09:47:26 +0100 [thread overview]
Message-ID: <89b0252e-dc4a-9fd6-e007-58bcc7e30bd7@linux.intel.com> (raw)
In-Reply-To: <156891536326.1196.6694433407311839234@skylake-alporthouse-com>
On 19/09/2019 18:49, Chris Wilson wrote:
> Quoting Tvrtko Ursulin (2019-09-19 18:11:14)
>>
>> On 19/09/2019 14:26, Chris Wilson wrote:
>>> Quoting Tvrtko Ursulin (2019-09-19 14:02:19)
>>>>
>>>> On 19/09/2019 12:19, Chris Wilson wrote:
>>>>> +static struct intel_timeline *get_timeline(struct i915_request *rq)
>>>>> +{
>>>>> + struct intel_timeline *tl;
>>>>> +
>>>>> + /*
>>>>> + * Even though we are holding the engine->active.lock here, there
>>>>> + * is no control over the submission queue per-se and we are
>>>>> + * inspecting the active state at a random point in time, with an
>>>>> + * unknown queue. Play safe and make sure the timeline remains valid.
>>>>> + * (Only being used for pretty printing, one extra kref shouldn't
>>>>> + * cause a camel stampede!)
>>>>> + */
>>>>> + rcu_read_lock();
>>>>> + tl = rcu_dereference(rq->timeline);
>>>>> + if (!kref_get_unless_zero(&tl->kref))
>>>>> + tl = NULL;
>>>>> + rcu_read_unlock();
>>>>
>>>> How can it be NULL under the active lock? Isn't that the same assertion
>>>> from i915_timeline_get_active.
>>>
>>> Not NULL, but retired. The difference is that during submission we know
>>> that this request's context/timeline must be currently pinned until
>>> a subsequent request (containing the idle-barriers) is submitted. The
>>> danger I worry about here is that subsequent idle request may be already
>>> submitted and since the queued requests may *already* have been retired,
>>> the timeline may be unpinned and indeed dropped it's last reference.
>>
>> But here it is under the engine->active.lock with interrupts disabled
>> and the requests are fetched from execlists ports. Timeline is not
>> guaranteed to be kept alive under these conditions? intel_context
>> reference will be held until process_csb schedules it out so I'd expect
>> timeline and hwsp to be there. But I could be lost in the new scheme of
>> things.
>
> I felt it was prudent to only rely on the active pin. You are right in
> that we have a context reference if it is in active, and that context
> holds a reference to the timeline. But... engine->active.lock is not
> the lock that guards rq->timeline, so I feel uneasy on extending
> i915_request_active_timeline() too far. Outside of the submission
> pathway, inside a pretty printer, it feels safer (whatever changes may
> come we don't have to worry about it) to not assume anything and just
> use the failsafe rcu_dereference() + kref.
Well okay, I can accept that in the overall situation.
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
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-09-20 8:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-19 11:19 [PATCH v2 1/3] drm/i915: Mark i915_request.timeline as a volatile, rcu pointer Chris Wilson
2019-09-19 11:19 ` [PATCH v2 2/3] drm/i915: Lock signaler timeline while navigating Chris Wilson
2019-09-19 11:19 ` [PATCH v2 3/3] drm/i915: Protect timeline->hwsp dereferencing Chris Wilson
2019-09-19 12:22 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [v2,1/3] drm/i915: Mark i915_request.timeline as a volatile, rcu pointer Patchwork
2019-09-19 12:23 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-09-19 12:44 ` ✓ Fi.CI.BAT: success " Patchwork
2019-09-19 13:02 ` [PATCH v2 1/3] " Tvrtko Ursulin
2019-09-19 13:26 ` Chris Wilson
2019-09-19 17:11 ` Tvrtko Ursulin
2019-09-19 17:49 ` Chris Wilson
2019-09-20 8:47 ` Tvrtko Ursulin [this message]
2019-09-19 20:09 ` ✓ Fi.CI.IGT: success for series starting with [v2,1/3] " 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=89b0252e-dc4a-9fd6-e007-58bcc7e30bd7@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox