From: Daniel Vetter <daniel@ffwll.ch>
To: Ilija Hadzic <ihadzic@research.bell-labs.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/3] drm: make DRM_UNLOCKED ioctls with their own mutex
Date: Wed, 26 Oct 2011 22:01:55 +0200 [thread overview]
Message-ID: <20111026200155.GA3194@phenom.ffwll.local> (raw)
In-Reply-To: <Pine.GSO.4.62.1110261029170.22824@umail>
On Wed, Oct 26, 2011 at 11:11:14AM -0500, Ilija Hadzic wrote:
> On Wed, 26 Oct 2011, Daniel Vetter wrote:
> >
> >Just to check before I dig into reviewing this: Have you check all the
> >other users of these data structure that these functions touch whether
> >they don't accidentally rely on the global lock being taken?
>
> I did and thought it was safe. I re-checked this morning prompted by
> your note and of course there is one (easily fixable) thing that I
> missed.
> Here is the full "report":
>
> drm_getclient is safe: the only thing that should be protected there
> is dev->filelist and that is all protected in other functions using
> struct_mutex.
>
> drm_getstats is safe: actually I think there is no need for any mutex there
> because the loop runs through quasi-static (set at load time only)
> data, and the actual count access is done with atomic_read()
>
> drm_getmap has one problem which I can fix (and it's the hardest to
> follow): the structure that should be protected there is the
> dev->maplist. There are three functions that may potentially be an
> issue:
>
> drm_getsarea doesn't grab any lock before touching dev->maplist (so
> global mutex won't help here either). However, drivers seem to call
> it only at initialization time so it probably doesn't matter
>
> drm_master_destroy doesn't grab any lock either, but it is called
> from drm_master_put which is protected with dev->struct_mutex
> everywhere else in drm module. I also see a couple of calls
> to drm_master_destroy from vmwgfx driver that look unlocked
> to me, but drm_global_mutex won't help here either
>
> drm_getsareactx uses struct_mutex, but it apparently releases it
> too early (that's the problem I missed initially). If it's released
> after it's done with dev->maplist, we should be fine.
>
> I'll redo this patch with a fix to drm_getsareactx and that should do it.
> I would still appreciate another pair of eyes to make sure I didn't
> miss anything else
Awesome. Please include this in the patch description, and if the
description gets too complicated, maybe even split up the patches into the
individual cases. Also, when you can convince yourself that drm_getstats
doesn't need the struct_mutex, I think it'd be best to drop it. Locking
that doesn't actually protect anything just confuses, especially here in
drm where the locking isn't too clear to begin with.
Yours, Daniel
--
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48
next prev parent reply other threads:[~2011-10-26 20:01 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-26 2:20 drm: fix one flawed mutex grab and remove some spurious mutex grabs Ilija Hadzic
2011-10-26 2:20 ` [PATCH 1/3] drm: no need to hold global mutex for static data Ilija Hadzic
2011-10-26 7:44 ` Daniel Vetter
2011-10-26 2:20 ` [PATCH 2/3] drm: make DRM_UNLOCKED ioctls with their own mutex Ilija Hadzic
2011-10-26 7:47 ` Daniel Vetter
2011-10-26 16:11 ` Ilija Hadzic
2011-10-26 20:01 ` Daniel Vetter [this message]
2011-10-26 2:20 ` [PATCH 3/3] drm: do not sleep on vblank while holding a mutex Ilija Hadzic
2011-10-26 7:54 ` Daniel Vetter
2011-10-26 22:33 ` Ilija Hadzic
2011-10-27 10:43 ` Daniel Vetter
2011-10-27 14:10 ` Alan Coopersmith
2011-10-27 14:20 ` Ilija Hadzic
2011-10-28 3:19 ` Ilija Hadzic
2011-10-28 4:36 ` Ilija Hadzic
2011-10-28 6:59 ` Michel Dänzer
2011-10-28 9:20 ` Daniel Vetter
2011-10-28 12:10 ` Ilija Hadzic
2011-10-28 14:51 ` Daniel Vetter
2011-10-28 9:30 ` Daniel Vetter
2011-10-26 8:02 ` Michel Dänzer
2011-10-26 22:50 ` Ilija Hadzic
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=20111026200155.GA3194@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=ihadzic@research.bell-labs.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.