public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 5/5] drm/mm: Use clear_bit_unlock() for releasing the drm_mm_node()
Date: Wed, 9 Oct 2019 17:59:17 +0200	[thread overview]
Message-ID: <20191009155917.GN16989@phenom.ffwll.local> (raw)
In-Reply-To: <0b89ccc5-1b44-121b-4601-f8ae3f67b039@linux.intel.com>

On Fri, Oct 04, 2019 at 01:01:36PM +0100, Tvrtko Ursulin wrote:
> 
> On 04/10/2019 12:17, Chris Wilson wrote:
> > Quoting Chris Wilson (2019-10-04 12:07:10)
> > > Quoting Tvrtko Ursulin (2019-10-04 10:15:20)
> > > > 
> > > > On 03/10/2019 22:01, Chris Wilson wrote:
> > > > > A few callers need to serialise the destruction of their drm_mm_node and
> > > > > ensure it is removed from the drm_mm before freeing. However, to be
> > > > > completely sure that any access from another thread is complete before
> > > > > we free the struct, we require the RELEASE semantics of
> > > > > clear_bit_unlock().
> > > > > 
> > > > > This allows the conditional locking such as
> > > > > 
> > > > > Thread A                              Thread B
> > > > >       mutex_lock(mm_lock);                if (drm_mm_node_allocated(node)) {
> > > > >       drm_mm_node_remove(node);               mutex_lock(mm_lock);
> > > > >       mutex_unlock(mm_lock);                  drm_mm_node_remove(node);
> > > > >                                               mutex_unlock(mm_lock);
> > > > >                                            }
> > > > >                                            kfree(node);
> > > > 
> > > > My understanding is that release semantics on node allocated mean 1 -> 0
> > > > transition is guaranteed to be seen only when thread A
> > > > drm_mm_node_remove is fully done with the removal. But if it is in the
> > > > middle of removal, node is still seen as allocated outside and thread B
> > > > can enter the if-body, wait for the lock, and then drm_mm_node_remove
> > > > will attempt a double removal. So I think another drm_mm_node_allocated
> > > > under the lock is needed.
> > > 
> > > Yes. Check after the lock is indeed required in this scenario. And
> > > drm_mm_node_remove() insists the caller doesn't try a double remove.
> > 
> > I had to go back and double check the vma code, and that's fine.
> > (We hit this case where one thread is evicting and another thread is
> > destroying the object. And for us we do the check under the lock inside
> > __i915_vma_unbind() on the destroy path.)
> 
> So I think if you amend the commit message to contain the repeated check
> under the lock patch looks good to me. With that:
> 
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

I think a follow-up patch to update the kerneldoc to mention that we're
guaranteeing this now is missing here (best with the above fixed example).
Plus maybe a oneline code comment for the ALLOCATED_BIT.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-10-09 15:59 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-03 21:00 [PATCH 1/5] drm/i915/execlists: Skip redundant resubmission Chris Wilson
2019-10-03 21:00 ` [PATCH 2/5] dma-fence: Serialise signal enabling (dma_fence_enable_sw_signaling) Chris Wilson
2019-10-04  8:31   ` Tvrtko Ursulin
2019-10-04 10:11   ` [PATCH] " Chris Wilson
2019-10-04 10:18     ` Tvrtko Ursulin
2019-10-03 21:00 ` [PATCH 3/5] drm/mm: Use helpers for drm_mm_node booleans Chris Wilson
2019-10-04  8:33   ` Tvrtko Ursulin
2019-10-03 21:00 ` [PATCH 4/5] drm/mm: Convert drm_mm_node booleans to bitops Chris Wilson
2019-10-04  8:34   ` Tvrtko Ursulin
2019-10-03 21:01 ` [PATCH 5/5] drm/mm: Use clear_bit_unlock() for releasing the drm_mm_node() Chris Wilson
2019-10-04  9:15   ` Tvrtko Ursulin
2019-10-04 11:07     ` Chris Wilson
2019-10-04 11:17       ` Chris Wilson
2019-10-04 12:01         ` [Intel-gfx] " Tvrtko Ursulin
2019-10-09 15:59           ` Daniel Vetter [this message]
2019-10-03 22:38 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/5] drm/i915/execlists: Skip redundant resubmission Patchwork
2019-10-03 22:58 ` ✓ Fi.CI.BAT: success " Patchwork
2019-10-04 10:08 ` [PATCH 1/5] " Tvrtko Ursulin
2019-10-04 10:25 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/5] drm/i915/execlists: Skip redundant resubmission (rev2) Patchwork
2019-10-04 11:36 ` ✓ Fi.CI.BAT: success " Patchwork
2019-10-04 11:53 ` ✗ Fi.CI.IGT: failure for series starting with [1/5] drm/i915/execlists: Skip redundant resubmission Patchwork
2019-10-04 17:01 ` ✗ Fi.CI.IGT: failure for series starting with [1/5] drm/i915/execlists: Skip redundant resubmission (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=20191009155917.GN16989@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox