mm: directly use __mlock_vma_pages_range() in find_extend_vma()
In find_extend_vma(), we don't need mlock_vma_pages_range() to verify the vma type - we know we're working with a stack. So, we can call directly into __mlock_vma_pages_range(), and remove the last make_pages_present() call site. Note that we don't use mm_populate() here, so we can't release the mmap_sem while allocating new stack pages. This is deemed acceptable, because the stack vmas grow by a bounded number of pages at a time, and these are anon pages so we don't have to read from disk to populate them. Signed-off-by: Michel Lespinasse <walken@google.com> Acked-by: Rik van Riel <riel@redhat.com> Tested-by: Andy Lutomirski <luto@amacapital.net> Cc: Greg Ungerer <gregungerer@westnet.com.au> Cc: David Howells <dhowells@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:

committed by
Linus Torvalds

parent
c22c0d6344
commit
cea10a19b7
24
mm/memory.c
24
mm/memory.c
@@ -3824,30 +3824,6 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
|
||||
}
|
||||
#endif /* __PAGETABLE_PMD_FOLDED */
|
||||
|
||||
int make_pages_present(unsigned long addr, unsigned long end)
|
||||
{
|
||||
int ret, len, write;
|
||||
struct vm_area_struct * vma;
|
||||
|
||||
vma = find_vma(current->mm, addr);
|
||||
if (!vma)
|
||||
return -ENOMEM;
|
||||
/*
|
||||
* We want to touch writable mappings with a write fault in order
|
||||
* to break COW, except for shared mappings because these don't COW
|
||||
* and we would not want to dirty them for nothing.
|
||||
*/
|
||||
write = (vma->vm_flags & (VM_WRITE | VM_SHARED)) == VM_WRITE;
|
||||
BUG_ON(addr >= end);
|
||||
BUG_ON(end > vma->vm_end);
|
||||
len = DIV_ROUND_UP(end, PAGE_SIZE) - addr/PAGE_SIZE;
|
||||
ret = get_user_pages(current, current->mm, addr,
|
||||
len, write, 0, NULL, NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
return ret == len ? 0 : -EFAULT;
|
||||
}
|
||||
|
||||
#if !defined(__HAVE_ARCH_GATE_AREA)
|
||||
|
||||
#if defined(AT_SYSINFO_EHDR)
|
||||
|
Reference in New Issue
Block a user