Commit 128557ff authored by Michel Lespinasse's avatar Michel Lespinasse Committed by Linus Torvalds

mm: use mm_populate() when adjusting brk with MCL_FUTURE in effect

Signed-off-by: default avatarMichel Lespinasse <walken@google.com>
Acked-by: default avatarRik van Riel <riel@redhat.com>
Tested-by: default avatarAndy Lutomirski <luto@amacapital.net>
Cc: Greg Ungerer <gregungerer@westnet.com.au>
Cc: David Howells <dhowells@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a1ea9549
...@@ -256,6 +256,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk) ...@@ -256,6 +256,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
unsigned long newbrk, oldbrk; unsigned long newbrk, oldbrk;
struct mm_struct *mm = current->mm; struct mm_struct *mm = current->mm;
unsigned long min_brk; unsigned long min_brk;
bool populate;
down_write(&mm->mmap_sem); down_write(&mm->mmap_sem);
...@@ -305,8 +306,15 @@ SYSCALL_DEFINE1(brk, unsigned long, brk) ...@@ -305,8 +306,15 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
/* Ok, looks good - let it rip. */ /* Ok, looks good - let it rip. */
if (do_brk(oldbrk, newbrk-oldbrk) != oldbrk) if (do_brk(oldbrk, newbrk-oldbrk) != oldbrk)
goto out; goto out;
set_brk: set_brk:
mm->brk = brk; mm->brk = brk;
populate = newbrk > oldbrk && (mm->def_flags & VM_LOCKED) != 0;
up_write(&mm->mmap_sem);
if (populate)
mm_populate(oldbrk, newbrk - oldbrk);
return brk;
out: out:
retval = mm->brk; retval = mm->brk;
up_write(&mm->mmap_sem); up_write(&mm->mmap_sem);
...@@ -2600,10 +2608,8 @@ static unsigned long do_brk(unsigned long addr, unsigned long len) ...@@ -2600,10 +2608,8 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
out: out:
perf_event_mmap(vma); perf_event_mmap(vma);
mm->total_vm += len >> PAGE_SHIFT; mm->total_vm += len >> PAGE_SHIFT;
if (flags & VM_LOCKED) { if (flags & VM_LOCKED)
if (!mlock_vma_pages_range(vma, addr, addr + len)) mm->locked_vm += (len >> PAGE_SHIFT);
mm->locked_vm += (len >> PAGE_SHIFT);
}
return addr; return addr;
} }
...@@ -2611,10 +2617,14 @@ unsigned long vm_brk(unsigned long addr, unsigned long len) ...@@ -2611,10 +2617,14 @@ unsigned long vm_brk(unsigned long addr, unsigned long len)
{ {
struct mm_struct *mm = current->mm; struct mm_struct *mm = current->mm;
unsigned long ret; unsigned long ret;
bool populate;
down_write(&mm->mmap_sem); down_write(&mm->mmap_sem);
ret = do_brk(addr, len); ret = do_brk(addr, len);
populate = ((mm->def_flags & VM_LOCKED) != 0);
up_write(&mm->mmap_sem); up_write(&mm->mmap_sem);
if (populate)
mm_populate(addr, len);
return ret; return ret;
} }
EXPORT_SYMBOL(vm_brk); EXPORT_SYMBOL(vm_brk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment