From: Daniel Vetter <daniel@ffwll.ch>
To: Chris Wilson <chris@chris-wilson.co.uk>,
Daniel Vetter <daniel@ffwll.ch>,
intel-gfx@lists.freedesktop.org, "Goel,
Akash" <akash.goel@intel.com>,
Josh Triplett <josh@joshtriplett.org>
Subject: Re: [PATCH 21/22] drm/i915: Enable lockless lookup of request tracking via RCU
Date: Fri, 29 Jul 2016 10:41:14 +0200 [thread overview]
Message-ID: <20160729084114.GV6232@phenom.ffwll.local> (raw)
In-Reply-To: <20160728204958.GA17037@nuc-i3427.alporthouse.com>
On Thu, Jul 28, 2016 at 09:49:58PM +0100, Chris Wilson wrote:
> On Thu, Jul 28, 2016 at 12:23:40PM +0200, Daniel Vetter wrote:
> > I think we have a race here still: The issue is that the
> > kref_get_unless_zero is an unordered atomic, and the rcu_dereference is
> > only an smb_read_barrier_depends, which doesn't prevent the fetch from
> > happening before the atomic_add_unless.
> >
> > Well until I opened memory-barriers.txt and learned that atomic_add_unless
> > is a full smp_mb() on both sides on success. That's a bit too tricky for
> > my taste, what about the following comment:
> >
> > /* When request_get_rcu succeds the underlying
> > * atomic_add_unless has a full smp_mb() on both sides.
> > * This ensures that the rcu_dereference() below can't be
> > * reordered before the the refcounting increase has
> > * happened, which prevents the request from being reused.
> > */
> >
> > I couldn't poke any other holes into this, and we're reusing the fence rcu
> > functions where appropriate. With the comment:
>
I guess it doesn't hurt to make this really, really clear. Perfect! Well
almost, one nit:
>
> /* What stops the following rcu_dereference() from occuring
> * before the above i915_gem_request_get_rcu()? If we were
> * to read the value before pausing to get the reference to
> * the request, we may not notice a change in the active
> * tracker.
> *
> * The rcu_dereference() is a mere read barrier, which means
s/read barrier/barrier of depending reads/, rcu_dereference is not even a
full rmb!
> * that operations after it will appear after, neither the
hence also: s/operations/any operations through the read pointer/
Aside: I'm always impressive how alpha managed to mispredict dependent
reads somehow ... "sorry my magic 8ball had a glitch"!?
-Daniel
> * CPU nor the compiler will bring them forwards. However,
> * that does not restrict the rcu_dereference() itself. The
> * read may be performed earlier by an out-of-order CPU, or
> * adventurous compiler.
> *
> * The atomic operation at the heart of
> * i915_gem_request_get_rcu(), see fence_get_rcu(), is
> * atomic_inc_not_zero() which is only a full memory barrier
> * when succesful. That is, if i915_gem_request_get_rcu()
> * returns the request (and so with the reference counted
> * incremented) then the following read for rcu_dereference()
> * must occur after the atomic operation and so confirm
> * that this request is the one currently being tracked.
> */
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-07-29 8:41 UTC|newest]
Thread overview: 95+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-27 11:14 Getting to RCU and exporting fences Chris Wilson
2016-07-27 11:14 ` [PATCH 01/22] drm/i915: Combine loops within i915_gem_evict_something Chris Wilson
2016-07-29 6:17 ` Joonas Lahtinen
2016-07-29 6:31 ` Chris Wilson
2016-07-27 11:14 ` [PATCH 02/22] drm/i915: Remove surplus drm_device parameter to i915_gem_evict_something() Chris Wilson
2016-07-28 8:07 ` Joonas Lahtinen
2016-07-27 11:14 ` [PATCH 03/22] drm/i915: Double check the active status on the batch pool Chris Wilson
2016-07-28 8:14 ` Joonas Lahtinen
2016-07-27 11:14 ` [PATCH 04/22] drm/i915: Remove request retirement before each batch Chris Wilson
2016-07-28 8:32 ` Joonas Lahtinen
2016-07-28 9:32 ` Chris Wilson
2016-07-28 9:53 ` Joonas Lahtinen
2016-07-28 9:54 ` Daniel Vetter
2016-07-28 10:26 ` Chris Wilson
2016-07-28 11:52 ` Daniel Vetter
2016-07-28 12:24 ` Chris Wilson
2016-07-28 14:21 ` Chris Wilson
2016-07-27 11:14 ` [PATCH 05/22] drm/i915: Remove i915_gem_execbuffer_retire_commands() Chris Wilson
2016-07-28 8:46 ` Joonas Lahtinen
2016-07-28 8:55 ` Chris Wilson
2016-07-28 9:54 ` Joonas Lahtinen
2016-07-27 11:14 ` [PATCH 06/22] drm/i915: Fix up vma alignment to be u64 Chris Wilson
2016-07-28 8:59 ` Joonas Lahtinen
2016-07-27 11:14 ` [PATCH 07/22] drm/i915: Pad GTT views of exec objects up to user specified size Chris Wilson
2016-07-28 9:55 ` Daniel Vetter
2016-07-28 10:33 ` Chris Wilson
2016-07-29 7:59 ` Joonas Lahtinen
2016-07-29 8:08 ` Chris Wilson
2016-07-29 8:55 ` Joonas Lahtinen
2016-07-27 11:14 ` [PATCH 08/22] drm/i915: Reduce WARN(i915_gem_valid_gtt_space) to a debug-only check Chris Wilson
2016-07-28 9:18 ` Joonas Lahtinen
2016-07-27 11:14 ` [PATCH 09/22] drm/i915: Split insertion/binding of an object into the VM Chris Wilson
2016-07-28 9:25 ` Joonas Lahtinen
2016-07-28 9:34 ` Chris Wilson
2016-07-27 11:14 ` [PATCH 10/22] drm/i915: Record allocated vma size Chris Wilson
2016-07-29 6:53 ` Joonas Lahtinen
2016-07-29 7:18 ` Chris Wilson
2016-07-29 10:19 ` [PATCH] drm/i915: Convert 4096 alignment request to 0 for drm_mm allocations Chris Wilson
2016-07-29 10:28 ` Joonas Lahtinen
2016-07-29 10:38 ` Chris Wilson
2016-07-27 11:14 ` [PATCH 11/22] drm/i915: Wrap vma->pin_count accessors with small inline helpers Chris Wilson
2016-07-29 6:59 ` Joonas Lahtinen
2016-07-29 7:23 ` Chris Wilson
2016-07-27 11:14 ` [PATCH 12/22] drm/i915: Start passing around i915_vma from execbuffer Chris Wilson
2016-07-29 8:23 ` Joonas Lahtinen
2016-08-01 7:34 ` Chris Wilson
2016-07-27 11:14 ` [PATCH 13/22] drm/i915: Combine all i915_vma bitfields into a single set of flags Chris Wilson
2016-07-29 7:30 ` Joonas Lahtinen
2016-07-29 7:44 ` Chris Wilson
2016-07-27 11:14 ` [PATCH 14/22] drm/i915: Make i915_vma_pin() small and inline Chris Wilson
2016-07-28 11:06 ` Joonas Lahtinen
2016-07-27 11:14 ` [PATCH 15/22] drm/i915: Remove highly confusing i915_gem_obj_ggtt_pin() Chris Wilson
2016-07-28 10:38 ` Joonas Lahtinen
2016-07-28 11:36 ` Chris Wilson
2016-07-28 11:53 ` Joonas Lahtinen
2016-07-28 16:12 ` Chris Wilson
2016-07-29 9:10 ` Joonas Lahtinen
2016-07-27 11:14 ` [PATCH 16/22] drm/i915: Make fb_tracking.lock a spinlock Chris Wilson
2016-07-28 10:02 ` Daniel Vetter
2016-07-28 10:08 ` Daniel Vetter
2016-07-29 8:25 ` Chris Wilson
2016-07-28 10:19 ` Joonas Lahtinen
2016-07-27 11:14 ` [PATCH 17/22] drm/i915: Use atomics to manipulate obj->frontbuffer_bits Chris Wilson
2016-07-28 9:49 ` Joonas Lahtinen
2016-07-28 10:10 ` Chris Wilson
2016-07-28 10:51 ` Joonas Lahtinen
2016-07-28 10:05 ` Daniel Vetter
2016-07-27 11:14 ` [PATCH 18/22] drm/i915: Use dev_priv consistently through the intel_frontbuffer interface Chris Wilson
2016-07-28 9:36 ` Joonas Lahtinen
2016-07-28 10:06 ` Daniel Vetter
2016-07-27 11:14 ` [PATCH 19/22] drm/i915: Move obj->active:5 to obj->flags Chris Wilson
2016-07-29 7:40 ` Joonas Lahtinen
2016-07-29 8:04 ` Chris Wilson
2016-07-29 8:10 ` Chris Wilson
2016-07-29 9:34 ` Joonas Lahtinen
2016-07-27 11:14 ` [PATCH 20/22] drm/i915: Move i915_gem_object_wait_rendering() Chris Wilson
2016-07-28 9:37 ` Joonas Lahtinen
2016-07-27 11:14 ` [PATCH 21/22] drm/i915: Enable lockless lookup of request tracking via RCU Chris Wilson
2016-07-28 10:23 ` Daniel Vetter
2016-07-28 20:49 ` Chris Wilson
2016-07-29 8:41 ` Daniel Vetter [this message]
2016-07-29 8:49 ` Chris Wilson
2016-07-29 9:43 ` Chris Wilson
2016-07-29 9:45 ` Daniel Vetter
2016-07-27 11:15 ` [PATCH 22/22] drm/i915: Export our request as a dma-buf fence on the reservation object Chris Wilson
2016-07-28 10:32 ` Daniel Vetter
2016-07-28 10:40 ` Chris Wilson
2016-07-28 11:59 ` Daniel Vetter
2016-07-28 12:17 ` Chris Wilson
2016-07-28 12:28 ` Daniel Vetter
2016-07-28 12:45 ` Chris Wilson
2016-07-28 20:14 ` Daniel Vetter
2016-07-28 21:08 ` Chris Wilson
2016-07-27 11:23 ` ✗ Ro.CI.BAT: failure for series starting with [01/22] drm/i915: Combine loops within i915_gem_evict_something Patchwork
2016-07-29 10:20 ` ✗ Ro.CI.BAT: failure for series starting with [01/22] drm/i915: Combine loops within i915_gem_evict_something (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=20160729084114.GV6232@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=akash.goel@intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=intel-gfx@lists.freedesktop.org \
--cc=josh@joshtriplett.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