All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Herrmann <dh.herrmann@gmail.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	DRI Development <dri-devel@lists.freedesktop.org>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH 09/25] drm/gem: Check locking in drm_gem_object_unreference
Date: Thu, 15 Oct 2015 10:56:07 +0200	[thread overview]
Message-ID: <CANq1E4T+o_9kJtd4TF5Hj0zvdtSXEJc8jS_Ro3VrW7Zp5c8sjQ@mail.gmail.com> (raw)
In-Reply-To: <20151015085510.GU26718@phenom.ffwll.local>

Hi

On Thu, Oct 15, 2015 at 10:55 AM, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Thu, Oct 15, 2015 at 10:36:08AM +0200, David Herrmann wrote:
>> Hi
>>
>> On Thu, Oct 15, 2015 at 9:36 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>> > Pretty soon only some drivers will need dev->struct_mutex in their
>> > gem_free_object callbacks. Hence it's really important to make sure
>> > everything still keeps getting this right.
>> >
>> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
>> > ---
>> >  include/drm/drm_gem.h | 2 ++
>> >  1 file changed, 2 insertions(+)
>> >
>> > diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
>> > index 7a592d7e398b..5b3754864fb0 100644
>> > --- a/include/drm/drm_gem.h
>> > +++ b/include/drm/drm_gem.h
>> > @@ -142,6 +142,8 @@ drm_gem_object_reference(struct drm_gem_object *obj)
>> >  static inline void
>> >  drm_gem_object_unreference(struct drm_gem_object *obj)
>> >  {
>> > +       WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
>> > +
>>
>> This doesn't work. mutex_is_locked() is not context-aware, so it does
>> not check whether the holder is the current thread or someone else.
>> You *have* to use lockdep if you want negative lock checks.
>>
>> In other words, if some other thread holds the mutex in parallel to
>> this being called, you will trigger the WARN_ON.
>
> It's the other way round: If another thread holds the lock, but the caller
> doesn't, then we won't WARN: It's a false negative, not a false positive.
>
> And since lockdep is a serious hog and no one runs it I prefer this way
> round than the "perfect" lockdep_assert_hold.
>
> Not that in the unlocked variant we can't afford this mistake, so there we
> do rely upon the perfect lockdep locking tracking and use might_lock.

Gnah, you're right! I read this as assert, not WARN_ON.. *sigh* Sorry
for the noise.

David
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2015-10-15  8:56 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-15  7:36 [PATCH 00/25] dev->struct_mutex crusade (cont'd) Daniel Vetter
2015-10-15  7:36 ` [PATCH 01/25] drm/armada: Plug leak in dumb_map_offset Daniel Vetter
2015-10-15  7:36 ` [PATCH 02/25] drm/armada: Don't grab dev->struct_mutex for in mmap offset ioctl Daniel Vetter
2015-10-15  7:36 ` [PATCH 03/25] drm/armada: Drop struct_mutex from cursor paths Daniel Vetter
2015-10-15  7:36 ` [PATCH 04/25] drm/armada: Use a private mutex to protect priv->linear Daniel Vetter
2015-10-15  7:36 ` [PATCH 05/25] drm/tegra: don't take dev->struct_mutex in mmap offset ioctl Daniel Vetter
2015-10-15 12:35   ` [PATCH] " Daniel Vetter
2015-10-15 12:40     ` Patrik Jakobsson
2015-10-21 11:23     ` Thierry Reding
2015-10-15  7:36 ` [PATCH 06/25] drm/tegra: Use drm_gem_object_reference_unlocked Daniel Vetter
2015-10-21 11:25   ` Thierry Reding
2015-10-15  7:36 ` [PATCH 07/25] drm/vgem: Drop vgem_drm_gem_mmap Daniel Vetter
2015-10-15  7:36 ` [PATCH 08/25] drm/gem: Drop struct_mutex requirement from drm_gem_mmap_obj Daniel Vetter
2015-10-15  8:34   ` David Herrmann
2015-10-15  7:36 ` [PATCH 09/25] drm/gem: Check locking in drm_gem_object_unreference Daniel Vetter
2015-10-15  8:36   ` David Herrmann
2015-10-15  8:55     ` Daniel Vetter
2015-10-15  8:56       ` David Herrmann [this message]
2015-10-15  7:36 ` [PATCH 10/25] drm/gem: Use container_of in drm_gem_object_free Daniel Vetter
2015-10-15  8:36   ` David Herrmann
2015-10-15  7:36 ` [PATCH 11/25] drm/gem: Use kref_get_unless_zero for the weak mmap references Daniel Vetter
2015-10-15  8:46   ` David Herrmann
2015-10-15  9:33   ` [PATCH] " Daniel Vetter
2015-10-15 10:06     ` Chris Wilson
2015-10-15 11:11       ` Daniel Vetter
2015-10-15 12:31         ` Daniel Vetter
2015-10-15  7:36 ` [PATCH 12/25] drm/gma500: Use correct unref in the gem bo create function Daniel Vetter
2015-10-15 12:48   ` Patrik Jakobsson
2015-10-15  7:36 ` [PATCH 13/25] drm/gma500: Drop dev->struct_mutex from modeset code Daniel Vetter
2015-10-15 13:07   ` Patrik Jakobsson
2015-10-15  7:36 ` [PATCH 14/25] drm/gma500: Drop dev->struct_mutex from fbdev init/teardown code Daniel Vetter
2015-10-15 13:24   ` Patrik Jakobsson
2015-10-15  7:36 ` [PATCH 15/25] drm/gma500: Drop dev->struct_mutex from mmap offset function Daniel Vetter
2015-10-15 17:04   ` Patrik Jakobsson
2015-10-15  7:36 ` [PATCH 16/25] drm/gma500: Add driver private mutex for the fault handler Daniel Vetter
2015-10-15  7:36 ` [PATCH 17/25] drm/nouveau: Drop dev->struct_mutex from fbdev init Daniel Vetter
2015-10-15  7:36 ` [PATCH 18/25] drm/radeon: Use rdev->gem.mutex to protect hyperz/cmask owners Daniel Vetter
2015-10-15  8:27   ` Christian König
2015-10-15 14:24     ` Alex Deucher
2015-10-15  7:36 ` [PATCH 19/25] drm/exynos: Drop dev->struct_mutex from mmap offset function Daniel Vetter
2015-10-15  7:36 ` [PATCH 20/25] drm/exynos: drop struct_mutex from exynos_gem_map_sgt_with_dma Daniel Vetter
2015-10-15  7:36 ` [PATCH 21/25] drm/exynos: drop struct_mutex from exynos_drm_gem_get_ioctl Daniel Vetter
2015-10-15  7:36 ` [PATCH 22/25] drm/exynos: drop struct_mutex from fbdev setup Daniel Vetter
2015-10-15  7:36 ` [PATCH 23/25] drm/vgem: Simplify dum_map Daniel Vetter
2015-10-15  7:36 ` [PATCH 24/25] drm/vgem: Move get_pages to gem_create Daniel Vetter
2015-10-15  7:36 ` [PATCH 25/25] drm/vgem: Drop dev->struct_mutex Daniel Vetter

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=CANq1E4T+o_9kJtd4TF5Hj0zvdtSXEJc8jS_Ro3VrW7Zp5c8sjQ@mail.gmail.com \
    --to=dh.herrmann@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@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 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.