aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mmap.c
diff options
context:
space:
mode:
authorMichel Lespinasse <walken@google.com>2013-02-22 19:32:40 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-23 20:50:11 -0500
commit128557ffe147c282d8a25e6faeaec6099540bea4 (patch)
treeb3a0ce0540dd51f634f7ba9f7f7bf16576dce2cb /mm/mmap.c
parenta1ea9549a7254b17ba85809f4a0200abc21453a2 (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.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index 9b12e3047a86..a23e30f9719c 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -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
308set_brk: 310set_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
310out: 318out:
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)
2600out: 2608out:
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}
2620EXPORT_SYMBOL(vm_brk); 2630EXPORT_SYMBOL(vm_brk);