From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx112.postini.com [74.125.245.112]) by kanga.kvack.org (Postfix) with SMTP id 102A86B005D for ; Thu, 3 Jan 2013 20:18:33 -0500 (EST) Received: by mail-pb0-f49.google.com with SMTP id un15so8795648pbc.22 for ; Thu, 03 Jan 2013 17:18:33 -0800 (PST) Message-ID: <1357262311.5105.6.camel@kernel.cn.ibm.com> Subject: Re: [PATCH] mm: protect against concurrent vma expansion From: Simon Jeons Date: Thu, 03 Jan 2013 19:18:31 -0600 In-Reply-To: References: <1354344987-28203-1-git-send-email-walken@google.com> <20121203150110.39c204ff.akpm@linux-foundation.org> <20121203164322.b967d461.akpm@linux-foundation.org> <20121204144820.GA13916@google.com> <1355968594.1415.4.camel@kernel-VirtualBox> <1357260005.4930.6.camel@kernel.cn.ibm.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Michel Lespinasse Cc: Andrew Morton , linux-mm@kvack.org, Rik van Riel , Hugh Dickins , linux-kernel@vger.kernel.org On Thu, 2013-01-03 at 16:50 -0800, Michel Lespinasse wrote: > On Thu, Jan 3, 2013 at 4:40 PM, Simon Jeons 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 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. > Thanks for your quick explanation. > 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. If this senario only occur for userspace stack? > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org