From: "Michel Dänzer" <michel@daenzer.net>
To: Ilija Hadzic <ihadzic@research.bell-labs.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 3/3] drm: do not sleep on vblank while holding a mutex
Date: Wed, 26 Oct 2011 10:02:24 +0200 [thread overview]
Message-ID: <1319616144.19240.37.camel@thor.local> (raw)
In-Reply-To: <1319595614-9098-4-git-send-email-ihadzic@research.bell-labs.com>
On Die, 2011-10-25 at 22:20 -0400, Ilija Hadzic wrote:
> holding the drm_global_mutex in drm_wait_vblank and then
> going to sleep (via DRM_WAIT_ON) is a bad idea in general
> because it can block other processes that may issue ioctls
> that also grab drm_global_mutex. Blocking can occur until
> next vblank which is in the tens of microseconds order of
> magnitude.
>
> fix it, but making drm_wait_vblank DRM_UNLOCKED call and
> then grabbing the mutex inside the drm_wait_vblank function
> and only for the duration of the critical section (i.e.,
> from first manipulation of vblank sequence number until
> putting the task in the wait queue).
Does it really need drm_global_mutex at all, as opposed to e.g.
dev->struct_mutex?
> diff --git a/include/drm/drm_os_linux.h b/include/drm/drm_os_linux.h
> index 3933691..fc6aaf4 100644
> --- a/include/drm/drm_os_linux.h
> +++ b/include/drm/drm_os_linux.h
> @@ -123,5 +123,30 @@ do
> { \
> remove_wait_queue(&(queue), &entry); \
> } while (0)
>
> +#define DRM_WAIT_ON_LOCKED( ret, queue, timeout, condition ) \
> +do { \
> + DECLARE_WAITQUEUE(entry, current); \
> + unsigned long end = jiffies + (timeout); \
> + add_wait_queue(&(queue), &entry); \
> + mutex_unlock(&drm_global_mutex); \
I agree with Daniel's sentiment on this. AFAICT add_wait_queue()
protects against concurrent access to the wait queue, so I think it
would be better to just drop the mutex explicitly before calling
DRM_WAIT_ON.
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Debian, X and DRI developer
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2011-10-26 8:02 UTC|newest]
Thread overview: 25+ 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
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 [this message]
2011-10-26 22:50 ` Ilija Hadzic
[not found] <mailman.37.1319803862.23620.dri-devel@lists.freedesktop.org>
2011-10-28 18:15 ` Mario Kleiner
2011-10-28 19:15 ` Daniel Vetter
2011-10-28 19:53 ` Mario Kleiner
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=1319616144.19240.37.camel@thor.local \
--to=michel@daenzer.net \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox