Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Chris Wilson <chris@chris-wilson.co.uk>,
	intel-gfx@lists.freedesktop.org,
	Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: Re: [PATCH 1/2] drm/i915: Add smp_rmb() to busy ioctl's RCU dance
Date: Tue, 9 Aug 2016 08:30:06 +0200	[thread overview]
Message-ID: <20160809063006.GH6232@phenom.ffwll.local> (raw)
In-Reply-To: <20160806102622.GB11646@nuc-i3427.alporthouse.com>

On Sat, Aug 06, 2016 at 11:26:22AM +0100, Chris Wilson wrote:
> On Fri, Aug 05, 2016 at 10:13:22PM +0100, Chris Wilson wrote:
> > In the debate as to whether the second read of active->request is
> > ordered after the dependent reads of the first read of active->request,
> > just give in and throw a smp_rmb() in there so that ordering of loads is
> > assured.
> > 
> > v2: Explain the manual smp_rmb()
> > 
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> > ---
> >  drivers/gpu/drm/i915/i915_gem.c         | 25 ++++++++++++++++++++-----
> >  drivers/gpu/drm/i915/i915_gem_request.h |  3 +++
> >  2 files changed, 23 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> > index f4f8eaa90f2a..654f0b015f97 100644
> > --- a/drivers/gpu/drm/i915/i915_gem.c
> > +++ b/drivers/gpu/drm/i915/i915_gem.c
> > @@ -3735,7 +3735,7 @@ i915_gem_object_ggtt_unpin_view(struct drm_i915_gem_object *obj,
> >  	i915_vma_unpin(i915_gem_obj_to_ggtt_view(obj, view));
> >  }
> >  
> > -static __always_inline unsigned __busy_read_flag(unsigned int id)
> > +static __always_inline unsigned int __busy_read_flag(unsigned int id)
> >  {
> >  	/* Note that we could alias engines in the execbuf API, but
> >  	 * that would be very unwise as it prevents userspace from
> > @@ -3753,7 +3753,7 @@ static __always_inline unsigned int __busy_write_id(unsigned int id)
> >  	return id;
> >  }
> >  
> > -static __always_inline unsigned
> > +static __always_inline unsigned int
> >  __busy_set_if_active(const struct i915_gem_active *active,
> >  		     unsigned int (*flag)(unsigned int id))
> >  {
> > @@ -3770,19 +3770,34 @@ __busy_set_if_active(const struct i915_gem_active *active,
> >  
> >  		id = request->engine->exec_id;
> >  
> > -		/* Check that the pointer wasn't reassigned and overwritten. */
> > +		/* Check that the pointer wasn't reassigned and overwritten.
> > +		 *
> > +		 * In __i915_gem_active_get_rcu(), we enforce ordering between
> > +		 * the first rcu pointer dereference (imposing a
> > +		 * read-dependency only on access through the pointer) and
> > +		 * the second lockless access through the memory barrier
> > +		 * following a successful atomic_inc_not_zero(). Here there
> > +		 * is no such barrier, and so we must manually insert an
> > +		 * explicit read barrier to ensure that the following
> > +		 * access occurs after all the loads through the first
> > +		 * pointer.
> > +		 *
> > +		 * The corresponding write barrier is part of
> > +		 * rcu_assign_pointer().
> > +		 */
> > +		smp_rmb();
> 
> Are you sure this should not just be a read_barrier_depends()?
> 
> active->request is data dependent on the earlier reads through it, and
> here we are only caring that those loads are completed before we double
> check the request hasn't been overwritten.

There's no data depency between loading request->engine->exec_id and
(re)loading active->request. I think full smp_rmb it needs to be.
-Daniel
-- 
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

      reply	other threads:[~2016-08-09  6:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-05 21:13 [PATCH 1/2] drm/i915: Add smp_rmb() to busy ioctl's RCU dance Chris Wilson
2016-08-05 21:13 ` [PATCH 2/2] drm/i915: Do not overwrite the request with zero on reallocation Chris Wilson
2016-08-06  9:11 ` ✗ Ro.CI.BAT: failure for series starting with [1/2] drm/i915: Add smp_rmb() to busy ioctl's RCU dance Patchwork
2016-08-06 10:26 ` [PATCH 1/2] " Chris Wilson
2016-08-09  6:30   ` Daniel Vetter [this message]

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=20160809063006.GH6232@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=chris@chris-wilson.co.uk \
    --cc=daniel.vetter@ffwll.ch \
    --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