lkml.org 
[lkml]   [2013]   [Jan]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] mm: protect against concurrent vma expansion
From
On Thu, Jan 3, 2013 at 4:40 PM, Simon Jeons <simon.jeons@gmail.com> wrote:
> On Wed, 2012-12-19 at 19:01 -0800, Michel Lespinasse wrote:
>> Hi Simon,
>>
>> On Wed, Dec 19, 2012 at 5:56 PM, Simon Jeons <simon.jeons@gmail.com> wrote:
>> > One question.
>> >
>> > I found that mainly callsite of expand_stack() is #PF, but it holds
>> > mmap_sem each time before call expand_stack(), how can hold a *shared*
>> > mmap_sem happen?
>>
>> the #PF handler calls down_read(&mm->mmap_sem) before calling expand_stack.
>>
>> I think I'm just confusing you with my terminology; shared lock ==
>> read lock == several readers might hold it at once (I'd say they share
>> it)
>
> Sorry for my late response.
>
> Since expand_stack() will modify vma, then why hold a read lock here?

Well, it'd be much nicer if we had a write lock, I think. But, we
didn't know when taking the lock that we'd end up having to expand
stacks.

What happens is that page faults don't generally modify vmas, so they
get a read lock (just to know what vma the fault is happening in) and
then fault in the page.

expand_stack() is the one exception to that - after getting the read
lock as usual, we notice that the fault is not in any vma right now,
but it's close enough to an expandable vma.

--
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.


\
 
 \ /
  Last update: 2013-01-04 02:21    [W:0.069 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site