All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 1/3] drm/i915: Mark i915_request.timeline as a volatile, rcu pointer
Date: Thu, 19 Sep 2019 14:26:04 +0100	[thread overview]
Message-ID: <156889956418.31102.4110265390892262636@skylake-alporthouse-com> (raw)
In-Reply-To: <5202f44e-a251-f4e0-f27c-1f96fab24078@linux.intel.com>

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.

> > diff --git a/drivers/gpu/drm/i915/gt/selftest_context.c b/drivers/gpu/drm/i915/gt/selftest_context.c
> > index 9d1ea26c7a2d..4ce1e25433d2 100644
> > --- a/drivers/gpu/drm/i915/gt/selftest_context.c
> > +++ b/drivers/gpu/drm/i915/gt/selftest_context.c
> > @@ -14,22 +14,28 @@
> >   
> >   static int request_sync(struct i915_request *rq)
> >   {
> > +     struct intel_timeline *tl = i915_request_timeline(rq);
> >       long timeout;
> >       int err = 0;
> >   
> > +     intel_timeline_get(tl);
> >       i915_request_get(rq);
> >   
> > -     i915_request_add(rq);
> > +     /* Opencode i915_request_add() so we can keep the timeline locked. */
> > +     __i915_request_commit(rq);
> > +     __i915_request_queue(rq, NULL);
> 
> Looking at i915_request_add here we also have tasklet kicking but I 
> guess for selftests it's not important.

Yup, and immediately before a wait, that tasklet should be scheduled
naturally in the near future.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-09-19 13:26 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 [this message]
2019-09-19 17:11     ` Tvrtko Ursulin
2019-09-19 17:49       ` Chris Wilson
2019-09-20  8:47         ` Tvrtko Ursulin
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=156889956418.31102.4110265390892262636@skylake-alporthouse-com \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=tvrtko.ursulin@linux.intel.com \
    /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.