Messages in this thread | | | Date | Wed, 4 May 2011 18:18:09 -0700 | Subject | Re: [PATCH] mm: fix possible cause of a page_mapped BUG | From | Michel Lespinasse <> |
| |
On Wed, May 4, 2011 at 5:38 PM, Linus Torvalds <torvalds@linux-foundation.org> 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.
| |