diff options
author | Michel Lespinasse <walken@google.com> | 2013-02-22 19:32:40 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-23 20:50:11 -0500 |
commit | 128557ffe147c282d8a25e6faeaec6099540bea4 (patch) | |
tree | b3a0ce0540dd51f634f7ba9f7f7bf16576dce2cb /mm/mmap.c | |
parent | a1ea9549a7254b17ba85809f4a0200abc21453a2 (diff) |
mm: use mm_populate() when adjusting brk with MCL_FUTURE in effect
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>
Diffstat (limited to 'mm/mmap.c')
-rw-r--r-- | mm/mmap.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -256,6 +256,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk) | |||
256 | unsigned long newbrk, oldbrk; | 256 | unsigned long newbrk, oldbrk; |
257 | struct mm_struct *mm = current->mm; | 257 | struct mm_struct *mm = current->mm; |
258 | unsigned long min_brk; | 258 | unsigned long min_brk; |
259 | bool populate; | ||
259 | 260 | ||
260 | down_write(&mm->mmap_sem); | 261 | down_write(&mm->mmap_sem); |
261 | 262 | ||
@@ -305,8 +306,15 @@ SYSCALL_DEFINE1(brk, unsigned long, brk) | |||
305 | /* Ok, looks good - let it rip. */ | 306 | /* Ok, looks good - let it rip. */ |
306 | if (do_brk(oldbrk, newbrk-oldbrk) != oldbrk) | 307 | if (do_brk(oldbrk, newbrk-oldbrk) != oldbrk) |
307 | goto out; | 308 | goto out; |
309 | |||
308 | set_brk: | 310 | set_brk: |
309 | mm->brk = brk; | 311 | mm->brk = brk; |
312 | populate = newbrk > oldbrk && (mm->def_flags & VM_LOCKED) != 0; | ||
313 | up_write(&mm->mmap_sem); | ||
314 | if (populate) | ||
315 | mm_populate(oldbrk, newbrk - oldbrk); | ||
316 | return brk; | ||
317 | |||
310 | out: | 318 | out: |
311 | retval = mm->brk; | 319 | retval = mm->brk; |
312 | up_write(&mm->mmap_sem); | 320 | up_write(&mm->mmap_sem); |
@@ -2600,10 +2608,8 @@ static unsigned long do_brk(unsigned long addr, unsigned long len) | |||
2600 | out: | 2608 | out: |
2601 | perf_event_mmap(vma); | 2609 | perf_event_mmap(vma); |
2602 | mm->total_vm += len >> PAGE_SHIFT; | 2610 | mm->total_vm += len >> PAGE_SHIFT; |
2603 | if (flags & VM_LOCKED) { | 2611 | if (flags & VM_LOCKED) |
2604 | if (!mlock_vma_pages_range(vma, addr, addr + len)) | 2612 | mm->locked_vm += (len >> PAGE_SHIFT); |
2605 | mm->locked_vm += (len >> PAGE_SHIFT); | ||
2606 | } | ||
2607 | return addr; | 2613 | return addr; |
2608 | } | 2614 | } |
2609 | 2615 | ||
@@ -2611,10 +2617,14 @@ unsigned long vm_brk(unsigned long addr, unsigned long len) | |||
2611 | { | 2617 | { |
2612 | struct mm_struct *mm = current->mm; | 2618 | struct mm_struct *mm = current->mm; |
2613 | unsigned long ret; | 2619 | unsigned long ret; |
2620 | bool populate; | ||
2614 | 2621 | ||
2615 | down_write(&mm->mmap_sem); | 2622 | down_write(&mm->mmap_sem); |
2616 | ret = do_brk(addr, len); | 2623 | ret = do_brk(addr, len); |
2624 | populate = ((mm->def_flags & VM_LOCKED) != 0); | ||
2617 | up_write(&mm->mmap_sem); | 2625 | up_write(&mm->mmap_sem); |
2626 | if (populate) | ||
2627 | mm_populate(addr, len); | ||
2618 | return ret; | 2628 | return ret; |
2619 | } | 2629 | } |
2620 | EXPORT_SYMBOL(vm_brk); | 2630 | EXPORT_SYMBOL(vm_brk); |