From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail190.messagelabs.com (mail190.messagelabs.com [216.82.249.51]) by kanga.kvack.org (Postfix) with ESMTP id 036176B0011 for ; Wed, 4 May 2011 21:18:15 -0400 (EDT) Received: from hpaq6.eem.corp.google.com (hpaq6.eem.corp.google.com [172.25.149.6]) by smtp-out.google.com with ESMTP id p451ICXv028549 for ; Wed, 4 May 2011 18:18:12 -0700 Received: from gyf1 (gyf1.prod.google.com [10.243.50.65]) by hpaq6.eem.corp.google.com with ESMTP id p451IA3p005065 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT) for ; Wed, 4 May 2011 18:18:11 -0700 Received: by gyf1 with SMTP id 1so844605gyf.34 for ; Wed, 04 May 2011 18:18:09 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: Date: Wed, 4 May 2011 18:18:09 -0700 Message-ID: Subject: Re: [PATCH] mm: fix possible cause of a page_mapped BUG From: Michel Lespinasse Content-Type: text/plain; charset=ISO-8859-1 Sender: owner-linux-mm@kvack.org List-ID: To: Linus Torvalds Cc: =?UTF-8?B?Um9iZXJ0IMWad2nEmWNraQ==?= , Hugh Dickins , Andrew Morton , Miklos Szeredi , "Eric W. Biederman" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Peter Zijlstra , Rik van Riel On Wed, May 4, 2011 at 5:38 PM, Linus Torvalds wrote: >> A more conservative alternative could >> be to enable the guard page special case under an new GUP flag, but >> this loses much of the elegance of your original proposal... > > How about only doing that only for FOLL_MLOCK? Sounds reasonable. > Also, looking at mm/mlock.c, why _do_ we call get_user_pages() even if > the vma isn't mlocked? That looks bogus. Since we have dropped the > mm_semaphore, an unlock may have happened, and afaik we should *not* > try to bring those pages back in at all. There's this whole comment > about that in the caller ("__mlock_vma_pages_range() double checks the > vma flags, so that it won't mlock pages if the vma was already > munlocked."), but despite that it would actually call > __get_user_pages() even if the VM_LOCKED bit had been cleared (it just > wouldn't call it with the FOLL_MLOCK flag). There are two reasons VM_LOCKED might be cleared in __mlock_vma_pages_range(). It could be that one of the VM_SPECIAL flags were set on the VMA, in which case mlock() won't set VM_LOCKED but it still must make the pages present. Or, there is an munlock() executing concurrently with mlock() - in that case, the conservative thing to do is to give the same results as if the mlock() had completed before the munlock(). That is, the mlock() would have broken COW / made the pages present and the munlock() would have cleared the VM_LOCKED and PageMlocked flags. > UNTESTED! And maybe there was some really subtle reason to still call > __get_user_pages() without that FOLL_MLOCK thing that I'm missing. I think we want the mm/memory.c part of this proposal without the mm/mlock.c part. -- Michel "Walken" Lespinasse A program is never fully debugged until the last user dies. -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org