[prev in list] [next in list] [prev in thread] [next in thread] 

List:       dri-devel
Subject:    Re: [PATCH] drm: Take mmap_sem up front to avoid lock order
From:       Kristian_Høgsberg <krh () bitplanet ! net>
Date:       2009-02-18 17:57:57
Message-ID: 59ad55d30902180957u3927ac40wb43d7623df3f6537 () mail ! gmail ! com
[Download RAW message or body]

On Wed, Feb 18, 2009 at 12:36 PM, Eric Anholt <eric@anholt.net> wrote:
> On Wed, 2009-02-18 at 11:02 -0500, krh@bitplanet.net wrote:
>> From: Kristian Høgsberg <krh@redhat.com>
>>
>> A number of GEM operations (and legacy drm ones) want to copy data to
>> or from userspace while holding the struct_mutex lock.  However, the
>> fault handler calls us with the mmap_sem held and thus enforces the
>> opposite locking order.  This patch downs the mmap_sem up front for
>> those operations that access userspace data under the struct_mutex
>> lock to ensure the locking order is consistent.
>>
>> Signed-off-by: Kristian Høgsberg <krh@redhat.com>
>
> Have you tested this against actually faulting?  My understanding was
> that you can't recurse on mmap_sem.

I tested it and it worked, but didn't add code to detect contention so
I can't say for sure I hit that case.  mmap_sem is a read/write
semaphore, so while we can't recurse, we can get away with taking two
reader locks.

cheers,
Kristian

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic